api_op_Logout.go raw

   1  // Code generated by smithy-go-codegen DO NOT EDIT.
   2  
   3  package sso
   4  
   5  import (
   6  	"context"
   7  	"fmt"
   8  	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
   9  	"github.com/aws/smithy-go/middleware"
  10  	smithyhttp "github.com/aws/smithy-go/transport/http"
  11  )
  12  
  13  // Removes the locally stored SSO tokens from the client-side cache and sends an
  14  // API call to the IAM Identity Center service to invalidate the corresponding
  15  // server-side IAM Identity Center sign in session.
  16  //
  17  // If a user uses IAM Identity Center to access the AWS CLI, the user’s IAM
  18  // Identity Center sign in session is used to obtain an IAM session, as specified
  19  // in the corresponding IAM Identity Center permission set. More specifically, IAM
  20  // Identity Center assumes an IAM role in the target account on behalf of the user,
  21  // and the corresponding temporary AWS credentials are returned to the client.
  22  //
  23  // After user logout, any existing IAM role sessions that were created by using
  24  // IAM Identity Center permission sets continue based on the duration configured in
  25  // the permission set. For more information, see [User authentications]in the IAM Identity Center User
  26  // Guide.
  27  //
  28  // [User authentications]: https://docs.aws.amazon.com/singlesignon/latest/userguide/authconcept.html
  29  func (c *Client) Logout(ctx context.Context, params *LogoutInput, optFns ...func(*Options)) (*LogoutOutput, error) {
  30  	if params == nil {
  31  		params = &LogoutInput{}
  32  	}
  33  
  34  	result, metadata, err := c.invokeOperation(ctx, "Logout", params, optFns, c.addOperationLogoutMiddlewares)
  35  	if err != nil {
  36  		return nil, err
  37  	}
  38  
  39  	out := result.(*LogoutOutput)
  40  	out.ResultMetadata = metadata
  41  	return out, nil
  42  }
  43  
  44  type LogoutInput struct {
  45  
  46  	// The token issued by the CreateToken API call. For more information, see [CreateToken] in the
  47  	// IAM Identity Center OIDC API Reference Guide.
  48  	//
  49  	// [CreateToken]: https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html
  50  	//
  51  	// This member is required.
  52  	AccessToken *string
  53  
  54  	noSmithyDocumentSerde
  55  }
  56  
  57  type LogoutOutput struct {
  58  	// Metadata pertaining to the operation's result.
  59  	ResultMetadata middleware.Metadata
  60  
  61  	noSmithyDocumentSerde
  62  }
  63  
  64  func (c *Client) addOperationLogoutMiddlewares(stack *middleware.Stack, options Options) (err error) {
  65  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  66  		return err
  67  	}
  68  	err = stack.Serialize.Add(&awsRestjson1_serializeOpLogout{}, middleware.After)
  69  	if err != nil {
  70  		return err
  71  	}
  72  	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpLogout{}, middleware.After)
  73  	if err != nil {
  74  		return err
  75  	}
  76  	if err := addProtocolFinalizerMiddlewares(stack, options, "Logout"); err != nil {
  77  		return fmt.Errorf("add protocol finalizers: %v", err)
  78  	}
  79  
  80  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  81  		return err
  82  	}
  83  	if err = addSetLoggerMiddleware(stack, options); err != nil {
  84  		return err
  85  	}
  86  	if err = addClientRequestID(stack); err != nil {
  87  		return err
  88  	}
  89  	if err = addComputeContentLength(stack); err != nil {
  90  		return err
  91  	}
  92  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
  93  		return err
  94  	}
  95  	if err = addRetry(stack, options); err != nil {
  96  		return err
  97  	}
  98  	if err = addRawResponseToMetadata(stack); err != nil {
  99  		return err
 100  	}
 101  	if err = addRecordResponseTiming(stack); err != nil {
 102  		return err
 103  	}
 104  	if err = addSpanRetryLoop(stack, options); err != nil {
 105  		return err
 106  	}
 107  	if err = addClientUserAgent(stack, options); err != nil {
 108  		return err
 109  	}
 110  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 111  		return err
 112  	}
 113  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 114  		return err
 115  	}
 116  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 117  		return err
 118  	}
 119  	if err = addTimeOffsetBuild(stack, c); err != nil {
 120  		return err
 121  	}
 122  	if err = addUserAgentRetryMode(stack, options); err != nil {
 123  		return err
 124  	}
 125  	if err = addCredentialSource(stack, options); err != nil {
 126  		return err
 127  	}
 128  	if err = addOpLogoutValidationMiddleware(stack); err != nil {
 129  		return err
 130  	}
 131  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opLogout(options.Region), middleware.Before); err != nil {
 132  		return err
 133  	}
 134  	if err = addRecursionDetection(stack); err != nil {
 135  		return err
 136  	}
 137  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 138  		return err
 139  	}
 140  	if err = addResponseErrorMiddleware(stack); err != nil {
 141  		return err
 142  	}
 143  	if err = addRequestResponseLogging(stack, options); err != nil {
 144  		return err
 145  	}
 146  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 147  		return err
 148  	}
 149  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 150  		return err
 151  	}
 152  	if err = addInterceptAttempt(stack, options); err != nil {
 153  		return err
 154  	}
 155  	if err = addInterceptors(stack, options); err != nil {
 156  		return err
 157  	}
 158  	return nil
 159  }
 160  
 161  func newServiceMetadataMiddleware_opLogout(region string) *awsmiddleware.RegisterServiceMetadata {
 162  	return &awsmiddleware.RegisterServiceMetadata{
 163  		Region:        region,
 164  		ServiceID:     ServiceID,
 165  		OperationName: "Logout",
 166  	}
 167  }
 168