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

package signin

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

// Grants permission to revoke an OAuth 2.0 refresh token and its associated
// refresh tokens
//
// Revokes a refresh_token issued by AWS Sign-In, invalidating the entire token
// chain so that the refresh_token can no longer be used to mint new access_tokens.
//
// Idempotency: revoking an already-revoked, expired, or otherwise invalid token
// still returns 200 OK with an empty body. Only the refresh_token type is
// accepted.
func (c *Client) RevokeOAuth2TokenWithIAM(ctx context.Context, params *RevokeOAuth2TokenWithIAMInput, optFns ...func(*Options)) (*RevokeOAuth2TokenWithIAMOutput, error) {
	if params == nil {
		params = &RevokeOAuth2TokenWithIAMInput{}
	}

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

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

// Input structure for RevokeOAuth2TokenWithIAM operation
//
// RFC 7009 §2.1 revocation request. Contains the refresh_token to revoke.
type RevokeOAuth2TokenWithIAMInput struct {

	// The refresh_token to revoke. Must be a refresh_token issued by AWS Sign-In
	// (prefix "ASOR"); access_tokens are not accepted for revocation.
	//
	// This member is required.
	Token *string

	noSmithyDocumentSerde
}

func (in *RevokeOAuth2TokenWithIAMInput) bindEndpointParams(p *EndpointParameters) {

	p.IsOAuthEndpoint = ptr.Bool(true)
}

// Output structure for RevokeOAuth2TokenWithIAM operation
//
// RFC 7009 §2.2 revocation response. The endpoint returns 200 OK with an empty
// body on success; there are no response fields.
type RevokeOAuth2TokenWithIAMOutput struct {
	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationRevokeOAuth2TokenWithIAMMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsRestjson1_serializeOpRevokeOAuth2TokenWithIAM{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpRevokeOAuth2TokenWithIAM{}, 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, 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 = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpRevokeOAuth2TokenWithIAMValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "RevokeOAuth2TokenWithIAM"), 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
}
