github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/invitation.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package mono_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  // Invitation invitation
    18  //
    19  // swagger:model Invitation
    20  type Invitation struct {
    21  
    22  	// added
    23  	// Format: date-time
    24  	Added strfmt.DateTime `json:"added,omitempty"`
    25  
    26  	// changed
    27  	// Format: date-time
    28  	Changed strfmt.DateTime `json:"changed,omitempty"`
    29  
    30  	// email
    31  	Email string `json:"email,omitempty"`
    32  
    33  	// Only populated if you're a superuser and if the invite was created in this request, or if you are a user getting their own invitations
    34  	InviteCode string `json:"inviteCode,omitempty"`
    35  
    36  	// Only populated if you're a superuser and if the invite was created in this request
    37  	InviteURL string `json:"inviteUrl,omitempty"`
    38  
    39  	// invited by
    40  	InvitedBy string `json:"invitedBy,omitempty"`
    41  
    42  	// organization
    43  	Organization *Organization `json:"organization,omitempty"`
    44  }
    45  
    46  // Validate validates this invitation
    47  func (m *Invitation) Validate(formats strfmt.Registry) error {
    48  	var res []error
    49  
    50  	if err := m.validateAdded(formats); err != nil {
    51  		res = append(res, err)
    52  	}
    53  
    54  	if err := m.validateChanged(formats); err != nil {
    55  		res = append(res, err)
    56  	}
    57  
    58  	if err := m.validateOrganization(formats); err != nil {
    59  		res = append(res, err)
    60  	}
    61  
    62  	if len(res) > 0 {
    63  		return errors.CompositeValidationError(res...)
    64  	}
    65  	return nil
    66  }
    67  
    68  func (m *Invitation) validateAdded(formats strfmt.Registry) error {
    69  	if swag.IsZero(m.Added) { // not required
    70  		return nil
    71  	}
    72  
    73  	if err := validate.FormatOf("added", "body", "date-time", m.Added.String(), formats); err != nil {
    74  		return err
    75  	}
    76  
    77  	return nil
    78  }
    79  
    80  func (m *Invitation) validateChanged(formats strfmt.Registry) error {
    81  	if swag.IsZero(m.Changed) { // not required
    82  		return nil
    83  	}
    84  
    85  	if err := validate.FormatOf("changed", "body", "date-time", m.Changed.String(), formats); err != nil {
    86  		return err
    87  	}
    88  
    89  	return nil
    90  }
    91  
    92  func (m *Invitation) validateOrganization(formats strfmt.Registry) error {
    93  	if swag.IsZero(m.Organization) { // not required
    94  		return nil
    95  	}
    96  
    97  	if m.Organization != nil {
    98  		if err := m.Organization.Validate(formats); err != nil {
    99  			if ve, ok := err.(*errors.Validation); ok {
   100  				return ve.ValidateName("organization")
   101  			}
   102  			return err
   103  		}
   104  	}
   105  
   106  	return nil
   107  }
   108  
   109  // ContextValidate validate this invitation based on the context it is used
   110  func (m *Invitation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   111  	var res []error
   112  
   113  	if err := m.contextValidateOrganization(ctx, formats); err != nil {
   114  		res = append(res, err)
   115  	}
   116  
   117  	if len(res) > 0 {
   118  		return errors.CompositeValidationError(res...)
   119  	}
   120  	return nil
   121  }
   122  
   123  func (m *Invitation) contextValidateOrganization(ctx context.Context, formats strfmt.Registry) error {
   124  
   125  	if m.Organization != nil {
   126  		if err := m.Organization.ContextValidate(ctx, formats); err != nil {
   127  			if ve, ok := err.(*errors.Validation); ok {
   128  				return ve.ValidateName("organization")
   129  			}
   130  			return err
   131  		}
   132  	}
   133  
   134  	return nil
   135  }
   136  
   137  // MarshalBinary interface implementation
   138  func (m *Invitation) MarshalBinary() ([]byte, error) {
   139  	if m == nil {
   140  		return nil, nil
   141  	}
   142  	return swag.WriteJSON(m)
   143  }
   144  
   145  // UnmarshalBinary interface implementation
   146  func (m *Invitation) UnmarshalBinary(b []byte) error {
   147  	var res Invitation
   148  	if err := swag.ReadJSON(b, &res); err != nil {
   149  		return err
   150  	}
   151  	*m = res
   152  	return nil
   153  }