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

// HashicorpCloudVault20201125PluginRegistrationStatus hashicorp cloud vault 20201125 plugin registration status
//
// swagger:model hashicorp.cloud.vault_20201125.PluginRegistrationStatus
type HashicorpCloudVault20201125PluginRegistrationStatus struct {

	// is_registered tells whether the plugin is currently registered or not on the vault cluster
	IsRegistered bool `json:"is_registered,omitempty"`

	// opt_in represents who manages the plugin lifecycle - customer or HCPV
	OptIn *HashicorpCloudVault20201125OptInState `json:"opt_in,omitempty"`

	// plugin_name is the plugin name
	PluginName string `json:"plugin_name,omitempty"`

	// plugin_type is the plugin type
	PluginType *HashicorpCloudVault20201125PluginType `json:"plugin_type,omitempty"`

	// plugin_version is the plugin version
	PluginVersion string `json:"plugin_version,omitempty"`
}

// Validate validates this hashicorp cloud vault 20201125 plugin registration status
func (m *HashicorpCloudVault20201125PluginRegistrationStatus) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudVault20201125PluginRegistrationStatus) validateOptIn(formats strfmt.Registry) error {
	if swag.IsZero(m.OptIn) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudVault20201125PluginRegistrationStatus) validatePluginType(formats strfmt.Registry) error {
	if swag.IsZero(m.PluginType) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud vault 20201125 plugin registration status based on the context it is used
func (m *HashicorpCloudVault20201125PluginRegistrationStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *HashicorpCloudVault20201125PluginRegistrationStatus) contextValidateOptIn(ctx context.Context, formats strfmt.Registry) error {

	if m.OptIn != nil {

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

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

	return nil
}

func (m *HashicorpCloudVault20201125PluginRegistrationStatus) contextValidatePluginType(ctx context.Context, formats strfmt.Registry) error {

	if m.PluginType != nil {

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

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

	return nil
}

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

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