github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/branch_editable.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  	"encoding/json"
    11  
    12  	"github.com/go-openapi/errors"
    13  	"github.com/go-openapi/strfmt"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // BranchEditable branchEditable
    19  //
    20  // swagger:model BranchEditable
    21  type BranchEditable struct {
    22  
    23  	// The commit that this branch is currently pointing at
    24  	// Format: uuid
    25  	CommitID *strfmt.UUID `json:"commitID,omitempty"`
    26  
    27  	// The human readable label or name of the branch.
    28  	Label *string `json:"label,omitempty"`
    29  
    30  	// The tracking method used
    31  	// Enum: [ignore auto_update notify]
    32  	TrackingType *string `json:"tracking_type,omitempty"`
    33  
    34  	// The branch_id of the branch that this branch tracks
    35  	// Format: uuid
    36  	Tracks *strfmt.UUID `json:"tracks,omitempty"`
    37  }
    38  
    39  // Validate validates this branch editable
    40  func (m *BranchEditable) Validate(formats strfmt.Registry) error {
    41  	var res []error
    42  
    43  	if err := m.validateCommitID(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if err := m.validateTrackingType(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if err := m.validateTracks(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if len(res) > 0 {
    56  		return errors.CompositeValidationError(res...)
    57  	}
    58  	return nil
    59  }
    60  
    61  func (m *BranchEditable) validateCommitID(formats strfmt.Registry) error {
    62  	if swag.IsZero(m.CommitID) { // not required
    63  		return nil
    64  	}
    65  
    66  	if err := validate.FormatOf("commitID", "body", "uuid", m.CommitID.String(), formats); err != nil {
    67  		return err
    68  	}
    69  
    70  	return nil
    71  }
    72  
    73  var branchEditableTypeTrackingTypePropEnum []interface{}
    74  
    75  func init() {
    76  	var res []string
    77  	if err := json.Unmarshal([]byte(`["ignore","auto_update","notify"]`), &res); err != nil {
    78  		panic(err)
    79  	}
    80  	for _, v := range res {
    81  		branchEditableTypeTrackingTypePropEnum = append(branchEditableTypeTrackingTypePropEnum, v)
    82  	}
    83  }
    84  
    85  const (
    86  
    87  	// BranchEditableTrackingTypeIgnore captures enum value "ignore"
    88  	BranchEditableTrackingTypeIgnore string = "ignore"
    89  
    90  	// BranchEditableTrackingTypeAutoUpdate captures enum value "auto_update"
    91  	BranchEditableTrackingTypeAutoUpdate string = "auto_update"
    92  
    93  	// BranchEditableTrackingTypeNotify captures enum value "notify"
    94  	BranchEditableTrackingTypeNotify string = "notify"
    95  )
    96  
    97  // prop value enum
    98  func (m *BranchEditable) validateTrackingTypeEnum(path, location string, value string) error {
    99  	if err := validate.EnumCase(path, location, value, branchEditableTypeTrackingTypePropEnum, true); err != nil {
   100  		return err
   101  	}
   102  	return nil
   103  }
   104  
   105  func (m *BranchEditable) validateTrackingType(formats strfmt.Registry) error {
   106  	if swag.IsZero(m.TrackingType) { // not required
   107  		return nil
   108  	}
   109  
   110  	// value enum
   111  	if err := m.validateTrackingTypeEnum("tracking_type", "body", *m.TrackingType); err != nil {
   112  		return err
   113  	}
   114  
   115  	return nil
   116  }
   117  
   118  func (m *BranchEditable) validateTracks(formats strfmt.Registry) error {
   119  	if swag.IsZero(m.Tracks) { // not required
   120  		return nil
   121  	}
   122  
   123  	if err := validate.FormatOf("tracks", "body", "uuid", m.Tracks.String(), formats); err != nil {
   124  		return err
   125  	}
   126  
   127  	return nil
   128  }
   129  
   130  // ContextValidate validates this branch editable based on context it is used
   131  func (m *BranchEditable) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   132  	return nil
   133  }
   134  
   135  // MarshalBinary interface implementation
   136  func (m *BranchEditable) MarshalBinary() ([]byte, error) {
   137  	if m == nil {
   138  		return nil, nil
   139  	}
   140  	return swag.WriteJSON(m)
   141  }
   142  
   143  // UnmarshalBinary interface implementation
   144  func (m *BranchEditable) UnmarshalBinary(b []byte) error {
   145  	var res BranchEditable
   146  	if err := swag.ReadJSON(b, &res); err != nil {
   147  		return err
   148  	}
   149  	*m = res
   150  	return nil
   151  }