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

package iam

import (
	"context"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Updates an existing delegation request with additional information. When the
// delegation request is updated, it reaches the PENDING_APPROVAL state.
//
// Once a delegation request has an owner, that owner gets a default permission to
// update the delegation request. For more details, see [Managing Permissions for Delegation Requests].
//
// [Managing Permissions for Delegation Requests]: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-temporary-delegation.html#temporary-delegation-managing-permissions
func (c *Client) UpdateDelegationRequest(ctx context.Context, params *UpdateDelegationRequestInput, optFns ...func(*Options)) (*UpdateDelegationRequestOutput, error) {
	if params == nil {
		params = &UpdateDelegationRequestInput{}
	}

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

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

type UpdateDelegationRequestInput struct {

	// The unique identifier of the delegation request to update.
	//
	// This member is required.
	DelegationRequestId *string

	// Additional notes or comments to add to the delegation request.
	Notes *string

	noSmithyDocumentSerde
}

type UpdateDelegationRequestOutput struct {
	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationUpdateDelegationRequestMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsAwsquery_serializeOpUpdateDelegationRequest{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpUpdateDelegationRequest{}, 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 = addOpUpdateDelegationRequestValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateDelegationRequest"), 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
}
