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

// Secrets20231128DescribeProviderResponse secrets 20231128 describe provider response
//
// swagger:model secrets_20231128DescribeProviderResponse
type Secrets20231128DescribeProviderResponse struct {

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

	// name
	Name string `json:"name,omitempty"`

	// secret types
	SecretTypes map[string]DescribeProviderResponseSecretType `json:"secret_types,omitempty"`

	// title
	Title string `json:"title,omitempty"`
}

// Validate validates this secrets 20231128 describe provider response
func (m *Secrets20231128DescribeProviderResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *Secrets20231128DescribeProviderResponse) 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 *Secrets20231128DescribeProviderResponse) validateSecretTypes(formats strfmt.Registry) error {
	if swag.IsZero(m.SecretTypes) { // not required
		return nil
	}

	for k := range m.SecretTypes {

		if err := validate.Required("secret_types"+"."+k, "body", m.SecretTypes[k]); err != nil {
			return err
		}
		if val, ok := m.SecretTypes[k]; ok {
			if err := val.Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("secret_types" + "." + k)
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("secret_types" + "." + k)
				}
				return err
			}
		}

	}

	return nil
}

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

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

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

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

func (m *Secrets20231128DescribeProviderResponse) 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 *Secrets20231128DescribeProviderResponse) contextValidateSecretTypes(ctx context.Context, formats strfmt.Registry) error {

	for k := range m.SecretTypes {

		if val, ok := m.SecretTypes[k]; ok {
			if err := val.ContextValidate(ctx, formats); err != nil {
				return err
			}
		}

	}

	return nil
}

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

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