// 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"
)

// HashicorpCloudVagrantUpdateProviderRequest hashicorp cloud vagrant update provider request
//
// swagger:model hashicorp.cloud.vagrant.UpdateProviderRequest
type HashicorpCloudVagrantUpdateProviderRequest struct {

	// The name segment of the Box. As an example, this field would represent the
	// "vagrant" in "hashicorp/vagrant".
	Box string `json:"box,omitempty"`

	// external
	External *HashicorpCloudVagrantExternalProvider `json:"external,omitempty"`

	// hosted
	Hosted *HashicorpCloudVagrantHostedProvider `json:"hosted,omitempty"`

	// The name of the Provider.
	Provider string `json:"provider,omitempty"`

	// The Registry segment of the Box. As an example, this field would represent
	// the "hashicorp" in "hashicorp/vagrant".
	Registry string `json:"registry,omitempty"`

	// The name of the Version for the Provider.
	Version string `json:"version,omitempty"`
}

// Validate validates this hashicorp cloud vagrant update provider request
func (m *HashicorpCloudVagrantUpdateProviderRequest) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudVagrantUpdateProviderRequest) validateExternal(formats strfmt.Registry) error {
	if swag.IsZero(m.External) { // not required
		return nil
	}

	if m.External != nil {
		if err := m.External.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("external")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("external")
			}
			return err
		}
	}

	return nil
}

func (m *HashicorpCloudVagrantUpdateProviderRequest) validateHosted(formats strfmt.Registry) error {
	if swag.IsZero(m.Hosted) { // not required
		return nil
	}

	if m.Hosted != nil {
		if err := m.Hosted.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("hosted")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("hosted")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this hashicorp cloud vagrant update provider request based on the context it is used
func (m *HashicorpCloudVagrantUpdateProviderRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudVagrantUpdateProviderRequest) contextValidateExternal(ctx context.Context, formats strfmt.Registry) error {

	if m.External != nil {
		if err := m.External.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("external")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("external")
			}
			return err
		}
	}

	return nil
}

func (m *HashicorpCloudVagrantUpdateProviderRequest) contextValidateHosted(ctx context.Context, formats strfmt.Registry) error {

	if m.Hosted != nil {
		if err := m.Hosted.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("hosted")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("hosted")
			}
			return err
		}
	}

	return nil
}

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

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