// 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" ) // CommonAPIToken common API token // // swagger:model common.APIToken type CommonAPIToken struct { // description // Required: true // Max Length: 1000 Description *string `json:"description"` // expires at ExpiresAt string `json:"expires_at,omitempty"` // roles // Required: true // Max Length: 10000 Roles *string `json:"roles"` // token // Required: true // Max Length: 1000 Token *string `json:"token"` } // Validate validates this common API token func (m *CommonAPIToken) Validate(formats strfmt.Registry) error { var res []error if err := m.validateDescription(formats); err != nil { res = append(res, err) } if err := m.validateRoles(formats); err != nil { res = append(res, err) } if err := m.validateToken(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CommonAPIToken) validateDescription(formats strfmt.Registry) error { if err := validate.Required("description", "body", m.Description); err != nil { return err } if err := validate.MaxLength("description", "body", *m.Description, 1000); err != nil { return err } return nil } func (m *CommonAPIToken) validateRoles(formats strfmt.Registry) error { if err := validate.Required("roles", "body", m.Roles); err != nil { return err } if err := validate.MaxLength("roles", "body", *m.Roles, 10000); err != nil { return err } return nil } func (m *CommonAPIToken) validateToken(formats strfmt.Registry) error { if err := validate.Required("token", "body", m.Token); err != nil { return err } if err := validate.MaxLength("token", "body", *m.Token, 1000); err != nil { return err } return nil } // ContextValidate validates this common API token based on context it is used func (m *CommonAPIToken) ContextValidate(ctx context.Context, formats strfmt.Registry) error { return nil } // MarshalBinary interface implementation func (m *CommonAPIToken) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *CommonAPIToken) UnmarshalBinary(b []byte) error { var res CommonAPIToken if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }