github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/schedule.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  // Schedule schedule
    18  //
    19  // swagger:model Schedule
    20  type Schedule struct {
    21  
    22  	// the creation time of the schedule.
    23  	// Read Only: true
    24  	// Format: date-time
    25  	CreationTime strfmt.DateTime `json:"creation_time,omitempty"`
    26  
    27  	// The id of the schedule.
    28  	// Read Only: true
    29  	ID int64 `json:"id,omitempty"`
    30  
    31  	// The parameters of schedule job
    32  	Parameters map[string]interface{} `json:"parameters,omitempty"`
    33  
    34  	// schedule
    35  	Schedule *ScheduleObj `json:"schedule,omitempty"`
    36  
    37  	// The status of the schedule.
    38  	// Read Only: true
    39  	Status string `json:"status,omitempty"`
    40  
    41  	// the update time of the schedule.
    42  	// Read Only: true
    43  	// Format: date-time
    44  	UpdateTime strfmt.DateTime `json:"update_time,omitempty"`
    45  }
    46  
    47  // Validate validates this schedule
    48  func (m *Schedule) Validate(formats strfmt.Registry) error {
    49  	var res []error
    50  
    51  	if err := m.validateCreationTime(formats); err != nil {
    52  		res = append(res, err)
    53  	}
    54  
    55  	if err := m.validateSchedule(formats); err != nil {
    56  		res = append(res, err)
    57  	}
    58  
    59  	if err := m.validateUpdateTime(formats); err != nil {
    60  		res = append(res, err)
    61  	}
    62  
    63  	if len(res) > 0 {
    64  		return errors.CompositeValidationError(res...)
    65  	}
    66  	return nil
    67  }
    68  
    69  func (m *Schedule) validateCreationTime(formats strfmt.Registry) error {
    70  	if swag.IsZero(m.CreationTime) { // not required
    71  		return nil
    72  	}
    73  
    74  	if err := validate.FormatOf("creation_time", "body", "date-time", m.CreationTime.String(), formats); err != nil {
    75  		return err
    76  	}
    77  
    78  	return nil
    79  }
    80  
    81  func (m *Schedule) validateSchedule(formats strfmt.Registry) error {
    82  	if swag.IsZero(m.Schedule) { // not required
    83  		return nil
    84  	}
    85  
    86  	if m.Schedule != nil {
    87  		if err := m.Schedule.Validate(formats); err != nil {
    88  			if ve, ok := err.(*errors.Validation); ok {
    89  				return ve.ValidateName("schedule")
    90  			} else if ce, ok := err.(*errors.CompositeError); ok {
    91  				return ce.ValidateName("schedule")
    92  			}
    93  			return err
    94  		}
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  func (m *Schedule) validateUpdateTime(formats strfmt.Registry) error {
   101  	if swag.IsZero(m.UpdateTime) { // not required
   102  		return nil
   103  	}
   104  
   105  	if err := validate.FormatOf("update_time", "body", "date-time", m.UpdateTime.String(), formats); err != nil {
   106  		return err
   107  	}
   108  
   109  	return nil
   110  }
   111  
   112  // ContextValidate validate this schedule based on the context it is used
   113  func (m *Schedule) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   114  	var res []error
   115  
   116  	if err := m.contextValidateCreationTime(ctx, formats); err != nil {
   117  		res = append(res, err)
   118  	}
   119  
   120  	if err := m.contextValidateID(ctx, formats); err != nil {
   121  		res = append(res, err)
   122  	}
   123  
   124  	if err := m.contextValidateSchedule(ctx, formats); err != nil {
   125  		res = append(res, err)
   126  	}
   127  
   128  	if err := m.contextValidateStatus(ctx, formats); err != nil {
   129  		res = append(res, err)
   130  	}
   131  
   132  	if err := m.contextValidateUpdateTime(ctx, formats); err != nil {
   133  		res = append(res, err)
   134  	}
   135  
   136  	if len(res) > 0 {
   137  		return errors.CompositeValidationError(res...)
   138  	}
   139  	return nil
   140  }
   141  
   142  func (m *Schedule) contextValidateCreationTime(ctx context.Context, formats strfmt.Registry) error {
   143  
   144  	if err := validate.ReadOnly(ctx, "creation_time", "body", strfmt.DateTime(m.CreationTime)); err != nil {
   145  		return err
   146  	}
   147  
   148  	return nil
   149  }
   150  
   151  func (m *Schedule) contextValidateID(ctx context.Context, formats strfmt.Registry) error {
   152  
   153  	if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil {
   154  		return err
   155  	}
   156  
   157  	return nil
   158  }
   159  
   160  func (m *Schedule) contextValidateSchedule(ctx context.Context, formats strfmt.Registry) error {
   161  
   162  	if m.Schedule != nil {
   163  		if err := m.Schedule.ContextValidate(ctx, formats); err != nil {
   164  			if ve, ok := err.(*errors.Validation); ok {
   165  				return ve.ValidateName("schedule")
   166  			} else if ce, ok := err.(*errors.CompositeError); ok {
   167  				return ce.ValidateName("schedule")
   168  			}
   169  			return err
   170  		}
   171  	}
   172  
   173  	return nil
   174  }
   175  
   176  func (m *Schedule) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {
   177  
   178  	if err := validate.ReadOnly(ctx, "status", "body", string(m.Status)); err != nil {
   179  		return err
   180  	}
   181  
   182  	return nil
   183  }
   184  
   185  func (m *Schedule) contextValidateUpdateTime(ctx context.Context, formats strfmt.Registry) error {
   186  
   187  	if err := validate.ReadOnly(ctx, "update_time", "body", strfmt.DateTime(m.UpdateTime)); err != nil {
   188  		return err
   189  	}
   190  
   191  	return nil
   192  }
   193  
   194  // MarshalBinary interface implementation
   195  func (m *Schedule) MarshalBinary() ([]byte, error) {
   196  	if m == nil {
   197  		return nil, nil
   198  	}
   199  	return swag.WriteJSON(m)
   200  }
   201  
   202  // UnmarshalBinary interface implementation
   203  func (m *Schedule) UnmarshalBinary(b []byte) error {
   204  	var res Schedule
   205  	if err := swag.ReadJSON(b, &res); err != nil {
   206  		return err
   207  	}
   208  	*m = res
   209  	return nil
   210  }