github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/user_resp.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  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/strfmt"
    13  	"github.com/go-openapi/swag"
    14  	"github.com/go-openapi/validate"
    15  )
    16  
    17  // UserResp user resp
    18  //
    19  // swagger:model UserResp
    20  type UserResp struct {
    21  
    22  	// indicate the admin privilege is grant by authenticator (LDAP), is always false unless it is the current login user
    23  	AdminRoleInAuth bool `json:"admin_role_in_auth"`
    24  
    25  	// comment
    26  	Comment string `json:"comment,omitempty"`
    27  
    28  	// The creation time of the user.
    29  	// Format: date-time
    30  	CreationTime strfmt.DateTime `json:"creation_time,omitempty"`
    31  
    32  	// email
    33  	Email string `json:"email,omitempty"`
    34  
    35  	// oidc user meta
    36  	OIDCUserMeta *OIDCUserInfo `json:"oidc_user_meta,omitempty"`
    37  
    38  	// realname
    39  	Realname string `json:"realname,omitempty"`
    40  
    41  	// sysadmin flag
    42  	SysadminFlag bool `json:"sysadmin_flag"`
    43  
    44  	// The update time of the user.
    45  	// Format: date-time
    46  	UpdateTime strfmt.DateTime `json:"update_time,omitempty"`
    47  
    48  	// user id
    49  	UserID int64 `json:"user_id,omitempty"`
    50  
    51  	// username
    52  	Username string `json:"username,omitempty"`
    53  }
    54  
    55  // Validate validates this user resp
    56  func (m *UserResp) Validate(formats strfmt.Registry) error {
    57  	var res []error
    58  
    59  	if err := m.validateCreationTime(formats); err != nil {
    60  		res = append(res, err)
    61  	}
    62  
    63  	if err := m.validateOIDCUserMeta(formats); err != nil {
    64  		res = append(res, err)
    65  	}
    66  
    67  	if err := m.validateUpdateTime(formats); err != nil {
    68  		res = append(res, err)
    69  	}
    70  
    71  	if len(res) > 0 {
    72  		return errors.CompositeValidationError(res...)
    73  	}
    74  	return nil
    75  }
    76  
    77  func (m *UserResp) validateCreationTime(formats strfmt.Registry) error {
    78  	if swag.IsZero(m.CreationTime) { // not required
    79  		return nil
    80  	}
    81  
    82  	if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil {
    83  		return err
    84  	}
    85  
    86  	return nil
    87  }
    88  
    89  func (m *UserResp) validateOIDCUserMeta(formats strfmt.Registry) error {
    90  	if swag.IsZero(m.OIDCUserMeta) { // not required
    91  		return nil
    92  	}
    93  
    94  	if m.OIDCUserMeta != nil {
    95  		if err := m.OIDCUserMeta.Validate(formats); err != nil {
    96  			if ve, ok := err.(*errors.Validation); ok {
    97  				return ve.ValidateName("oidc_user_meta")
    98  			} else if ce, ok := err.(*errors.CompositeError); ok {
    99  				return ce.ValidateName("oidc_user_meta")
   100  			}
   101  			return err
   102  		}
   103  	}
   104  
   105  	return nil
   106  }
   107  
   108  func (m *UserResp) validateUpdateTime(formats strfmt.Registry) error {
   109  	if swag.IsZero(m.UpdateTime) { // not required
   110  		return nil
   111  	}
   112  
   113  	if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil {
   114  		return err
   115  	}
   116  
   117  	return nil
   118  }
   119  
   120  // ContextValidate validate this user resp based on the context it is used
   121  func (m *UserResp) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   122  	var res []error
   123  
   124  	if err := m.contextValidateOIDCUserMeta(ctx, formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	if len(res) > 0 {
   129  		return errors.CompositeValidationError(res...)
   130  	}
   131  	return nil
   132  }
   133  
   134  func (m *UserResp) contextValidateOIDCUserMeta(ctx context.Context, formats strfmt.Registry) error {
   135  
   136  	if m.OIDCUserMeta != nil {
   137  		if err := m.OIDCUserMeta.ContextValidate(ctx, formats); err != nil {
   138  			if ve, ok := err.(*errors.Validation); ok {
   139  				return ve.ValidateName("oidc_user_meta")
   140  			} else if ce, ok := err.(*errors.CompositeError); ok {
   141  				return ce.ValidateName("oidc_user_meta")
   142  			}
   143  			return err
   144  		}
   145  	}
   146  
   147  	return nil
   148  }
   149  
   150  // MarshalBinary interface implementation
   151  func (m *UserResp) MarshalBinary() ([]byte, error) {
   152  	if m == nil {
   153  		return nil, nil
   154  	}
   155  	return swag.WriteJSON(m)
   156  }
   157  
   158  // UnmarshalBinary interface implementation
   159  func (m *UserResp) UnmarshalBinary(b []byte) error {
   160  	var res UserResp
   161  	if err := swag.ReadJSON(b, &res); err != nil {
   162  		return err
   163  	}
   164  	*m = res
   165  	return nil
   166  }