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

// HashicorpCloudGlobalNetworkManager20220215AgentBootstrapResponse hashicorp cloud global network manager 20220215 agent bootstrap response
//
// swagger:model hashicorp.cloud.global_network_manager_20220215.AgentBootstrapResponse
type HashicorpCloudGlobalNetworkManager20220215AgentBootstrapResponse struct {

	// bootstrap
	Bootstrap *HashicorpCloudGlobalNetworkManager20220215ClusterBootstrap `json:"bootstrap,omitempty"`

	// cluster
	Cluster *HashicorpCloudGlobalNetworkManager20220215Cluster `json:"cluster,omitempty"`
}

// Validate validates this hashicorp cloud global network manager 20220215 agent bootstrap response
func (m *HashicorpCloudGlobalNetworkManager20220215AgentBootstrapResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215AgentBootstrapResponse) validateBootstrap(formats strfmt.Registry) error {
	if swag.IsZero(m.Bootstrap) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudGlobalNetworkManager20220215AgentBootstrapResponse) validateCluster(formats strfmt.Registry) error {
	if swag.IsZero(m.Cluster) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud global network manager 20220215 agent bootstrap response based on the context it is used
func (m *HashicorpCloudGlobalNetworkManager20220215AgentBootstrapResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215AgentBootstrapResponse) contextValidateBootstrap(ctx context.Context, formats strfmt.Registry) error {

	if m.Bootstrap != nil {

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

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

	return nil
}

func (m *HashicorpCloudGlobalNetworkManager20220215AgentBootstrapResponse) contextValidateCluster(ctx context.Context, formats strfmt.Registry) error {

	if m.Cluster != nil {

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

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

	return nil
}

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

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