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

// HashicorpCloudPacker20230101Parent hashicorp cloud packer 20230101 parent
//
// swagger:model hashicorp.cloud.packer_20230101.Parent
type HashicorpCloudPacker20230101Parent struct {

	// The parent bucket name.
	BucketName string `json:"bucket_name,omitempty"`

	// The name of the channel associated with this relationship.
	ChannelName string `json:"channel_name,omitempty"`

	// The version currently assigned to the channel associated with the ancestry
	// relationship.
	ChannelVersion *HashicorpCloudPacker20230101ChannelVersion `json:"channel_version,omitempty"`

	// The parent version fingerprint.
	VersionFingerprint string `json:"version_fingerprint,omitempty"`

	// The parent version ULID.
	VersionID string `json:"version_id,omitempty"`

	// The parent version name.
	VersionName string `json:"version_name,omitempty"`
}

// Validate validates this hashicorp cloud packer 20230101 parent
func (m *HashicorpCloudPacker20230101Parent) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudPacker20230101Parent) validateChannelVersion(formats strfmt.Registry) error {
	if swag.IsZero(m.ChannelVersion) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *HashicorpCloudPacker20230101Parent) contextValidateChannelVersion(ctx context.Context, formats strfmt.Registry) error {

	if m.ChannelVersion != nil {

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

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

	return nil
}

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

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