github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/secrets/secrets_models/user_secret_diff.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package secrets_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  	"strconv"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // UserSecretDiff user secret diff
    19  // swagger:model UserSecretDiff
    20  type UserSecretDiff struct {
    21  
    22  	// public key
    23  	// Required: true
    24  	PublicKey *string `json:"public_key"`
    25  
    26  	// shares
    27  	Shares []*UserSecretShare `json:"shares"`
    28  
    29  	// user id
    30  	// Required: true
    31  	// Format: uuid
    32  	UserID *strfmt.UUID `json:"user_id"`
    33  }
    34  
    35  // Validate validates this user secret diff
    36  func (m *UserSecretDiff) Validate(formats strfmt.Registry) error {
    37  	var res []error
    38  
    39  	if err := m.validatePublicKey(formats); err != nil {
    40  		res = append(res, err)
    41  	}
    42  
    43  	if err := m.validateShares(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if err := m.validateUserID(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if len(res) > 0 {
    52  		return errors.CompositeValidationError(res...)
    53  	}
    54  	return nil
    55  }
    56  
    57  func (m *UserSecretDiff) validatePublicKey(formats strfmt.Registry) error {
    58  
    59  	if err := validate.Required("public_key", "body", m.PublicKey); err != nil {
    60  		return err
    61  	}
    62  
    63  	return nil
    64  }
    65  
    66  func (m *UserSecretDiff) validateShares(formats strfmt.Registry) error {
    67  
    68  	if swag.IsZero(m.Shares) { // not required
    69  		return nil
    70  	}
    71  
    72  	for i := 0; i < len(m.Shares); i++ {
    73  		if swag.IsZero(m.Shares[i]) { // not required
    74  			continue
    75  		}
    76  
    77  		if m.Shares[i] != nil {
    78  			if err := m.Shares[i].Validate(formats); err != nil {
    79  				if ve, ok := err.(*errors.Validation); ok {
    80  					return ve.ValidateName("shares" + "." + strconv.Itoa(i))
    81  				}
    82  				return err
    83  			}
    84  		}
    85  
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  func (m *UserSecretDiff) validateUserID(formats strfmt.Registry) error {
    92  
    93  	if err := validate.Required("user_id", "body", m.UserID); err != nil {
    94  		return err
    95  	}
    96  
    97  	if err := validate.FormatOf("user_id", "body", "uuid", m.UserID.String(), formats); err != nil {
    98  		return err
    99  	}
   100  
   101  	return nil
   102  }
   103  
   104  // MarshalBinary interface implementation
   105  func (m *UserSecretDiff) MarshalBinary() ([]byte, error) {
   106  	if m == nil {
   107  		return nil, nil
   108  	}
   109  	return swag.WriteJSON(m)
   110  }
   111  
   112  // UnmarshalBinary interface implementation
   113  func (m *UserSecretDiff) UnmarshalBinary(b []byte) error {
   114  	var res UserSecretDiff
   115  	if err := swag.ReadJSON(b, &res); err != nil {
   116  		return err
   117  	}
   118  	*m = res
   119  	return nil
   120  }