github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/label.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  // Label label
    18  //
    19  // swagger:model Label
    20  type Label struct {
    21  
    22  	// The color the label
    23  	Color string `json:"color,omitempty"`
    24  
    25  	// The creation time the label
    26  	// Format: date-time
    27  	CreationTime strfmt.DateTime `json:"creation_time,omitempty"`
    28  
    29  	// The description the label
    30  	Description string `json:"description,omitempty"`
    31  
    32  	// The ID of the label
    33  	ID int64 `json:"id,omitempty"`
    34  
    35  	// The name the label
    36  	Name string `json:"name,omitempty"`
    37  
    38  	// The ID of project that the label belongs to
    39  	ProjectID int64 `json:"project_id,omitempty"`
    40  
    41  	// The scope the label
    42  	Scope string `json:"scope,omitempty"`
    43  
    44  	// The update time of the label
    45  	// Format: date-time
    46  	UpdateTime strfmt.DateTime `json:"update_time,omitempty"`
    47  }
    48  
    49  // Validate validates this label
    50  func (m *Label) Validate(formats strfmt.Registry) error {
    51  	var res []error
    52  
    53  	if err := m.validateCreationTime(formats); err != nil {
    54  		res = append(res, err)
    55  	}
    56  
    57  	if err := m.validateUpdateTime(formats); err != nil {
    58  		res = append(res, err)
    59  	}
    60  
    61  	if len(res) > 0 {
    62  		return errors.CompositeValidationError(res...)
    63  	}
    64  	return nil
    65  }
    66  
    67  func (m *Label) validateCreationTime(formats strfmt.Registry) error {
    68  	if swag.IsZero(m.CreationTime) { // not required
    69  		return nil
    70  	}
    71  
    72  	if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil {
    73  		return err
    74  	}
    75  
    76  	return nil
    77  }
    78  
    79  func (m *Label) validateUpdateTime(formats strfmt.Registry) error {
    80  	if swag.IsZero(m.UpdateTime) { // not required
    81  		return nil
    82  	}
    83  
    84  	if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil {
    85  		return err
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  // ContextValidate validates this label based on context it is used
    92  func (m *Label) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    93  	return nil
    94  }
    95  
    96  // MarshalBinary interface implementation
    97  func (m *Label) MarshalBinary() ([]byte, error) {
    98  	if m == nil {
    99  		return nil, nil
   100  	}
   101  	return swag.WriteJSON(m)
   102  }
   103  
   104  // UnmarshalBinary interface implementation
   105  func (m *Label) UnmarshalBinary(b []byte) error {
   106  	var res Label
   107  	if err := swag.ReadJSON(b, &res); err != nil {
   108  		return err
   109  	}
   110  	*m = res
   111  	return nil
   112  }