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

// HashicorpCloudPacker20230101AssignChannelVersionResponse hashicorp cloud packer 20230101 assign channel version response
//
// swagger:model hashicorp.cloud.packer_20230101.AssignChannelVersionResponse
type HashicorpCloudPacker20230101AssignChannelVersionResponse struct {

	// The version fingerprint that was assigned.
	Fingerprint string `json:"fingerprint,omitempty"`

	// The full source channel object.
	SourceChannel *HashicorpCloudPacker20230101Channel `json:"source_channel,omitempty"`

	// The full target channel object that received the assignment.
	TargetChannel *HashicorpCloudPacker20230101Channel `json:"target_channel,omitempty"`

	// Full version details.
	Version *HashicorpCloudPacker20230101Version `json:"version,omitempty"`
}

// Validate validates this hashicorp cloud packer 20230101 assign channel version response
func (m *HashicorpCloudPacker20230101AssignChannelVersionResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudPacker20230101AssignChannelVersionResponse) validateSourceChannel(formats strfmt.Registry) error {
	if swag.IsZero(m.SourceChannel) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudPacker20230101AssignChannelVersionResponse) validateTargetChannel(formats strfmt.Registry) error {
	if swag.IsZero(m.TargetChannel) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudPacker20230101AssignChannelVersionResponse) validateVersion(formats strfmt.Registry) error {
	if swag.IsZero(m.Version) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud packer 20230101 assign channel version response based on the context it is used
func (m *HashicorpCloudPacker20230101AssignChannelVersionResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudPacker20230101AssignChannelVersionResponse) contextValidateSourceChannel(ctx context.Context, formats strfmt.Registry) error {

	if m.SourceChannel != nil {

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

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

	return nil
}

func (m *HashicorpCloudPacker20230101AssignChannelVersionResponse) contextValidateTargetChannel(ctx context.Context, formats strfmt.Registry) error {

	if m.TargetChannel != nil {

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

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

	return nil
}

func (m *HashicorpCloudPacker20230101AssignChannelVersionResponse) contextValidateVersion(ctx context.Context, formats strfmt.Registry) error {

	if m.Version != nil {

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

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

	return nil
}

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

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