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

// Secrets20230613SyncInstallation secrets 20230613 sync installation
//
// swagger:model secrets_20230613SyncInstallation
type Secrets20230613SyncInstallation struct {

	// aws assume role
	AwsAssumeRole *Secrets20230613AwsAssumeRoleMetadata `json:"aws_assume_role,omitempty"`

	// gh app
	GhApp *Secrets20230613GhAppMetadata `json:"gh_app,omitempty"`

	// hcp terraform
	HcpTerraform *Secrets20230613HcpTerraformMetadata `json:"hcp_terraform,omitempty"`

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

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

	// vercel oauth
	VercelOauth *Secrets20230613VercelOAuthMetadata `json:"vercel_oauth,omitempty"`
}

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

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

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

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

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

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

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

func (m *Secrets20230613SyncInstallation) validateAwsAssumeRole(formats strfmt.Registry) error {
	if swag.IsZero(m.AwsAssumeRole) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613SyncInstallation) validateGhApp(formats strfmt.Registry) error {
	if swag.IsZero(m.GhApp) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613SyncInstallation) validateHcpTerraform(formats strfmt.Registry) error {
	if swag.IsZero(m.HcpTerraform) { // not required
		return nil
	}

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

	return nil
}

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

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

	return nil
}

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

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

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

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

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

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

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

func (m *Secrets20230613SyncInstallation) contextValidateAwsAssumeRole(ctx context.Context, formats strfmt.Registry) error {

	if m.AwsAssumeRole != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncInstallation) contextValidateGhApp(ctx context.Context, formats strfmt.Registry) error {

	if m.GhApp != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncInstallation) contextValidateHcpTerraform(ctx context.Context, formats strfmt.Registry) error {

	if m.HcpTerraform != nil {

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

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

	return nil
}

func (m *Secrets20230613SyncInstallation) 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 *Secrets20230613SyncInstallation) contextValidateVercelOauth(ctx context.Context, formats strfmt.Registry) error {

	if m.VercelOauth != nil {

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

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

	return nil
}

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

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