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

// Secrets20230613SyncIntegration secrets 20230613 sync integration
//
// swagger:model secrets_20230613SyncIntegration
type Secrets20230613SyncIntegration struct {

	// aws sm connection details
	AwsSmConnectionDetails *Secrets20230613AwsSmConnectionDetailsResponse `json:"aws_sm_connection_details,omitempty"`

	// azure kv connection details
	AzureKvConnectionDetails *Secrets20230613AzureKvConnectionDetailsResponse `json:"azure_kv_connection_details,omitempty"`

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

	// created by
	CreatedBy *Secrets20230613Principal `json:"created_by,omitempty"`

	// gcp sm connection details
	GcpSmConnectionDetails *Secrets20230613GcpSmConnectionDetailsResponse `json:"gcp_sm_connection_details,omitempty"`

	// gh org connection details
	GhOrgConnectionDetails *Secrets20230613GhOrgConnectionDetailsResponse `json:"gh_org_connection_details,omitempty"`

	// gh repo connection details
	GhRepoConnectionDetails *Secrets20230613GhRepoConnectionDetailsResponse `json:"gh_repo_connection_details,omitempty"`

	// hcp terraform connection details
	HcpTerraformConnectionDetails *Secrets20230613HcpTerraformConnectionDetailsResponse `json:"hcp_terraform_connection_details,omitempty"`

	// location
	Location *CloudlocationLocation `json:"location,omitempty"`

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

	// type
	Type string `json:"type,omitempty"`

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

	// updated by
	UpdatedBy *Secrets20230613Principal `json:"updated_by,omitempty"`

	// vercel project connection details
	VercelProjectConnectionDetails *Secrets20230613VercelProjectConnectionDetailsResponse `json:"vercel_project_connection_details,omitempty"`
}

// Validate validates this secrets 20230613 sync integration
func (m *Secrets20230613SyncIntegration) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

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

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

func (m *Secrets20230613SyncIntegration) validateAwsSmConnectionDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.AwsSmConnectionDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613SyncIntegration) validateAzureKvConnectionDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.AzureKvConnectionDetails) { // not required
		return nil
	}

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

	return nil
}

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) validateGcpSmConnectionDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.GcpSmConnectionDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613SyncIntegration) validateGhOrgConnectionDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.GhOrgConnectionDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613SyncIntegration) validateGhRepoConnectionDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.GhRepoConnectionDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613SyncIntegration) validateHcpTerraformConnectionDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.HcpTerraformConnectionDetails) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613SyncIntegration) validateLocation(formats strfmt.Registry) error {
	if swag.IsZero(m.Location) { // not required
		return nil
	}

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

	return nil
}

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

func (m *Secrets20230613SyncIntegration) validateUpdatedBy(formats strfmt.Registry) error {
	if swag.IsZero(m.UpdatedBy) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613SyncIntegration) validateVercelProjectConnectionDetails(formats strfmt.Registry) error {
	if swag.IsZero(m.VercelProjectConnectionDetails) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this secrets 20230613 sync integration based on the context it is used
func (m *Secrets20230613SyncIntegration) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

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

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

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

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

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

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

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

func (m *Secrets20230613SyncIntegration) contextValidateAwsSmConnectionDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.AwsSmConnectionDetails != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateAzureKvConnectionDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.AzureKvConnectionDetails != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateCreatedBy(ctx context.Context, formats strfmt.Registry) error {

	if m.CreatedBy != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateGcpSmConnectionDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.GcpSmConnectionDetails != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateGhOrgConnectionDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.GhOrgConnectionDetails != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateGhRepoConnectionDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.GhRepoConnectionDetails != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateHcpTerraformConnectionDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.HcpTerraformConnectionDetails != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateLocation(ctx context.Context, formats strfmt.Registry) error {

	if m.Location != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateUpdatedBy(ctx context.Context, formats strfmt.Registry) error {

	if m.UpdatedBy != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncIntegration) contextValidateVercelProjectConnectionDetails(ctx context.Context, formats strfmt.Registry) error {

	if m.VercelProjectConnectionDetails != nil {

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

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

	return nil
}

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

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