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

// SecretServiceUpdateAppDynamicSecretBody secret service update app dynamic secret body
//
// swagger:model SecretServiceUpdateAppDynamicSecretBody
type SecretServiceUpdateAppDynamicSecretBody struct {

	// aws assume role details
	AwsAssumeRoleDetails *Secrets20231128AwsAssumeRoleDetails `json:"aws_assume_role_details,omitempty"`

	// default ttl
	DefaultTTL string `json:"default_ttl,omitempty"`

	// gcp service account impersonation details
	GcpServiceAccountImpersonationDetails *Secrets20231128GcpServiceAccountImpersonationDetails `json:"gcp_service_account_impersonation_details,omitempty"`
}

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

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

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

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

func (m *SecretServiceUpdateAppDynamicSecretBody) validateAwsAssumeRoleDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.AwsAssumeRoleDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *SecretServiceUpdateAppDynamicSecretBody) validateGcpServiceAccountImpersonationDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.GcpServiceAccountImpersonationDetails) { // not required
		return nil
	}

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

	return nil
}

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

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

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

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

func (m *SecretServiceUpdateAppDynamicSecretBody) contextValidateAwsAssumeRoleDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.AwsAssumeRoleDetails != nil {

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

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

	return nil
}

func (m *SecretServiceUpdateAppDynamicSecretBody) contextValidateGcpServiceAccountImpersonationDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.GcpServiceAccountImpersonationDetails != nil {

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

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

	return nil
}

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

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