235 lines
6.0 KiB
Go
235 lines
6.0 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"
|
|
"encoding/json"
|
|
|
|
"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 is the unique context identifier for the status
|
|
Context string `json:"context,omitempty"`
|
|
|
|
// created
|
|
// Format: date-time
|
|
Created strfmt.DateTime `json:"created_at,omitempty"`
|
|
|
|
// Description provides a brief description of the status
|
|
Description string `json:"description,omitempty"`
|
|
|
|
// ID is the unique identifier for the commit status
|
|
ID int64 `json:"id,omitempty"`
|
|
|
|
// State represents the status state (pending, success, error, failure)
|
|
// pending CommitStatusPending CommitStatusPending is for when the CommitStatus is Pending
|
|
// success CommitStatusSuccess CommitStatusSuccess is for when the CommitStatus is Success
|
|
// error CommitStatusError CommitStatusError is for when the CommitStatus is Error
|
|
// failure CommitStatusFailure CommitStatusFailure is for when the CommitStatus is Failure
|
|
// warning CommitStatusWarning CommitStatusWarning is for when the CommitStatus is Warning
|
|
// skipped CommitStatusSkipped CommitStatusSkipped is for when CommitStatus is Skipped
|
|
// Enum: ["pending","success","error","failure","warning","skipped"]
|
|
State string `json:"status,omitempty"`
|
|
|
|
// TargetURL is the URL to link to for more details
|
|
TargetURL string `json:"target_url,omitempty"`
|
|
|
|
// URL is the API URL for this status
|
|
URL string `json:"url,omitempty"`
|
|
|
|
// updated
|
|
// Format: date-time
|
|
Updated strfmt.DateTime `json:"updated_at,omitempty"`
|
|
|
|
// creator
|
|
Creator *User `json:"creator,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.validateState(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 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
|
|
}
|
|
|
|
var commitStatusTypeStatePropEnum []interface{}
|
|
|
|
func init() {
|
|
var res []string
|
|
if err := json.Unmarshal([]byte(`["pending","success","error","failure","warning","skipped"]`), &res); err != nil {
|
|
panic(err)
|
|
}
|
|
for _, v := range res {
|
|
commitStatusTypeStatePropEnum = append(commitStatusTypeStatePropEnum, v)
|
|
}
|
|
}
|
|
|
|
const (
|
|
|
|
// CommitStatusStatePending captures enum value "pending"
|
|
CommitStatusStatePending string = "pending"
|
|
|
|
// CommitStatusStateSuccess captures enum value "success"
|
|
CommitStatusStateSuccess string = "success"
|
|
|
|
// CommitStatusStateError captures enum value "error"
|
|
CommitStatusStateError string = "error"
|
|
|
|
// CommitStatusStateFailure captures enum value "failure"
|
|
CommitStatusStateFailure string = "failure"
|
|
|
|
// CommitStatusStateWarning captures enum value "warning"
|
|
CommitStatusStateWarning string = "warning"
|
|
|
|
// CommitStatusStateSkipped captures enum value "skipped"
|
|
CommitStatusStateSkipped string = "skipped"
|
|
)
|
|
|
|
// prop value enum
|
|
func (m *CommitStatus) validateStateEnum(path, location string, value string) error {
|
|
if err := validate.EnumCase(path, location, value, commitStatusTypeStatePropEnum, true); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *CommitStatus) validateState(formats strfmt.Registry) error {
|
|
if swag.IsZero(m.State) { // not required
|
|
return nil
|
|
}
|
|
|
|
// value enum
|
|
if err := m.validateStateEnum("status", "body", m.State); 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
|
|
}
|
|
|
|
// 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 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
|
|
}
|
|
|
|
// 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
|
|
}
|