// 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"
	cloud "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models"
)

// HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody UpdateAddOnDefinitionRequest is the request used to update an existing
// Add-on definition
//
// swagger:model hashicorp.cloud.waypoint.v20241122.WaypointService.UpdateAddOnDefinitionBody
type HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody struct {

	// Add-on definition to be updated
	AddOnDefinition *HashicorpCloudWaypointV20241122AddOnDefinition `json:"add_on_definition,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	Description string `json:"description,omitempty"`

	// existing add on definition
	ExistingAddOnDefinition *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyExistingAddOnDefinition `json:"existing_add_on_definition,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	Labels []string `json:"labels"`

	// DEPRECATED: Use add_on_definition instead.
	ModuleSource string `json:"module_source,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	Name string `json:"name,omitempty"`

	// namespace
	Namespace *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespace `json:"namespace,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	// Format: byte
	ReadmeMarkdownTemplate strfmt.Base64 `json:"readme_markdown_template,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	ReadmeTemplate string `json:"readme_template,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	Summary string `json:"summary,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	TerraformCloudWorkspaceDetails *HashicorpCloudWaypointV20241122TerraformCloudWorkspaceDetails `json:"terraform_cloud_workspace_details,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	TfAgentPoolID string `json:"tf_agent_pool_id,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	TfExecutionMode string `json:"tf_execution_mode,omitempty"`

	// Field mask to update only specific fields. I.e. if you want a field updated,
	// you must include it in the field mask.
	UpdateMask string `json:"update_mask,omitempty"`

	// DEPRECATED: Use add_on_definition instead.
	VariableOptions []*HashicorpCloudWaypointV20241122TFModuleVariable `json:"variable_options"`
}

// Validate validates this hashicorp cloud waypoint v20241122 waypoint service update add on definition body
func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) validateAddOnDefinition(formats strfmt.Registry) error {
	if swag.IsZero(m.AddOnDefinition) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) validateExistingAddOnDefinition(formats strfmt.Registry) error {
	if swag.IsZero(m.ExistingAddOnDefinition) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) validateNamespace(formats strfmt.Registry) error {
	if swag.IsZero(m.Namespace) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) validateTerraformCloudWorkspaceDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.TerraformCloudWorkspaceDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) validateVariableOptions(formats strfmt.Registry) error {
	if swag.IsZero(m.VariableOptions) { // not required
		return nil
	}

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

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

	}

	return nil
}

// ContextValidate validate this hashicorp cloud waypoint v20241122 waypoint service update add on definition body based on the context it is used
func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) contextValidateAddOnDefinition(ctx context.Context, formats strfmt.Registry) error {

	if m.AddOnDefinition != nil {

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

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) contextValidateExistingAddOnDefinition(ctx context.Context, formats strfmt.Registry) error {

	if m.ExistingAddOnDefinition != nil {

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

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) contextValidateNamespace(ctx context.Context, formats strfmt.Registry) error {

	if m.Namespace != nil {

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

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) contextValidateTerraformCloudWorkspaceDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.TerraformCloudWorkspaceDetails != nil {

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

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBody) contextValidateVariableOptions(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(m.VariableOptions); i++ {

		if m.VariableOptions[i] != nil {

			if swag.IsZero(m.VariableOptions[i]) { // not required
				return nil
			}

			if err := m.VariableOptions[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("variable_options" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("variable_options" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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

// HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyExistingAddOnDefinition Add-on definition ref without ID
//
// # Reference to an existing Add-on
//
// swagger:model HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyExistingAddOnDefinition
type HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyExistingAddOnDefinition struct {

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

// Validate validates this hashicorp cloud waypoint v20241122 waypoint service update add on definition body existing add on definition
func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyExistingAddOnDefinition) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this hashicorp cloud waypoint v20241122 waypoint service update add on definition body existing add on definition based on context it is used
func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyExistingAddOnDefinition) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

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

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

// HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespace Global references the entire server. This is used in some APIs
// as a way to read/write values that are server-global.
//
// swagger:model HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespace
type HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespace struct {

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

	// location
	Location *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespaceLocation `json:"location,omitempty"`
}

// Validate validates this hashicorp cloud waypoint v20241122 waypoint service update add on definition body namespace
func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespace) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespace) validateLocation(formats strfmt.Registry) error {
	if swag.IsZero(m.Location) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud waypoint v20241122 waypoint service update add on definition body namespace based on the context it is used
func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespace) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespace) contextValidateLocation(ctx context.Context, formats strfmt.Registry) error {

	if m.Location != nil {

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

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

	return nil
}

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

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

// HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespaceLocation When used via an API request, this is populated and used to populate id.
//
// When used via an API request, this is populated and used to populate id.
//
// swagger:model HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespaceLocation
type HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespaceLocation struct {

	// region is the region that the resource is located in. It is
	// optional if the object being referenced is a global object.
	Region *cloud.HashicorpCloudLocationRegion `json:"region,omitempty"`
}

// Validate validates this hashicorp cloud waypoint v20241122 waypoint service update add on definition body namespace location
func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespaceLocation) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespaceLocation) validateRegion(formats strfmt.Registry) error {
	if swag.IsZero(m.Region) { // not required
		return nil
	}

	if m.Region != nil {
		if err := m.Region.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("namespace" + "." + "location" + "." + "region")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("namespace" + "." + "location" + "." + "region")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this hashicorp cloud waypoint v20241122 waypoint service update add on definition body namespace location based on the context it is used
func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespaceLocation) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudWaypointV20241122WaypointServiceUpdateAddOnDefinitionBodyNamespaceLocation) contextValidateRegion(ctx context.Context, formats strfmt.Registry) error {

	if m.Region != nil {

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

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

	return nil
}

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

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