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

// HashicorpCloudGlobalNetworkManager20220215GetClusterManagementTokenDetailsResponse hashicorp cloud global network manager 20220215 get cluster management token details response
//
// swagger:model hashicorp.cloud.global_network_manager_20220215.GetClusterManagementTokenDetailsResponse
type HashicorpCloudGlobalNetworkManager20220215GetClusterManagementTokenDetailsResponse struct {

	// accessor_id is the Consul accessor id of the cluster's management token
	AccessorID string `json:"accessor_id,omitempty"`

	// invalid_reasons are the reasons why the token is invalid. If the token
	// is not invalid (it is valid, unknown, or n/a), this will returned
	// "unspecified". A token could potentially be invalid for multiple reasons,
	// so lists all reasons
	InvalidReasons []*HashicorpCloudGlobalNetworkManager20220215TokenInvalidReason `json:"invalid_reasons"`

	// time_until_expiration is the amount of time until the token expires.
	// If a token has no expiration, returned duration returned will be nil.
	// Already expired tokens are indicated by TOKEN_INVALID_REASON_DOES_NOT_EXIST
	TimeUntilExpiration string `json:"time_until_expiration,omitempty"`

	// validity_status is the token's validity status
	ValidityStatus *HashicorpCloudGlobalNetworkManager20220215TokenValidityStatus `json:"validity_status,omitempty"`
}

// Validate validates this hashicorp cloud global network manager 20220215 get cluster management token details response
func (m *HashicorpCloudGlobalNetworkManager20220215GetClusterManagementTokenDetailsResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215GetClusterManagementTokenDetailsResponse) validateInvalidReasons(formats strfmt.Registry) error {
	if swag.IsZero(m.InvalidReasons) { // not required
		return nil
	}

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

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

	}

	return nil
}

func (m *HashicorpCloudGlobalNetworkManager20220215GetClusterManagementTokenDetailsResponse) validateValidityStatus(formats strfmt.Registry) error {
	if swag.IsZero(m.ValidityStatus) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud global network manager 20220215 get cluster management token details response based on the context it is used
func (m *HashicorpCloudGlobalNetworkManager20220215GetClusterManagementTokenDetailsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudGlobalNetworkManager20220215GetClusterManagementTokenDetailsResponse) contextValidateInvalidReasons(ctx context.Context, formats strfmt.Registry) error {

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

		if m.InvalidReasons[i] != nil {

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

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

	}

	return nil
}

func (m *HashicorpCloudGlobalNetworkManager20220215GetClusterManagementTokenDetailsResponse) contextValidateValidityStatus(ctx context.Context, formats strfmt.Registry) error {

	if m.ValidityStatus != nil {

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

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

	return nil
}

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

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