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

// HashicorpCloudPacker20220411BucketAncestryParent hashicorp cloud packer 20220411 bucket ancestry parent
//
// swagger:model hashicorp.cloud.packer_20220411.BucketAncestry.Parent
type HashicorpCloudPacker20220411BucketAncestryParent struct {

	// The parent bucket slug.
	BucketSlug string `json:"bucket_slug,omitempty"`

	// The image channel associated with this relationship.
	Channel string `json:"channel,omitempty"`

	// The iteration currently assigned to the channel associated with the ancestry relationship.
	ChannelIteration *HashicorpCloudPacker20220411BucketAncestryParentChannelIteration `json:"channel_iteration,omitempty"`

	// The parent iteration fingerprint.
	IterationFingerprint string `json:"iteration_fingerprint,omitempty"`

	// The parent iteration ULID.
	IterationID string `json:"iteration_id,omitempty"`

	// The parent iteration incremental version.
	IterationIncrementalVersion int32 `json:"iteration_incremental_version,omitempty"`
}

// Validate validates this hashicorp cloud packer 20220411 bucket ancestry parent
func (m *HashicorpCloudPacker20220411BucketAncestryParent) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *HashicorpCloudPacker20220411BucketAncestryParent) validateChannelIteration(formats strfmt.Registry) error {
	if swag.IsZero(m.ChannelIteration) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *HashicorpCloudPacker20220411BucketAncestryParent) contextValidateChannelIteration(ctx context.Context, formats strfmt.Registry) error {

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

	return nil
}

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

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