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

// SecretServiceCreateGcpServiceAccountKeyRotatingSecretBody secret service create gcp service account key rotating secret body
//
// swagger:model SecretServiceCreateGcpServiceAccountKeyRotatingSecretBody
type SecretServiceCreateGcpServiceAccountKeyRotatingSecretBody struct {

	// gcp service account key params
	GcpServiceAccountKeyParams *Secrets20231128GcpServiceAccountKeyParams `json:"gcp_service_account_key_params,omitempty"`

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

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

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

// Validate validates this secret service create gcp service account key rotating secret body
func (m *SecretServiceCreateGcpServiceAccountKeyRotatingSecretBody) Validate(formats strfmt.Registry) error {
	var res []error

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

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

func (m *SecretServiceCreateGcpServiceAccountKeyRotatingSecretBody) validateGcpServiceAccountKeyParams(formats strfmt.Registry) error {
	if swag.IsZero(m.GcpServiceAccountKeyParams) { // not required
		return nil
	}

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

	return nil
}

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

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

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

func (m *SecretServiceCreateGcpServiceAccountKeyRotatingSecretBody) contextValidateGcpServiceAccountKeyParams(ctx context.Context, formats strfmt.Registry) error {

	if m.GcpServiceAccountKeyParams != nil {

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

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

	return nil
}

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

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