github.com/hashicorp/hcp-sdk-go@v0.94.0/clients/cloud-log-service/preview/2021-03-30/models/cloudiam_user_principal.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 "strconv" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 ) 16 17 // CloudiamUserPrincipal UserPrincipal represents a human user of our platform. 18 // 19 // swagger:model cloudiamUserPrincipal 20 type CloudiamUserPrincipal struct { 21 22 // email is the unique email address of this user. 23 Email string `json:"email,omitempty"` 24 25 // full_name is the name of the user, as provided by Auth0. 26 FullName string `json:"full_name,omitempty"` 27 28 // id is the UUID public identifier for a user principal. It is safe 29 // to share this value with external users, and it should be how user principals 30 // are commonly identified also within our platform. 31 ID string `json:"id,omitempty"` 32 33 // identity_type is the identity type for this user. 34 IdentityType *UserPrincipalIdentityType `json:"identity_type,omitempty"` 35 36 // identity_types is an array of the identity types for this user. 37 IdentityTypes []*UserPrincipalIdentityType `json:"identity_types"` 38 39 // scim_synchronized denotes the user principal was synchronized from a 40 // customer's IdP using SCIM. 41 ScimSynchronized bool `json:"scim_synchronized,omitempty"` 42 43 // subject is the user ID from the authenticating IDP (e.g. Hydra). 44 Subject string `json:"subject,omitempty"` 45 } 46 47 // Validate validates this cloudiam user principal 48 func (m *CloudiamUserPrincipal) Validate(formats strfmt.Registry) error { 49 var res []error 50 51 if err := m.validateIdentityType(formats); err != nil { 52 res = append(res, err) 53 } 54 55 if err := m.validateIdentityTypes(formats); err != nil { 56 res = append(res, err) 57 } 58 59 if len(res) > 0 { 60 return errors.CompositeValidationError(res...) 61 } 62 return nil 63 } 64 65 func (m *CloudiamUserPrincipal) validateIdentityType(formats strfmt.Registry) error { 66 if swag.IsZero(m.IdentityType) { // not required 67 return nil 68 } 69 70 if m.IdentityType != nil { 71 if err := m.IdentityType.Validate(formats); err != nil { 72 if ve, ok := err.(*errors.Validation); ok { 73 return ve.ValidateName("identity_type") 74 } else if ce, ok := err.(*errors.CompositeError); ok { 75 return ce.ValidateName("identity_type") 76 } 77 return err 78 } 79 } 80 81 return nil 82 } 83 84 func (m *CloudiamUserPrincipal) validateIdentityTypes(formats strfmt.Registry) error { 85 if swag.IsZero(m.IdentityTypes) { // not required 86 return nil 87 } 88 89 for i := 0; i < len(m.IdentityTypes); i++ { 90 if swag.IsZero(m.IdentityTypes[i]) { // not required 91 continue 92 } 93 94 if m.IdentityTypes[i] != nil { 95 if err := m.IdentityTypes[i].Validate(formats); err != nil { 96 if ve, ok := err.(*errors.Validation); ok { 97 return ve.ValidateName("identity_types" + "." + strconv.Itoa(i)) 98 } else if ce, ok := err.(*errors.CompositeError); ok { 99 return ce.ValidateName("identity_types" + "." + strconv.Itoa(i)) 100 } 101 return err 102 } 103 } 104 105 } 106 107 return nil 108 } 109 110 // ContextValidate validate this cloudiam user principal based on the context it is used 111 func (m *CloudiamUserPrincipal) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 112 var res []error 113 114 if err := m.contextValidateIdentityType(ctx, formats); err != nil { 115 res = append(res, err) 116 } 117 118 if err := m.contextValidateIdentityTypes(ctx, formats); err != nil { 119 res = append(res, err) 120 } 121 122 if len(res) > 0 { 123 return errors.CompositeValidationError(res...) 124 } 125 return nil 126 } 127 128 func (m *CloudiamUserPrincipal) contextValidateIdentityType(ctx context.Context, formats strfmt.Registry) error { 129 130 if m.IdentityType != nil { 131 132 if swag.IsZero(m.IdentityType) { // not required 133 return nil 134 } 135 136 if err := m.IdentityType.ContextValidate(ctx, formats); err != nil { 137 if ve, ok := err.(*errors.Validation); ok { 138 return ve.ValidateName("identity_type") 139 } else if ce, ok := err.(*errors.CompositeError); ok { 140 return ce.ValidateName("identity_type") 141 } 142 return err 143 } 144 } 145 146 return nil 147 } 148 149 func (m *CloudiamUserPrincipal) contextValidateIdentityTypes(ctx context.Context, formats strfmt.Registry) error { 150 151 for i := 0; i < len(m.IdentityTypes); i++ { 152 153 if m.IdentityTypes[i] != nil { 154 155 if swag.IsZero(m.IdentityTypes[i]) { // not required 156 return nil 157 } 158 159 if err := m.IdentityTypes[i].ContextValidate(ctx, formats); err != nil { 160 if ve, ok := err.(*errors.Validation); ok { 161 return ve.ValidateName("identity_types" + "." + strconv.Itoa(i)) 162 } else if ce, ok := err.(*errors.CompositeError); ok { 163 return ce.ValidateName("identity_types" + "." + strconv.Itoa(i)) 164 } 165 return err 166 } 167 } 168 169 } 170 171 return nil 172 } 173 174 // MarshalBinary interface implementation 175 func (m *CloudiamUserPrincipal) MarshalBinary() ([]byte, error) { 176 if m == nil { 177 return nil, nil 178 } 179 return swag.WriteJSON(m) 180 } 181 182 // UnmarshalBinary interface implementation 183 func (m *CloudiamUserPrincipal) UnmarshalBinary(b []byte) error { 184 var res CloudiamUserPrincipal 185 if err := swag.ReadJSON(b, &res); err != nil { 186 return err 187 } 188 *m = res 189 return nil 190 }