1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package organizations 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/aws-sdk-go-v2/service/organizations/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists the current handshakes that are associated with the account of the 16// requesting user. Handshakes that are ACCEPTED, DECLINED, or CANCELED appear in 17// the results of this API for only 30 days after changing to that state. After 18// that, they're deleted and no longer accessible. Always check the NextToken 19// response parameter for a null value when calling a List* operation. These 20// operations can occasionally return an empty set of results even when there are 21// more results available. The NextToken response parameter value is null only when 22// there are no more results to display. This operation can be called from any 23// account in the organization. 24func (c *Client) ListHandshakesForAccount(ctx context.Context, params *ListHandshakesForAccountInput, optFns ...func(*Options)) (*ListHandshakesForAccountOutput, error) { 25 if params == nil { 26 params = &ListHandshakesForAccountInput{} 27 } 28 29 result, metadata, err := c.invokeOperation(ctx, "ListHandshakesForAccount", params, optFns, addOperationListHandshakesForAccountMiddlewares) 30 if err != nil { 31 return nil, err 32 } 33 34 out := result.(*ListHandshakesForAccountOutput) 35 out.ResultMetadata = metadata 36 return out, nil 37} 38 39type ListHandshakesForAccountInput struct { 40 41 // Filters the handshakes that you want included in the response. The default is 42 // all types. Use the ActionType element to limit the output to only a specified 43 // type, such as INVITE, ENABLE_ALL_FEATURES, or APPROVE_ALL_FEATURES. 44 // Alternatively, for the ENABLE_ALL_FEATURES handshake that generates a separate 45 // child handshake for each member account, you can specify ParentHandshakeId to 46 // see only the handshakes that were generated by that parent request. 47 Filter *types.HandshakeFilter 48 49 // The total number of results that you want included on each page of the response. 50 // If you do not include this parameter, it defaults to a value that is specific to 51 // the operation. If additional items exist beyond the maximum you specify, the 52 // NextToken response element is present and has a value (is not null). Include 53 // that value as the NextToken request parameter in the next call to the operation 54 // to get the next part of the results. Note that Organizations might return fewer 55 // results than the maximum even when there are more results available. You should 56 // check NextToken after every operation to ensure that you receive all of the 57 // results. 58 MaxResults *int32 59 60 // The parameter for receiving additional results if you receive a NextToken 61 // response in a previous request. A NextToken response indicates that more output 62 // is available. Set this parameter to the value of the previous call's NextToken 63 // response to indicate where the output should continue from. 64 NextToken *string 65} 66 67type ListHandshakesForAccountOutput struct { 68 69 // A list of Handshake objects with details about each of the handshakes that is 70 // associated with the specified account. 71 Handshakes []types.Handshake 72 73 // If present, indicates that more output is available than is included in the 74 // current response. Use this value in the NextToken request parameter in a 75 // subsequent call to the operation to get the next part of the output. You should 76 // repeat this until the NextToken response element comes back as null. 77 NextToken *string 78 79 // Metadata pertaining to the operation's result. 80 ResultMetadata middleware.Metadata 81} 82 83func addOperationListHandshakesForAccountMiddlewares(stack *middleware.Stack, options Options) (err error) { 84 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListHandshakesForAccount{}, middleware.After) 85 if err != nil { 86 return err 87 } 88 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListHandshakesForAccount{}, middleware.After) 89 if err != nil { 90 return err 91 } 92 if err = addSetLoggerMiddleware(stack, options); err != nil { 93 return err 94 } 95 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 96 return err 97 } 98 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 99 return err 100 } 101 if err = addResolveEndpointMiddleware(stack, options); err != nil { 102 return err 103 } 104 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 105 return err 106 } 107 if err = addRetryMiddlewares(stack, options); err != nil { 108 return err 109 } 110 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 111 return err 112 } 113 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 114 return err 115 } 116 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 117 return err 118 } 119 if err = addClientUserAgent(stack); err != nil { 120 return err 121 } 122 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 123 return err 124 } 125 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 126 return err 127 } 128 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListHandshakesForAccount(options.Region), middleware.Before); err != nil { 129 return err 130 } 131 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 132 return err 133 } 134 if err = addResponseErrorMiddleware(stack); err != nil { 135 return err 136 } 137 if err = addRequestResponseLogging(stack, options); err != nil { 138 return err 139 } 140 return nil 141} 142 143// ListHandshakesForAccountAPIClient is a client that implements the 144// ListHandshakesForAccount operation. 145type ListHandshakesForAccountAPIClient interface { 146 ListHandshakesForAccount(context.Context, *ListHandshakesForAccountInput, ...func(*Options)) (*ListHandshakesForAccountOutput, error) 147} 148 149var _ ListHandshakesForAccountAPIClient = (*Client)(nil) 150 151// ListHandshakesForAccountPaginatorOptions is the paginator options for 152// ListHandshakesForAccount 153type ListHandshakesForAccountPaginatorOptions struct { 154 // The total number of results that you want included on each page of the response. 155 // If you do not include this parameter, it defaults to a value that is specific to 156 // the operation. If additional items exist beyond the maximum you specify, the 157 // NextToken response element is present and has a value (is not null). Include 158 // that value as the NextToken request parameter in the next call to the operation 159 // to get the next part of the results. Note that Organizations might return fewer 160 // results than the maximum even when there are more results available. You should 161 // check NextToken after every operation to ensure that you receive all of the 162 // results. 163 Limit int32 164 165 // Set to true if pagination should stop if the service returns a pagination token 166 // that matches the most recent token provided to the service. 167 StopOnDuplicateToken bool 168} 169 170// ListHandshakesForAccountPaginator is a paginator for ListHandshakesForAccount 171type ListHandshakesForAccountPaginator struct { 172 options ListHandshakesForAccountPaginatorOptions 173 client ListHandshakesForAccountAPIClient 174 params *ListHandshakesForAccountInput 175 nextToken *string 176 firstPage bool 177} 178 179// NewListHandshakesForAccountPaginator returns a new 180// ListHandshakesForAccountPaginator 181func NewListHandshakesForAccountPaginator(client ListHandshakesForAccountAPIClient, params *ListHandshakesForAccountInput, optFns ...func(*ListHandshakesForAccountPaginatorOptions)) *ListHandshakesForAccountPaginator { 182 options := ListHandshakesForAccountPaginatorOptions{} 183 if params.MaxResults != nil { 184 options.Limit = *params.MaxResults 185 } 186 187 for _, fn := range optFns { 188 fn(&options) 189 } 190 191 if params == nil { 192 params = &ListHandshakesForAccountInput{} 193 } 194 195 return &ListHandshakesForAccountPaginator{ 196 options: options, 197 client: client, 198 params: params, 199 firstPage: true, 200 } 201} 202 203// HasMorePages returns a boolean indicating whether more pages are available 204func (p *ListHandshakesForAccountPaginator) HasMorePages() bool { 205 return p.firstPage || p.nextToken != nil 206} 207 208// NextPage retrieves the next ListHandshakesForAccount page. 209func (p *ListHandshakesForAccountPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListHandshakesForAccountOutput, error) { 210 if !p.HasMorePages() { 211 return nil, fmt.Errorf("no more pages available") 212 } 213 214 params := *p.params 215 params.NextToken = p.nextToken 216 217 var limit *int32 218 if p.options.Limit > 0 { 219 limit = &p.options.Limit 220 } 221 params.MaxResults = limit 222 223 result, err := p.client.ListHandshakesForAccount(ctx, ¶ms, optFns...) 224 if err != nil { 225 return nil, err 226 } 227 p.firstPage = false 228 229 prevToken := p.nextToken 230 p.nextToken = result.NextToken 231 232 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 233 p.nextToken = nil 234 } 235 236 return result, nil 237} 238 239func newServiceMetadataMiddleware_opListHandshakesForAccount(region string) *awsmiddleware.RegisterServiceMetadata { 240 return &awsmiddleware.RegisterServiceMetadata{ 241 Region: region, 242 ServiceID: ServiceID, 243 SigningName: "organizations", 244 OperationName: "ListHandshakesForAccount", 245 } 246} 247