-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
previous_consent_session.go
175 lines (135 loc) · 4.18 KB
/
previous_consent_session.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
// 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 (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// PreviousConsentSession The response used to return used consent requests
// same as HandledLoginRequest, just with consent_request exposed as json
//
// swagger:model PreviousConsentSession
type PreviousConsentSession struct {
// consent request
ConsentRequest *ConsentRequest `json:"consent_request,omitempty"`
// grant access token audience
GrantAccessTokenAudience StringSlicePipeDelimiter `json:"grant_access_token_audience,omitempty"`
// grant scope
GrantScope StringSlicePipeDelimiter `json:"grant_scope,omitempty"`
// handled at
// Format: date-time
HandledAt NullTime `json:"handled_at,omitempty"`
// Remember, if set to true, tells ORY Hydra to remember this consent authorization and reuse it if the same
// client asks the same user for the same, or a subset of, scope.
Remember bool `json:"remember,omitempty"`
// RememberFor sets how long the consent authorization should be remembered for in seconds. If set to `0`, the
// authorization will be remembered indefinitely.
RememberFor int64 `json:"remember_for,omitempty"`
// session
Session *ConsentRequestSession `json:"session,omitempty"`
}
// Validate validates this previous consent session
func (m *PreviousConsentSession) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateConsentRequest(formats); err != nil {
res = append(res, err)
}
if err := m.validateGrantAccessTokenAudience(formats); err != nil {
res = append(res, err)
}
if err := m.validateGrantScope(formats); err != nil {
res = append(res, err)
}
if err := m.validateHandledAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateSession(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *PreviousConsentSession) validateConsentRequest(formats strfmt.Registry) error {
if swag.IsZero(m.ConsentRequest) { // not required
return nil
}
if m.ConsentRequest != nil {
if err := m.ConsentRequest.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("consent_request")
}
return err
}
}
return nil
}
func (m *PreviousConsentSession) validateGrantAccessTokenAudience(formats strfmt.Registry) error {
if swag.IsZero(m.GrantAccessTokenAudience) { // not required
return nil
}
if err := m.GrantAccessTokenAudience.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("grant_access_token_audience")
}
return err
}
return nil
}
func (m *PreviousConsentSession) validateGrantScope(formats strfmt.Registry) error {
if swag.IsZero(m.GrantScope) { // not required
return nil
}
if err := m.GrantScope.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("grant_scope")
}
return err
}
return nil
}
func (m *PreviousConsentSession) validateHandledAt(formats strfmt.Registry) error {
if swag.IsZero(m.HandledAt) { // not required
return nil
}
if err := m.HandledAt.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("handled_at")
}
return err
}
return nil
}
func (m *PreviousConsentSession) validateSession(formats strfmt.Registry) error {
if swag.IsZero(m.Session) { // not required
return nil
}
if m.Session != nil {
if err := m.Session.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("session")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *PreviousConsentSession) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *PreviousConsentSession) UnmarshalBinary(b []byte) error {
var res PreviousConsentSession
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}