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

package computeoptimizer

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/service/computeoptimizer/schemas"
	"github.com/aws/aws-sdk-go-v2/service/computeoptimizer/types"
	smithy "github.com/aws/smithy-go"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

//	Returns Amazon ECS service recommendations.
//
// Compute Optimizer generates recommendations for Amazon ECS services on Fargate
// that meet a specific set of requirements. For more information, see the [Supported resources and requirements]in the
// Compute Optimizer User Guide.
//
// [Supported resources and requirements]: https://docs.aws.amazon.com/compute-optimizer/latest/ug/requirements.html
func (c *Client) GetECSServiceRecommendations(ctx context.Context, params *GetECSServiceRecommendationsInput, optFns ...func(*Options)) (*GetECSServiceRecommendationsOutput, error) {
	if params == nil {
		params = &GetECSServiceRecommendationsInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "GetECSServiceRecommendations", params, optFns, c.addOperationGetECSServiceRecommendationsMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*GetECSServiceRecommendationsOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type GetECSServiceRecommendationsInput struct {

	//  Return the Amazon ECS service recommendations to the specified Amazon Web
	// Services account IDs.
	//
	// If your account is the management account or the delegated administrator of an
	// organization, use this parameter to return the Amazon ECS service
	// recommendations to specific member accounts.
	//
	// You can only specify one account ID per request.
	AccountIds []string

	//  An array of objects to specify a filter that returns a more specific list of
	// Amazon ECS service recommendations.
	Filters []types.ECSServiceRecommendationFilter

	//  The maximum number of Amazon ECS service recommendations to return with a
	// single request.
	//
	// To retrieve the remaining results, make another request with the returned
	// nextToken value.
	MaxResults *int32

	//  The token to advance to the next page of Amazon ECS service recommendations.
	NextToken *string

	//  The ARN that identifies the Amazon ECS service.
	//
	// The following is the format of the ARN:
	//
	//     arn:aws:ecs:region:aws_account_id:service/cluster-name/service-name
	ServiceArns []string

	noSmithyDocumentSerde
}

func (v *GetECSServiceRecommendationsInput) Serialize(s smithy.ShapeSerializer) {
	s.WriteStruct(schemas.GetECSServiceRecommendationsRequest)
	v.SerializeMembers(s)
	s.CloseStruct()
}

func (v *GetECSServiceRecommendationsInput) SerializeMembers(s smithy.ShapeSerializer) {
	serializeAccountIds(s, schemas.GetECSServiceRecommendationsRequest_accountIds, v.AccountIds)
	serializeECSServiceRecommendationFilters(s, schemas.GetECSServiceRecommendationsRequest_filters, v.Filters)
	if v.MaxResults != nil {
		s.WriteInt32(schemas.GetECSServiceRecommendationsRequest_maxResults, *v.MaxResults)
	}
	if v.NextToken != nil {
		s.WriteString(schemas.GetECSServiceRecommendationsRequest_nextToken, *v.NextToken)
	}
	serializeServiceArns(s, schemas.GetECSServiceRecommendationsRequest_serviceArns, v.ServiceArns)
}

type GetECSServiceRecommendationsOutput struct {

	//  An array of objects that describe the Amazon ECS service recommendations.
	EcsServiceRecommendations []types.ECSServiceRecommendation

	//  An array of objects that describe errors of the request.
	Errors []types.GetRecommendationError

	//  The token to advance to the next page of Amazon ECS service recommendations.
	NextToken *string

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (v *GetECSServiceRecommendationsOutput) Serialize(s smithy.ShapeSerializer) {
	s.WriteStruct(schemas.GetECSServiceRecommendationsResponse)
	v.SerializeMembers(s)
	s.CloseStruct()
}

func (v *GetECSServiceRecommendationsOutput) SerializeMembers(s smithy.ShapeSerializer) {
	serializeECSServiceRecommendations(s, schemas.GetECSServiceRecommendationsResponse_ecsServiceRecommendations, v.EcsServiceRecommendations)
	serializeGetRecommendationErrors(s, schemas.GetECSServiceRecommendationsResponse_errors, v.Errors)
	if v.NextToken != nil {
		s.WriteString(schemas.GetECSServiceRecommendationsResponse_nextToken, *v.NextToken)
	}
}
func (v *GetECSServiceRecommendationsOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.GetECSServiceRecommendationsResponse, func(s *smithy.Schema) error {
		switch s {
		case schemas.GetECSServiceRecommendationsResponse_ecsServiceRecommendations:
			return deserializeECSServiceRecommendations(d, schemas.GetECSServiceRecommendationsResponse_ecsServiceRecommendations, &v.EcsServiceRecommendations)
		case schemas.GetECSServiceRecommendationsResponse_errors:
			return deserializeGetRecommendationErrors(d, schemas.GetECSServiceRecommendationsResponse_errors, &v.Errors)
		case schemas.GetECSServiceRecommendationsResponse_nextToken:
			v.NextToken = new(string)
			return d.ReadString(schemas.GetECSServiceRecommendationsResponse_nextToken, v.NextToken)
		}
		return nil
	})
}
func (c *Client) addOperationGetECSServiceRecommendationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.GetECSServiceRecommendations, schemas.GetECSServiceRecommendationsRequest, schemas.GetECSServiceRecommendationsResponse)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.GetECSServiceRecommendations, schemas.GetECSServiceRecommendationsRequest, schemas.GetECSServiceRecommendationsResponse), output: &GetECSServiceRecommendationsOutput{}}, middleware.After); err != nil {
		return err
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack, options); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addUserAgentFeatureProtocolRPCV2CBOR(stack, options); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetECSServiceRecommendations"), middleware.Before); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
