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

package cloudfront

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

// Update an Amazon CloudFront VPC origin in your account.
func (c *Client) UpdateVpcOrigin(ctx context.Context, params *UpdateVpcOriginInput, optFns ...func(*Options)) (*UpdateVpcOriginOutput, error) {
	if params == nil {
		params = &UpdateVpcOriginInput{}
	}

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

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

type UpdateVpcOriginInput struct {

	// The VPC origin ID.
	//
	// This member is required.
	Id *string

	// The VPC origin to update, if a match occurs.
	//
	// This member is required.
	IfMatch *string

	// The VPC origin endpoint configuration.
	//
	// This member is required.
	VpcOriginEndpointConfig *types.VpcOriginEndpointConfig

	noSmithyDocumentSerde
}

type UpdateVpcOriginOutput struct {

	// The VPC origin ETag.
	ETag *string

	// The VPC origin.
	VpcOrigin *types.VpcOrigin

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

	noSmithyDocumentSerde
}

func (c *Client) addOperationUpdateVpcOriginMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsRestxml_serializeOpUpdateVpcOrigin{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestxml_deserializeOpUpdateVpcOrigin{}, middleware.After)
	if 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); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpUpdateVpcOriginValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateVpcOrigin"), 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
}
