github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/new_token.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  // NewToken new token
    18  //
    19  // swagger:model NewToken
    20  type NewToken struct {
    21  
    22  	// name
    23  	Name string `json:"name,omitempty"`
    24  
    25  	// token
    26  	Token string `json:"token,omitempty"`
    27  
    28  	// token ID
    29  	// Format: uuid
    30  	TokenID strfmt.UUID `json:"tokenID,omitempty"`
    31  }
    32  
    33  // Validate validates this new token
    34  func (m *NewToken) Validate(formats strfmt.Registry) error {
    35  	var res []error
    36  
    37  	if err := m.validateTokenID(formats); err != nil {
    38  		res = append(res, err)
    39  	}
    40  
    41  	if len(res) > 0 {
    42  		return errors.CompositeValidationError(res...)
    43  	}
    44  	return nil
    45  }
    46  
    47  func (m *NewToken) validateTokenID(formats strfmt.Registry) error {
    48  	if swag.IsZero(m.TokenID) { // not required
    49  		return nil
    50  	}
    51  
    52  	if err := validate.FormatOf("tokenID", "body", "uuid", m.TokenID.String(), formats); err != nil {
    53  		return err
    54  	}
    55  
    56  	return nil
    57  }
    58  
    59  // ContextValidate validates this new token based on context it is used
    60  func (m *NewToken) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    61  	return nil
    62  }
    63  
    64  // MarshalBinary interface implementation
    65  func (m *NewToken) MarshalBinary() ([]byte, error) {
    66  	if m == nil {
    67  		return nil, nil
    68  	}
    69  	return swag.WriteJSON(m)
    70  }
    71  
    72  // UnmarshalBinary interface implementation
    73  func (m *NewToken) UnmarshalBinary(b []byte) error {
    74  	var res NewToken
    75  	if err := swag.ReadJSON(b, &res); err != nil {
    76  		return err
    77  	}
    78  	*m = res
    79  	return nil
    80  }