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

// Secrets20231128DynamicSecret secrets 20231128 dynamic secret
//
// swagger:model secrets_20231128DynamicSecret
type Secrets20231128DynamicSecret struct {

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

	// created at
	// Format: date-time
	CreatedAt strfmt.DateTime `json:"created_at,omitempty"`

	// created by id
	CreatedByID string `json:"created_by_id,omitempty"`

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

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

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

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

	// provider
	Provider string `json:"provider,omitempty"`

	// updated at
	// Format: date-time
	UpdatedAt strfmt.DateTime `json:"updated_at,omitempty"`

	// updated by id
	UpdatedByID string `json:"updated_by_id,omitempty"`
}

// Validate validates this secrets 20231128 dynamic secret
func (m *Secrets20231128DynamicSecret) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

	if err := validate.FormatOf("created_at", "body", "date-time", m.CreatedAt.String(), formats); err != nil {
		return err
	}

	return nil
}

func (m *Secrets20231128DynamicSecret) 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
}

func (m *Secrets20231128DynamicSecret) validateUpdatedAt(formats strfmt.Registry) error {
	if swag.IsZero(m.UpdatedAt) { // not required
		return nil
	}

	if err := validate.FormatOf("updated_at", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
		return err
	}

	return nil
}

// ContextValidate validate this secrets 20231128 dynamic secret based on the context it is used
func (m *Secrets20231128DynamicSecret) 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 *Secrets20231128DynamicSecret) 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 *Secrets20231128DynamicSecret) 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 *Secrets20231128DynamicSecret) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

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