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

// SecretServiceUpdateAppRotatingSecretBody secret service update app rotating secret body
//
// swagger:model SecretServiceUpdateAppRotatingSecretBody
type SecretServiceUpdateAppRotatingSecretBody struct {

	// aws access key details
	AwsAccessKeyDetails *Secrets20231128AwsIAMUserAccessKeyParams `json:"aws_access_key_details,omitempty"`

	// azure application password details
	AzureApplicationPasswordDetails *Secrets20231128AzureApplicationPasswordParams `json:"azure_application_password_details,omitempty"`

	// confluent cloud api key details
	ConfluentCloudAPIKeyDetails *Secrets20231128ConfluentCloudAPIKeyParams `json:"confluent_cloud_api_key_details,omitempty"`

	// gcp service account key details
	GcpServiceAccountKeyDetails *Secrets20231128GcpServiceAccountKeyParams `json:"gcp_service_account_key_details,omitempty"`

	// integration name
	IntegrationName string `json:"integration_name,omitempty"`

	// mongodb atlas user password details
	MongodbAtlasUserPasswordDetails *Secrets20231128MongoDBAtlasSecretDetails `json:"mongodb_atlas_user_password_details,omitempty"`

	// mssql user password details
	MssqlUserPasswordDetails *Secrets20231128MssqlUserPasswordDetails `json:"mssql_user_password_details,omitempty"`

	// mysql user password details
	MysqlUserPasswordDetails *Secrets20231128MysqlUserPasswordDetails `json:"mysql_user_password_details,omitempty"`

	// postgres user password details
	PostgresUserPasswordDetails *Secrets20231128PostgresParams `json:"postgres_user_password_details,omitempty"`

	// random user password details
	RandomUserPasswordDetails *Secrets20231128RandomParams `json:"random_user_password_details,omitempty"`

	// rotate on update
	RotateOnUpdate bool `json:"rotate_on_update,omitempty"`

	// rotation policy name
	RotationPolicyName string `json:"rotation_policy_name,omitempty"`

	// twilio api key details
	TwilioAPIKeyDetails Secrets20231128TwilioAPIKeyDetails `json:"twilio_api_key_details,omitempty"`
}

// Validate validates this secret service update app rotating secret body
func (m *SecretServiceUpdateAppRotatingSecretBody) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

func (m *SecretServiceUpdateAppRotatingSecretBody) validateAwsAccessKeyDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.AwsAccessKeyDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) validateAzureApplicationPasswordDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.AzureApplicationPasswordDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) validateConfluentCloudAPIKeyDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.ConfluentCloudAPIKeyDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) validateGcpServiceAccountKeyDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.GcpServiceAccountKeyDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) validateMongodbAtlasUserPasswordDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.MongodbAtlasUserPasswordDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) validateMssqlUserPasswordDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.MssqlUserPasswordDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) validateMysqlUserPasswordDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.MysqlUserPasswordDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) validatePostgresUserPasswordDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.PostgresUserPasswordDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) validateRandomUserPasswordDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.RandomUserPasswordDetails) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this secret service update app rotating secret body based on the context it is used
func (m *SecretServiceUpdateAppRotatingSecretBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidateAwsAccessKeyDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.AwsAccessKeyDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidateAzureApplicationPasswordDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.AzureApplicationPasswordDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidateConfluentCloudAPIKeyDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.ConfluentCloudAPIKeyDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidateGcpServiceAccountKeyDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.GcpServiceAccountKeyDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidateMongodbAtlasUserPasswordDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.MongodbAtlasUserPasswordDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidateMssqlUserPasswordDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.MssqlUserPasswordDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidateMysqlUserPasswordDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.MysqlUserPasswordDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidatePostgresUserPasswordDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.PostgresUserPasswordDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppRotatingSecretBody) contextValidateRandomUserPasswordDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.RandomUserPasswordDetails != nil {

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

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

	return nil
}

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

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