212 lines
4.6 KiB
Go
212 lines
4.6 KiB
Go
|
// Code generated by go-swagger; DO NOT EDIT.
|
||
|
|
||
|
package models
|
||
|
|
||
|
// This file was generated by the swagger tool.
|
||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/go-openapi/errors"
|
||
|
"github.com/go-openapi/strfmt"
|
||
|
"github.com/go-openapi/swag"
|
||
|
"github.com/go-openapi/validate"
|
||
|
)
|
||
|
|
||
|
// CommitStatus CommitStatus holds a single status of a single Commit
|
||
|
//
|
||
|
// swagger:model CommitStatus
|
||
|
type CommitStatus struct {
|
||
|
|
||
|
// context
|
||
|
Context string `json:"context,omitempty"`
|
||
|
|
||
|
// created
|
||
|
// Format: date-time
|
||
|
Created strfmt.DateTime `json:"created_at,omitempty"`
|
||
|
|
||
|
// description
|
||
|
Description string `json:"description,omitempty"`
|
||
|
|
||
|
// ID
|
||
|
ID int64 `json:"id,omitempty"`
|
||
|
|
||
|
// target URL
|
||
|
TargetURL string `json:"target_url,omitempty"`
|
||
|
|
||
|
// URL
|
||
|
URL string `json:"url,omitempty"`
|
||
|
|
||
|
// updated
|
||
|
// Format: date-time
|
||
|
Updated strfmt.DateTime `json:"updated_at,omitempty"`
|
||
|
|
||
|
// creator
|
||
|
Creator *User `json:"creator,omitempty"`
|
||
|
|
||
|
// status
|
||
|
Status CommitStatusState `json:"status,omitempty"`
|
||
|
}
|
||
|
|
||
|
// Validate validates this commit status
|
||
|
func (m *CommitStatus) Validate(formats strfmt.Registry) error {
|
||
|
var res []error
|
||
|
|
||
|
if err := m.validateCreated(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateUpdated(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateCreator(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.validateStatus(formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if len(res) > 0 {
|
||
|
return errors.CompositeValidationError(res...)
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *CommitStatus) validateCreated(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Created) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := validate.FormatOf("created_at", "body", "date-time", m.Created.String(), formats); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *CommitStatus) validateUpdated(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Updated) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := validate.FormatOf("updated_at", "body", "date-time", m.Updated.String(), formats); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *CommitStatus) validateCreator(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Creator) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if m.Creator != nil {
|
||
|
if err := m.Creator.Validate(formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("creator")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("creator")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *CommitStatus) validateStatus(formats strfmt.Registry) error {
|
||
|
if swag.IsZero(m.Status) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := m.Status.Validate(formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("status")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("status")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// ContextValidate validate this commit status based on the context it is used
|
||
|
func (m *CommitStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||
|
var res []error
|
||
|
|
||
|
if err := m.contextValidateCreator(ctx, formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if err := m.contextValidateStatus(ctx, formats); err != nil {
|
||
|
res = append(res, err)
|
||
|
}
|
||
|
|
||
|
if len(res) > 0 {
|
||
|
return errors.CompositeValidationError(res...)
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *CommitStatus) contextValidateCreator(ctx context.Context, formats strfmt.Registry) error {
|
||
|
|
||
|
if m.Creator != nil {
|
||
|
|
||
|
if swag.IsZero(m.Creator) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := m.Creator.ContextValidate(ctx, formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("creator")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("creator")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (m *CommitStatus) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error {
|
||
|
|
||
|
if swag.IsZero(m.Status) { // not required
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
if err := m.Status.ContextValidate(ctx, formats); err != nil {
|
||
|
if ve, ok := err.(*errors.Validation); ok {
|
||
|
return ve.ValidateName("status")
|
||
|
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||
|
return ce.ValidateName("status")
|
||
|
}
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// MarshalBinary interface implementation
|
||
|
func (m *CommitStatus) MarshalBinary() ([]byte, error) {
|
||
|
if m == nil {
|
||
|
return nil, nil
|
||
|
}
|
||
|
return swag.WriteJSON(m)
|
||
|
}
|
||
|
|
||
|
// UnmarshalBinary interface implementation
|
||
|
func (m *CommitStatus) UnmarshalBinary(b []byte) error {
|
||
|
var res CommitStatus
|
||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
*m = res
|
||
|
return nil
|
||
|
}
|