1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package swf 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/swf/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Returns a list of closed workflow executions in the specified domain that meet 16// the filtering criteria. The results may be split into multiple pages. To 17// retrieve subsequent pages, make the call again using the nextPageToken returned 18// by the initial call. This operation is eventually consistent. The results are 19// best effort and may not exactly reflect recent updates and changes. Access 20// Control You can use IAM policies to control this action's access to Amazon SWF 21// resources as follows: 22// 23// * Use a Resource element with the domain name to limit 24// the action to only specified domains. 25// 26// * Use an Action element to allow or deny 27// permission to call this action. 28// 29// * Constrain the following parameters by using a 30// Condition element with the appropriate keys. 31// 32// * tagFilter.tag: String 33// constraint. The key is swf:tagFilter.tag. 34// 35// * typeFilter.name: String constraint. 36// The key is swf:typeFilter.name. 37// 38// * typeFilter.version: String constraint. The 39// key is swf:typeFilter.version. 40// 41// If the caller doesn't have sufficient 42// permissions to invoke the action, or the parameter values fall outside the 43// specified constraints, the action fails. The associated event attribute's cause 44// parameter is set to OPERATION_NOT_PERMITTED. For details and example IAM 45// policies, see Using IAM to Manage Access to Amazon SWF Workflows 46// (https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html) 47// in the Amazon SWF Developer Guide. 48func (c *Client) ListClosedWorkflowExecutions(ctx context.Context, params *ListClosedWorkflowExecutionsInput, optFns ...func(*Options)) (*ListClosedWorkflowExecutionsOutput, error) { 49 if params == nil { 50 params = &ListClosedWorkflowExecutionsInput{} 51 } 52 53 result, metadata, err := c.invokeOperation(ctx, "ListClosedWorkflowExecutions", params, optFns, c.addOperationListClosedWorkflowExecutionsMiddlewares) 54 if err != nil { 55 return nil, err 56 } 57 58 out := result.(*ListClosedWorkflowExecutionsOutput) 59 out.ResultMetadata = metadata 60 return out, nil 61} 62 63type ListClosedWorkflowExecutionsInput struct { 64 65 // The name of the domain that contains the workflow executions to list. 66 // 67 // This member is required. 68 Domain *string 69 70 // If specified, only workflow executions that match this close status are listed. 71 // For example, if TERMINATED is specified, then only TERMINATED workflow 72 // executions are listed. closeStatusFilter, executionFilter, typeFilter and 73 // tagFilter are mutually exclusive. You can specify at most one of these in a 74 // request. 75 CloseStatusFilter *types.CloseStatusFilter 76 77 // If specified, the workflow executions are included in the returned results based 78 // on whether their close times are within the range specified by this filter. 79 // Also, if this parameter is specified, the returned results are ordered by their 80 // close times. startTimeFilter and closeTimeFilter are mutually exclusive. You 81 // must specify one of these in a request but not both. 82 CloseTimeFilter *types.ExecutionTimeFilter 83 84 // If specified, only workflow executions matching the workflow ID specified in the 85 // filter are returned. closeStatusFilter, executionFilter, typeFilter and 86 // tagFilter are mutually exclusive. You can specify at most one of these in a 87 // request. 88 ExecutionFilter *types.WorkflowExecutionFilter 89 90 // The maximum number of results that are returned per call. Use nextPageToken to 91 // obtain further pages of results. 92 MaximumPageSize int32 93 94 // If NextPageToken is returned there are more results available. The value of 95 // NextPageToken is a unique pagination token for each page. Make the call again 96 // using the returned token to retrieve the next page. Keep all other arguments 97 // unchanged. Each pagination token expires after 60 seconds. Using an expired 98 // pagination token will return a 400 error: "Specified token has exceeded its 99 // maximum lifetime". The configured maximumPageSize determines how many results 100 // can be returned in a single call. 101 NextPageToken *string 102 103 // When set to true, returns the results in reverse order. By default the results 104 // are returned in descending order of the start or the close time of the 105 // executions. 106 ReverseOrder bool 107 108 // If specified, the workflow executions are included in the returned results based 109 // on whether their start times are within the range specified by this filter. 110 // Also, if this parameter is specified, the returned results are ordered by their 111 // start times. startTimeFilter and closeTimeFilter are mutually exclusive. You 112 // must specify one of these in a request but not both. 113 StartTimeFilter *types.ExecutionTimeFilter 114 115 // If specified, only executions that have the matching tag are listed. 116 // closeStatusFilter, executionFilter, typeFilter and tagFilter are mutually 117 // exclusive. You can specify at most one of these in a request. 118 TagFilter *types.TagFilter 119 120 // If specified, only executions of the type specified in the filter are returned. 121 // closeStatusFilter, executionFilter, typeFilter and tagFilter are mutually 122 // exclusive. You can specify at most one of these in a request. 123 TypeFilter *types.WorkflowTypeFilter 124 125 noSmithyDocumentSerde 126} 127 128// Contains a paginated list of information about workflow executions. 129type ListClosedWorkflowExecutionsOutput struct { 130 131 // The list of workflow information structures. 132 // 133 // This member is required. 134 ExecutionInfos []types.WorkflowExecutionInfo 135 136 // If a NextPageToken was returned by a previous call, there are more results 137 // available. To retrieve the next page of results, make the call again using the 138 // returned token in nextPageToken. Keep all other arguments unchanged. The 139 // configured maximumPageSize determines how many results can be returned in a 140 // single call. 141 NextPageToken *string 142 143 // Metadata pertaining to the operation's result. 144 ResultMetadata middleware.Metadata 145 146 noSmithyDocumentSerde 147} 148 149func (c *Client) addOperationListClosedWorkflowExecutionsMiddlewares(stack *middleware.Stack, options Options) (err error) { 150 err = stack.Serialize.Add(&awsAwsjson10_serializeOpListClosedWorkflowExecutions{}, middleware.After) 151 if err != nil { 152 return err 153 } 154 err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpListClosedWorkflowExecutions{}, middleware.After) 155 if err != nil { 156 return err 157 } 158 if err = addSetLoggerMiddleware(stack, options); err != nil { 159 return err 160 } 161 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 162 return err 163 } 164 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 165 return err 166 } 167 if err = addResolveEndpointMiddleware(stack, options); err != nil { 168 return err 169 } 170 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 171 return err 172 } 173 if err = addRetryMiddlewares(stack, options); err != nil { 174 return err 175 } 176 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 177 return err 178 } 179 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 180 return err 181 } 182 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 183 return err 184 } 185 if err = addClientUserAgent(stack); err != nil { 186 return err 187 } 188 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 189 return err 190 } 191 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 192 return err 193 } 194 if err = addOpListClosedWorkflowExecutionsValidationMiddleware(stack); err != nil { 195 return err 196 } 197 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListClosedWorkflowExecutions(options.Region), middleware.Before); err != nil { 198 return err 199 } 200 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 201 return err 202 } 203 if err = addResponseErrorMiddleware(stack); err != nil { 204 return err 205 } 206 if err = addRequestResponseLogging(stack, options); err != nil { 207 return err 208 } 209 return nil 210} 211 212// ListClosedWorkflowExecutionsAPIClient is a client that implements the 213// ListClosedWorkflowExecutions operation. 214type ListClosedWorkflowExecutionsAPIClient interface { 215 ListClosedWorkflowExecutions(context.Context, *ListClosedWorkflowExecutionsInput, ...func(*Options)) (*ListClosedWorkflowExecutionsOutput, error) 216} 217 218var _ ListClosedWorkflowExecutionsAPIClient = (*Client)(nil) 219 220// ListClosedWorkflowExecutionsPaginatorOptions is the paginator options for 221// ListClosedWorkflowExecutions 222type ListClosedWorkflowExecutionsPaginatorOptions struct { 223 // The maximum number of results that are returned per call. Use nextPageToken to 224 // obtain further pages of results. 225 Limit int32 226 227 // Set to true if pagination should stop if the service returns a pagination token 228 // that matches the most recent token provided to the service. 229 StopOnDuplicateToken bool 230} 231 232// ListClosedWorkflowExecutionsPaginator is a paginator for 233// ListClosedWorkflowExecutions 234type ListClosedWorkflowExecutionsPaginator struct { 235 options ListClosedWorkflowExecutionsPaginatorOptions 236 client ListClosedWorkflowExecutionsAPIClient 237 params *ListClosedWorkflowExecutionsInput 238 nextToken *string 239 firstPage bool 240} 241 242// NewListClosedWorkflowExecutionsPaginator returns a new 243// ListClosedWorkflowExecutionsPaginator 244func NewListClosedWorkflowExecutionsPaginator(client ListClosedWorkflowExecutionsAPIClient, params *ListClosedWorkflowExecutionsInput, optFns ...func(*ListClosedWorkflowExecutionsPaginatorOptions)) *ListClosedWorkflowExecutionsPaginator { 245 if params == nil { 246 params = &ListClosedWorkflowExecutionsInput{} 247 } 248 249 options := ListClosedWorkflowExecutionsPaginatorOptions{} 250 if params.MaximumPageSize != 0 { 251 options.Limit = params.MaximumPageSize 252 } 253 254 for _, fn := range optFns { 255 fn(&options) 256 } 257 258 return &ListClosedWorkflowExecutionsPaginator{ 259 options: options, 260 client: client, 261 params: params, 262 firstPage: true, 263 } 264} 265 266// HasMorePages returns a boolean indicating whether more pages are available 267func (p *ListClosedWorkflowExecutionsPaginator) HasMorePages() bool { 268 return p.firstPage || p.nextToken != nil 269} 270 271// NextPage retrieves the next ListClosedWorkflowExecutions page. 272func (p *ListClosedWorkflowExecutionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListClosedWorkflowExecutionsOutput, error) { 273 if !p.HasMorePages() { 274 return nil, fmt.Errorf("no more pages available") 275 } 276 277 params := *p.params 278 params.NextPageToken = p.nextToken 279 280 params.MaximumPageSize = p.options.Limit 281 282 result, err := p.client.ListClosedWorkflowExecutions(ctx, ¶ms, optFns...) 283 if err != nil { 284 return nil, err 285 } 286 p.firstPage = false 287 288 prevToken := p.nextToken 289 p.nextToken = result.NextPageToken 290 291 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 292 p.nextToken = nil 293 } 294 295 return result, nil 296} 297 298func newServiceMetadataMiddleware_opListClosedWorkflowExecutions(region string) *awsmiddleware.RegisterServiceMetadata { 299 return &awsmiddleware.RegisterServiceMetadata{ 300 Region: region, 301 ServiceID: ServiceID, 302 SigningName: "swf", 303 OperationName: "ListClosedWorkflowExecutions", 304 } 305} 306