// 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"
	"github.com/go-openapi/validate"
)

// HashicorpCloudPackerRegistryBillingDeprovision hashicorp cloud packer registry billing deprovision
//
// swagger:model hashicorp.cloud.packer.RegistryBillingDeprovision
type HashicorpCloudPackerRegistryBillingDeprovision struct {

	// The time the registry was deactivated of billing.
	// Format: date-time
	At strfmt.DateTime `json:"at,omitempty"`

	// Reason of why the registry was deactivated.
	Reason *HashicorpCloudPackerRegistryBillingDeprovisionReason `json:"reason,omitempty"`
}

// Validate validates this hashicorp cloud packer registry billing deprovision
func (m *HashicorpCloudPackerRegistryBillingDeprovision) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudPackerRegistryBillingDeprovision) validateAt(formats strfmt.Registry) error {
	if swag.IsZero(m.At) { // not required
		return nil
	}

	if err := validate.FormatOf("at", "body", "date-time", m.At.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *HashicorpCloudPackerRegistryBillingDeprovision) validateReason(formats strfmt.Registry) error {
	if swag.IsZero(m.Reason) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *HashicorpCloudPackerRegistryBillingDeprovision) contextValidateReason(ctx context.Context, formats strfmt.Registry) error {

	if m.Reason != nil {

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

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

	return nil
}

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

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