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

// HashicorpCloudWaypointV20241122GetActionConfigResponse hashicorp cloud waypoint v20241122 get action config response
//
// swagger:model hashicorp.cloud.waypoint.v20241122.GetActionConfigResponse
type HashicorpCloudWaypointV20241122GetActionConfigResponse struct {

	// The current requested action config
	ActionConfig *HashicorpCloudWaypointV20241122ActionConfig `json:"action_config,omitempty"`

	// The latest run for this config. A nil ActionRun means there are not yet any runs
	LatestRun *HashicorpCloudWaypointV20241122ActionRun `json:"latest_run,omitempty"`

	// The total number of runs (overall) for this config
	TotalRuns *HashicorpCloudWaypointV20241122GetActionConfigResponseTotalRuns `json:"total_runs,omitempty"`
}

// Validate validates this hashicorp cloud waypoint v20241122 get action config response
func (m *HashicorpCloudWaypointV20241122GetActionConfigResponse) Validate(formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudWaypointV20241122GetActionConfigResponse) validateActionConfig(formats strfmt.Registry) error {
	if swag.IsZero(m.ActionConfig) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122GetActionConfigResponse) validateLatestRun(formats strfmt.Registry) error {
	if swag.IsZero(m.LatestRun) { // not required
		return nil
	}

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122GetActionConfigResponse) validateTotalRuns(formats strfmt.Registry) error {
	if swag.IsZero(m.TotalRuns) { // not required
		return nil
	}

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

	return nil
}

// ContextValidate validate this hashicorp cloud waypoint v20241122 get action config response based on the context it is used
func (m *HashicorpCloudWaypointV20241122GetActionConfigResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

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

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

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

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

func (m *HashicorpCloudWaypointV20241122GetActionConfigResponse) contextValidateActionConfig(ctx context.Context, formats strfmt.Registry) error {

	if m.ActionConfig != nil {

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

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122GetActionConfigResponse) contextValidateLatestRun(ctx context.Context, formats strfmt.Registry) error {

	if m.LatestRun != nil {

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

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

	return nil
}

func (m *HashicorpCloudWaypointV20241122GetActionConfigResponse) contextValidateTotalRuns(ctx context.Context, formats strfmt.Registry) error {

	if m.TotalRuns != nil {

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

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

	return nil
}

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

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