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