-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain_permission_subscription.go
202 lines (152 loc) · 6.37 KB
/
domain_permission_subscription.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// DomainPermissionSubscription DomainPermissionSubscription represents an auto-refreshing subscription to a list of domain permissions (allows, blocks).
//
// swagger:model DomainPermissionSubscription
type DomainPermissionSubscription struct {
// If true, this domain permission subscription will "adopt" domain permissions which already exist on the instance, and which meet the following conditions: 1) they have no subscription ID (ie., they're "orphaned") and 2) they are present in the subscribed list. Such orphaned domain permissions will be given this subscription's subscription ID value.
// Example: false
AdoptOrphans bool `json:"adopt_orphans,omitempty"`
// If true, domain permissions arising from this subscription will be created as drafts that must be approved by a moderator to take effect. If false, domain permissions from this subscription will come into force immediately.
// Example: true
AsDraft bool `json:"as_draft,omitempty"`
// MIME content type to use when parsing the permissions list.
// Example: text/csv
ContentType string `json:"content_type,omitempty"`
// Count of domain permission entries discovered at URI on last (successful) fetch.
// Example: 53
// Read Only: true
Count uint64 `json:"count,omitempty"`
// Time at which the subscription was created (ISO 8601 Datetime).
// Example: 2021-07-30T09:20:25+00:00
CreatedAt string `json:"created_at,omitempty"`
// ID of the account that created this subscription.
// Example: 01FBW21XJA09XYX51KV5JVBW0F
// Read Only: true
CreatedBy string `json:"created_by,omitempty"`
// If most recent fetch attempt failed, this field will contain an error message related to the fetch attempt.
// Example: Oopsie doopsie, we made a fucky wucky.
// Read Only: true
Error string `json:"error,omitempty"`
// (Optional) password to set for basic auth when doing a fetch of URI.
// Example: admin123
FetchPassword string `json:"fetch_password,omitempty"`
// (Optional) username to set for basic auth when doing a fetch of URI.
// Example: admin123
FetchUsername string `json:"fetch_username,omitempty"`
// Time of the most recent fetch attempt (successful or otherwise) (ISO 8601 Datetime).
// Example: 2021-07-30T09:20:25+00:00
// Read Only: true
FetchedAt string `json:"fetched_at,omitempty"`
// The ID of the domain permission subscription.
// Example: 01FBW21XJA09XYX51KV5JVBW0F
// Read Only: true
ID string `json:"id,omitempty"`
// The type of domain permission subscription (allow, block).
// Example: block
PermissionType string `json:"permission_type,omitempty"`
// Priority of this subscription compared to others of the same permission type. 0-255 (higher = higher priority).
// Example: 100
Priority uint8 `json:"priority,omitempty"`
// Time of the most recent successful fetch (ISO 8601 Datetime).
// Example: 2021-07-30T09:20:25+00:00
// Read Only: true
SuccessfullyFetchedAt string `json:"successfully_fetched_at,omitempty"`
// Title of this subscription, as set by admin who created or updated it.
// Example: really cool list of neato pals
Title string `json:"title,omitempty"`
// URI to call in order to fetch the permissions list.
// Example: https://www.example.org/blocklists/list1.csv
URI string `json:"uri,omitempty"`
}
// Validate validates this domain permission subscription
func (m *DomainPermissionSubscription) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validate this domain permission subscription based on the context it is used
func (m *DomainPermissionSubscription) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateCount(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateCreatedBy(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateError(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateFetchedAt(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateID(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateSuccessfullyFetchedAt(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *DomainPermissionSubscription) contextValidateCount(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "count", "body", uint64(m.Count)); err != nil {
return err
}
return nil
}
func (m *DomainPermissionSubscription) contextValidateCreatedBy(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "created_by", "body", string(m.CreatedBy)); err != nil {
return err
}
return nil
}
func (m *DomainPermissionSubscription) contextValidateError(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "error", "body", string(m.Error)); err != nil {
return err
}
return nil
}
func (m *DomainPermissionSubscription) contextValidateFetchedAt(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "fetched_at", "body", string(m.FetchedAt)); err != nil {
return err
}
return nil
}
func (m *DomainPermissionSubscription) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "id", "body", string(m.ID)); err != nil {
return err
}
return nil
}
func (m *DomainPermissionSubscription) contextValidateSuccessfullyFetchedAt(ctx context.Context, formats strfmt.Registry) error {
if err := validate.ReadOnly(ctx, "successfully_fetched_at", "body", string(m.SuccessfullyFetchedAt)); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *DomainPermissionSubscription) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *DomainPermissionSubscription) UnmarshalBinary(b []byte) error {
var res DomainPermissionSubscription
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}