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

// Secrets20230613HcpTerraformConnectionDetailsResponse secrets 20230613 hcp terraform connection details response
//
// swagger:model secrets_20230613HcpTerraformConnectionDetailsResponse
type Secrets20230613HcpTerraformConnectionDetailsResponse struct {

	// category
	Category *Secrets20230613HcpTerraformCategory `json:"category,omitempty"`

	// hcl
	Hcl bool `json:"hcl,omitempty"`

	// installation name
	InstallationName string `json:"installation_name,omitempty"`

	// type
	Type *Secrets20230613HcpTerraformType `json:"type,omitempty"`

	// variable set id
	VariableSetID string `json:"variable_set_id,omitempty"`

	// variable set name
	VariableSetName string `json:"variable_set_name,omitempty"`

	// workspace id
	WorkspaceID string `json:"workspace_id,omitempty"`

	// workspace name
	WorkspaceName string `json:"workspace_name,omitempty"`
}

// Validate validates this secrets 20230613 hcp terraform connection details response
func (m *Secrets20230613HcpTerraformConnectionDetailsResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *Secrets20230613HcpTerraformConnectionDetailsResponse) validateCategory(formats strfmt.Registry) error {
	if swag.IsZero(m.Category) { // not required
		return nil
	}

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

	return nil
}

func (m *Secrets20230613HcpTerraformConnectionDetailsResponse) validateType(formats strfmt.Registry) error {
	if swag.IsZero(m.Type) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this secrets 20230613 hcp terraform connection details response based on the context it is used
func (m *Secrets20230613HcpTerraformConnectionDetailsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

func (m *Secrets20230613HcpTerraformConnectionDetailsResponse) contextValidateCategory(ctx context.Context, formats strfmt.Registry) error {

	if m.Category != nil {

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

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

	return nil
}

func (m *Secrets20230613HcpTerraformConnectionDetailsResponse) contextValidateType(ctx context.Context, formats strfmt.Registry) error {

	if m.Type != nil {

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

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

	return nil
}

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

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