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

// Rejects a delegation request, denying the requested temporary access.
//
// Once a request is rejected, it cannot be accepted or updated later. Rejected
// requests expire after 7 days.
//
// When rejecting a request, an optional explanation can be added using the Notes
// request parameter.
//
// 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) RejectDelegationRequest(ctx context.Context, params *RejectDelegationRequestInput, optFns ...func(*Options)) (*RejectDelegationRequestOutput, error) {
	if params == nil {
		params = &RejectDelegationRequestInput{}
	}

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

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

type RejectDelegationRequestInput struct {

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

	// Optional notes explaining the reason for rejecting the delegation request.
	Notes *string

	noSmithyDocumentSerde
}

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

	noSmithyDocumentSerde
}

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