// 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" "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // CombinedStatus CombinedStatus holds the combined state of several statuses for a single commit // // swagger:model CombinedStatus type CombinedStatus struct { // commit URL CommitURL string `json:"commit_url,omitempty"` // s h a SHA string `json:"sha,omitempty"` // statuses Statuses []*CommitStatus `json:"statuses"` // total count TotalCount int64 `json:"total_count,omitempty"` // URL URL string `json:"url,omitempty"` // repository Repository *Repository `json:"repository,omitempty"` // state State CommitStatusState `json:"state,omitempty"` } // Validate validates this combined status func (m *CombinedStatus) Validate(formats strfmt.Registry) error { var res []error if err := m.validateStatuses(formats); err != nil { res = append(res, err) } if err := m.validateRepository(formats); err != nil { res = append(res, err) } if err := m.validateState(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CombinedStatus) validateStatuses(formats strfmt.Registry) error { if swag.IsZero(m.Statuses) { // not required return nil } for i := 0; i < len(m.Statuses); i++ { if swag.IsZero(m.Statuses[i]) { // not required continue } if m.Statuses[i] != nil { if err := m.Statuses[i].Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("statuses" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("statuses" + "." + strconv.Itoa(i)) } return err } } } return nil } func (m *CombinedStatus) validateRepository(formats strfmt.Registry) error { if swag.IsZero(m.Repository) { // not required return nil } if m.Repository != nil { if err := m.Repository.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("repository") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("repository") } return err } } return nil } func (m *CombinedStatus) validateState(formats strfmt.Registry) error { if swag.IsZero(m.State) { // not required return nil } if err := m.State.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("state") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("state") } return err } return nil } // ContextValidate validate this combined status based on the context it is used func (m *CombinedStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateStatuses(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateRepository(ctx, formats); err != nil { res = append(res, err) } if err := m.contextValidateState(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *CombinedStatus) contextValidateStatuses(ctx context.Context, formats strfmt.Registry) error { for i := 0; i < len(m.Statuses); i++ { if m.Statuses[i] != nil { if swag.IsZero(m.Statuses[i]) { // not required return nil } if err := m.Statuses[i].ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("statuses" + "." + strconv.Itoa(i)) } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("statuses" + "." + strconv.Itoa(i)) } return err } } } return nil } func (m *CombinedStatus) contextValidateRepository(ctx context.Context, formats strfmt.Registry) error { if m.Repository != nil { if swag.IsZero(m.Repository) { // not required return nil } if err := m.Repository.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("repository") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("repository") } return err } } return nil } func (m *CombinedStatus) contextValidateState(ctx context.Context, formats strfmt.Registry) error { if swag.IsZero(m.State) { // not required return nil } if err := m.State.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("state") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("state") } return err } return nil } // MarshalBinary interface implementation func (m *CombinedStatus) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *CombinedStatus) UnmarshalBinary(b []byte) error { var res CombinedStatus if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }