// 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 (
	"strconv"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// Deploy deploy
//
// swagger:model deploy
type Deploy struct {

	// admin url
	AdminURL string `json:"admin_url,omitempty"`

	// branch
	Branch string `json:"branch,omitempty"`

	// build id
	BuildID string `json:"build_id,omitempty"`

	// commit ref
	CommitRef string `json:"commit_ref,omitempty"`

	// commit url
	CommitURL string `json:"commit_url,omitempty"`

	// context
	Context string `json:"context,omitempty"`

	// created at
	CreatedAt string `json:"created_at,omitempty"`

	// deploy ssl url
	DeploySslURL string `json:"deploy_ssl_url,omitempty"`

	// deploy url
	DeployURL string `json:"deploy_url,omitempty"`

	// draft
	Draft bool `json:"draft,omitempty"`

	// error message
	ErrorMessage string `json:"error_message,omitempty"`

	// framework
	Framework string `json:"framework,omitempty"`

	// function schedules
	FunctionSchedules []*FunctionSchedule `json:"function_schedules"`

	// id
	ID string `json:"id,omitempty"`

	// locked
	Locked bool `json:"locked,omitempty"`

	// name
	Name string `json:"name,omitempty"`

	// published at
	PublishedAt string `json:"published_at,omitempty"`

	// required
	Required []string `json:"required"`

	// required functions
	RequiredFunctions []string `json:"required_functions"`

	// review id
	ReviewID float64 `json:"review_id,omitempty"`

	// review url
	ReviewURL string `json:"review_url,omitempty"`

	// screenshot url
	ScreenshotURL string `json:"screenshot_url,omitempty"`

	// site id
	SiteID string `json:"site_id,omitempty"`

	// skipped
	Skipped bool `json:"skipped,omitempty"`

	// ssl url
	SslURL string `json:"ssl_url,omitempty"`

	// state
	State string `json:"state,omitempty"`

	// title
	Title string `json:"title,omitempty"`

	// updated at
	UpdatedAt string `json:"updated_at,omitempty"`

	// url
	URL string `json:"url,omitempty"`

	// user id
	UserID string `json:"user_id,omitempty"`
}

// Validate validates this deploy
func (m *Deploy) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateFunctionSchedules(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *Deploy) validateFunctionSchedules(formats strfmt.Registry) error {

	if swag.IsZero(m.FunctionSchedules) { // not required
		return nil
	}

	for i := 0; i < len(m.FunctionSchedules); i++ {
		if swag.IsZero(m.FunctionSchedules[i]) { // not required
			continue
		}

		if m.FunctionSchedules[i] != nil {
			if err := m.FunctionSchedules[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("function_schedules" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// MarshalBinary interface implementation
func (m *Deploy) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *Deploy) UnmarshalBinary(b []byte) error {
	var res Deploy
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
