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

// DescribeProviderResponseSecretType describe provider response secret type
//
// swagger:model DescribeProviderResponseSecretType
type DescribeProviderResponseSecretType struct {

	// capabilities
	Capabilities []*Secrets20231128Capability `json:"capabilities"`

	// config schema
	ConfigSchema *Secrets20231128DescribeProviderResponseSchema `json:"config_schema,omitempty"`

	// values schema
	ValuesSchema *Secrets20231128DescribeProviderResponseSchema `json:"values_schema,omitempty"`
}

// Validate validates this describe provider response secret type
func (m *DescribeProviderResponseSecretType) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *DescribeProviderResponseSecretType) validateCapabilities(formats strfmt.Registry) error {
	if swag.IsZero(m.Capabilities) { // not required
		return nil
	}

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

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

	}

	return nil
}

func (m *DescribeProviderResponseSecretType) validateConfigSchema(formats strfmt.Registry) error {
	if swag.IsZero(m.ConfigSchema) { // not required
		return nil
	}

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

	return nil
}

func (m *DescribeProviderResponseSecretType) validateValuesSchema(formats strfmt.Registry) error {
	if swag.IsZero(m.ValuesSchema) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this describe provider response secret type based on the context it is used
func (m *DescribeProviderResponseSecretType) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *DescribeProviderResponseSecretType) contextValidateCapabilities(ctx context.Context, formats strfmt.Registry) error {

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

		if m.Capabilities[i] != nil {

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

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

	}

	return nil
}

func (m *DescribeProviderResponseSecretType) contextValidateConfigSchema(ctx context.Context, formats strfmt.Registry) error {

	if m.ConfigSchema != nil {

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

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

	return nil
}

func (m *DescribeProviderResponseSecretType) contextValidateValuesSchema(ctx context.Context, formats strfmt.Registry) error {

	if m.ValuesSchema != nil {

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

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

	return nil
}

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

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