// Code generated by smithy-go-codegen DO NOT EDIT.

package costoptimizationhub

import (
	"context"
	"fmt"
	"github.com/aws/aws-sdk-go-v2/service/costoptimizationhub/types"
	smithy "github.com/aws/smithy-go"
	"github.com/aws/smithy-go/middleware"
)

type validateOpGetRecommendation struct {
}

func (*validateOpGetRecommendation) ID() string {
	return "OperationInputValidation"
}

func (m *validateOpGetRecommendation) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
	input, ok := in.Parameters.(*GetRecommendationInput)
	if !ok {
		return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters)
	}
	if err := validateOpGetRecommendationInput(input); err != nil {
		return out, metadata, err
	}
	return next.HandleInitialize(ctx, in)
}

type validateOpListEfficiencyMetrics struct {
}

func (*validateOpListEfficiencyMetrics) ID() string {
	return "OperationInputValidation"
}

func (m *validateOpListEfficiencyMetrics) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
	input, ok := in.Parameters.(*ListEfficiencyMetricsInput)
	if !ok {
		return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters)
	}
	if err := validateOpListEfficiencyMetricsInput(input); err != nil {
		return out, metadata, err
	}
	return next.HandleInitialize(ctx, in)
}

type validateOpListRecommendationSummaries struct {
}

func (*validateOpListRecommendationSummaries) ID() string {
	return "OperationInputValidation"
}

func (m *validateOpListRecommendationSummaries) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
	input, ok := in.Parameters.(*ListRecommendationSummariesInput)
	if !ok {
		return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters)
	}
	if err := validateOpListRecommendationSummariesInput(input); err != nil {
		return out, metadata, err
	}
	return next.HandleInitialize(ctx, in)
}

type validateOpUpdateEnrollmentStatus struct {
}

func (*validateOpUpdateEnrollmentStatus) ID() string {
	return "OperationInputValidation"
}

func (m *validateOpUpdateEnrollmentStatus) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
) {
	input, ok := in.Parameters.(*UpdateEnrollmentStatusInput)
	if !ok {
		return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters)
	}
	if err := validateOpUpdateEnrollmentStatusInput(input); err != nil {
		return out, metadata, err
	}
	return next.HandleInitialize(ctx, in)
}

func addOpGetRecommendationValidationMiddleware(stack *middleware.Stack) error {
	return stack.Initialize.Add(&validateOpGetRecommendation{}, middleware.After)
}

func addOpListEfficiencyMetricsValidationMiddleware(stack *middleware.Stack) error {
	return stack.Initialize.Add(&validateOpListEfficiencyMetrics{}, middleware.After)
}

func addOpListRecommendationSummariesValidationMiddleware(stack *middleware.Stack) error {
	return stack.Initialize.Add(&validateOpListRecommendationSummaries{}, middleware.After)
}

func addOpUpdateEnrollmentStatusValidationMiddleware(stack *middleware.Stack) error {
	return stack.Initialize.Add(&validateOpUpdateEnrollmentStatus{}, middleware.After)
}

func validateTimePeriod(v *types.TimePeriod) error {
	if v == nil {
		return nil
	}
	invalidParams := smithy.InvalidParamsError{Context: "TimePeriod"}
	if v.Start == nil {
		invalidParams.Add(smithy.NewErrParamRequired("Start"))
	}
	if v.End == nil {
		invalidParams.Add(smithy.NewErrParamRequired("End"))
	}
	if invalidParams.Len() > 0 {
		return invalidParams
	} else {
		return nil
	}
}

func validateOpGetRecommendationInput(v *GetRecommendationInput) error {
	if v == nil {
		return nil
	}
	invalidParams := smithy.InvalidParamsError{Context: "GetRecommendationInput"}
	if v.RecommendationId == nil {
		invalidParams.Add(smithy.NewErrParamRequired("RecommendationId"))
	}
	if invalidParams.Len() > 0 {
		return invalidParams
	} else {
		return nil
	}
}

func validateOpListEfficiencyMetricsInput(v *ListEfficiencyMetricsInput) error {
	if v == nil {
		return nil
	}
	invalidParams := smithy.InvalidParamsError{Context: "ListEfficiencyMetricsInput"}
	if len(v.Granularity) == 0 {
		invalidParams.Add(smithy.NewErrParamRequired("Granularity"))
	}
	if v.TimePeriod == nil {
		invalidParams.Add(smithy.NewErrParamRequired("TimePeriod"))
	} else if v.TimePeriod != nil {
		if err := validateTimePeriod(v.TimePeriod); err != nil {
			invalidParams.AddNested("TimePeriod", err.(smithy.InvalidParamsError))
		}
	}
	if invalidParams.Len() > 0 {
		return invalidParams
	} else {
		return nil
	}
}

func validateOpListRecommendationSummariesInput(v *ListRecommendationSummariesInput) error {
	if v == nil {
		return nil
	}
	invalidParams := smithy.InvalidParamsError{Context: "ListRecommendationSummariesInput"}
	if v.GroupBy == nil {
		invalidParams.Add(smithy.NewErrParamRequired("GroupBy"))
	}
	if invalidParams.Len() > 0 {
		return invalidParams
	} else {
		return nil
	}
}

func validateOpUpdateEnrollmentStatusInput(v *UpdateEnrollmentStatusInput) error {
	if v == nil {
		return nil
	}
	invalidParams := smithy.InvalidParamsError{Context: "UpdateEnrollmentStatusInput"}
	if len(v.Status) == 0 {
		invalidParams.Add(smithy.NewErrParamRequired("Status"))
	}
	if invalidParams.Len() > 0 {
		return invalidParams
	} else {
		return nil
	}
}
