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

// Returns the projected utilization metrics of Amazon EC2 instance
// recommendations.
//
// The Cpu and Memory metrics are the only projected utilization metrics returned
// when you run this action. Additionally, the Memory metric is returned only for
// resources that have the unified CloudWatch agent installed on them. For more
// information, see [Enabling Memory Utilization with the CloudWatch Agent].
//
// [Enabling Memory Utilization with the CloudWatch Agent]: https://docs.aws.amazon.com/compute-optimizer/latest/ug/metrics.html#cw-agent
func (c *Client) GetEC2RecommendationProjectedMetrics(ctx context.Context, params *GetEC2RecommendationProjectedMetricsInput, optFns ...func(*Options)) (*GetEC2RecommendationProjectedMetricsOutput, error) {
	if params == nil {
		params = &GetEC2RecommendationProjectedMetricsInput{}
	}

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

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

type GetEC2RecommendationProjectedMetricsInput struct {

	// The timestamp of the last projected metrics data point to return.
	//
	// This member is required.
	EndTime *time.Time

	// The Amazon Resource Name (ARN) of the instances for which to return
	// recommendation projected metrics.
	//
	// This member is required.
	InstanceArn *string

	// The granularity, in seconds, of the projected metrics data points.
	//
	// This member is required.
	Period int32

	// The timestamp of the first projected metrics data point to return.
	//
	// This member is required.
	StartTime *time.Time

	// The statistic of the projected metrics.
	//
	// This member is required.
	Stat types.MetricStatistic

	// An object to specify the preferences for the Amazon EC2 recommendation
	// projected metrics to return in the response.
	RecommendationPreferences *types.RecommendationPreferences

	noSmithyDocumentSerde
}

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

func (v *GetEC2RecommendationProjectedMetricsInput) SerializeMembers(s smithy.ShapeSerializer) {
	if v.EndTime != nil {
		s.WriteTime(schemas.GetEC2RecommendationProjectedMetricsRequest_endTime, *v.EndTime)
	}
	if v.InstanceArn != nil {
		s.WriteString(schemas.GetEC2RecommendationProjectedMetricsRequest_instanceArn, *v.InstanceArn)
	}
	s.WriteInt32(schemas.GetEC2RecommendationProjectedMetricsRequest_period, v.Period)
	if v.RecommendationPreferences != nil {
		s.WriteStruct(schemas.GetEC2RecommendationProjectedMetricsRequest_recommendationPreferences)
		v.RecommendationPreferences.SerializeMembers(s)
		s.CloseStruct()
	}
	if v.StartTime != nil {
		s.WriteTime(schemas.GetEC2RecommendationProjectedMetricsRequest_startTime, *v.StartTime)
	}
	if v.Stat != "" {
		s.WriteString(schemas.GetEC2RecommendationProjectedMetricsRequest_stat, string(v.Stat))
	}
}

type GetEC2RecommendationProjectedMetricsOutput struct {

	// An array of objects that describes projected metrics.
	RecommendedOptionProjectedMetrics []types.RecommendedOptionProjectedMetric

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

	noSmithyDocumentSerde
}

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

func (v *GetEC2RecommendationProjectedMetricsOutput) SerializeMembers(s smithy.ShapeSerializer) {
	serializeRecommendedOptionProjectedMetrics(s, schemas.GetEC2RecommendationProjectedMetricsResponse_recommendedOptionProjectedMetrics, v.RecommendedOptionProjectedMetrics)
}
func (v *GetEC2RecommendationProjectedMetricsOutput) Deserialize(d smithy.ShapeDeserializer) error {
	return smithy.ReadStruct(d, schemas.GetEC2RecommendationProjectedMetricsResponse, func(s *smithy.Schema) error {
		switch s {
		case schemas.GetEC2RecommendationProjectedMetricsResponse_recommendedOptionProjectedMetrics:
			return deserializeRecommendedOptionProjectedMetrics(d, schemas.GetEC2RecommendationProjectedMetricsResponse_recommendedOptionProjectedMetrics, &v.RecommendedOptionProjectedMetrics)
		}
		return nil
	})
}
func (c *Client) addOperationGetEC2RecommendationProjectedMetricsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&serializeRequestMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.GetEC2RecommendationProjectedMetrics, schemas.GetEC2RecommendationProjectedMetricsRequest, schemas.GetEC2RecommendationProjectedMetricsResponse)}, middleware.After); err != nil {
		return err
	}
	if err := stack.Deserialize.Add(&deserializeResponseMiddleware{options: &options, operationSchema: smithy.NewOperationSchema(schemas.GetEC2RecommendationProjectedMetrics, schemas.GetEC2RecommendationProjectedMetricsRequest, schemas.GetEC2RecommendationProjectedMetricsResponse), output: &GetEC2RecommendationProjectedMetricsOutput{}}, 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 = addOpGetEC2RecommendationProjectedMetricsValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "GetEC2RecommendationProjectedMetrics"), 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
}
