1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package swf
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/swf/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Returns the number of open workflow executions within the given domain that meet
15// the specified filtering criteria. This operation is eventually consistent. The
16// results are best effort and may not exactly reflect recent updates and changes.
17// Access Control You can use IAM policies to control this action's access to
18// Amazon SWF resources as follows:
19//
20// * Use a Resource element with the domain name
21// to limit the action to only specified domains.
22//
23// * Use an Action element to allow
24// or deny permission to call this action.
25//
26// * Constrain the following parameters by
27// using a Condition element with the appropriate keys.
28//
29// * tagFilter.tag: String
30// constraint. The key is swf:tagFilter.tag.
31//
32// * typeFilter.name: String constraint.
33// The key is swf:typeFilter.name.
34//
35// * typeFilter.version: String constraint. The
36// key is swf:typeFilter.version.
37//
38// If the caller doesn't have sufficient
39// permissions to invoke the action, or the parameter values fall outside the
40// specified constraints, the action fails. The associated event attribute's cause
41// parameter is set to OPERATION_NOT_PERMITTED. For details and example IAM
42// policies, see Using IAM to Manage Access to Amazon SWF Workflows
43// (https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html)
44// in the Amazon SWF Developer Guide.
45func (c *Client) CountOpenWorkflowExecutions(ctx context.Context, params *CountOpenWorkflowExecutionsInput, optFns ...func(*Options)) (*CountOpenWorkflowExecutionsOutput, error) {
46	if params == nil {
47		params = &CountOpenWorkflowExecutionsInput{}
48	}
49
50	result, metadata, err := c.invokeOperation(ctx, "CountOpenWorkflowExecutions", params, optFns, addOperationCountOpenWorkflowExecutionsMiddlewares)
51	if err != nil {
52		return nil, err
53	}
54
55	out := result.(*CountOpenWorkflowExecutionsOutput)
56	out.ResultMetadata = metadata
57	return out, nil
58}
59
60type CountOpenWorkflowExecutionsInput struct {
61
62	// The name of the domain containing the workflow executions to count.
63	//
64	// This member is required.
65	Domain *string
66
67	// Specifies the start time criteria that workflow executions must meet in order to
68	// be counted.
69	//
70	// This member is required.
71	StartTimeFilter *types.ExecutionTimeFilter
72
73	// If specified, only workflow executions matching the WorkflowId in the filter are
74	// counted. executionFilter, typeFilter and tagFilter are mutually exclusive. You
75	// can specify at most one of these in a request.
76	ExecutionFilter *types.WorkflowExecutionFilter
77
78	// If specified, only executions that have a tag that matches the filter are
79	// counted. executionFilter, typeFilter and tagFilter are mutually exclusive. You
80	// can specify at most one of these in a request.
81	TagFilter *types.TagFilter
82
83	// Specifies the type of the workflow executions to be counted. executionFilter,
84	// typeFilter and tagFilter are mutually exclusive. You can specify at most one of
85	// these in a request.
86	TypeFilter *types.WorkflowTypeFilter
87}
88
89// Contains the count of workflow executions returned from
90// CountOpenWorkflowExecutions or CountClosedWorkflowExecutions
91type CountOpenWorkflowExecutionsOutput struct {
92
93	// The number of workflow executions.
94	//
95	// This member is required.
96	Count int32
97
98	// If set to true, indicates that the actual count was more than the maximum
99	// supported by this API and the count returned is the truncated value.
100	Truncated bool
101
102	// Metadata pertaining to the operation's result.
103	ResultMetadata middleware.Metadata
104}
105
106func addOperationCountOpenWorkflowExecutionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
107	err = stack.Serialize.Add(&awsAwsjson10_serializeOpCountOpenWorkflowExecutions{}, middleware.After)
108	if err != nil {
109		return err
110	}
111	err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpCountOpenWorkflowExecutions{}, middleware.After)
112	if err != nil {
113		return err
114	}
115	if err = addSetLoggerMiddleware(stack, options); err != nil {
116		return err
117	}
118	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
119		return err
120	}
121	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
122		return err
123	}
124	if err = addResolveEndpointMiddleware(stack, options); err != nil {
125		return err
126	}
127	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
128		return err
129	}
130	if err = addRetryMiddlewares(stack, options); err != nil {
131		return err
132	}
133	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
134		return err
135	}
136	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
137		return err
138	}
139	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
140		return err
141	}
142	if err = addClientUserAgent(stack); err != nil {
143		return err
144	}
145	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
146		return err
147	}
148	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
149		return err
150	}
151	if err = addOpCountOpenWorkflowExecutionsValidationMiddleware(stack); err != nil {
152		return err
153	}
154	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCountOpenWorkflowExecutions(options.Region), middleware.Before); err != nil {
155		return err
156	}
157	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
158		return err
159	}
160	if err = addResponseErrorMiddleware(stack); err != nil {
161		return err
162	}
163	if err = addRequestResponseLogging(stack, options); err != nil {
164		return err
165	}
166	return nil
167}
168
169func newServiceMetadataMiddleware_opCountOpenWorkflowExecutions(region string) *awsmiddleware.RegisterServiceMetadata {
170	return &awsmiddleware.RegisterServiceMetadata{
171		Region:        region,
172		ServiceID:     ServiceID,
173		SigningName:   "swf",
174		OperationName: "CountOpenWorkflowExecutions",
175	}
176}
177