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// Starts an execution of the workflow type in the specified domain using the
15// provided workflowId and input data. This action returns the newly started
16// workflow execution. Access Control You can use IAM policies to control this
17// action's access to Amazon SWF resources as follows:
18//
19// * Use a Resource element
20// with the domain name to limit the action to only specified domains.
21//
22// * Use an
23// Action element to allow or deny permission to call this action.
24//
25// * Constrain the
26// following parameters by using a Condition element with the appropriate keys.
27//
28// *
29// tagList.member.0: The key is swf:tagList.member.0.
30//
31// * tagList.member.1: The key
32// is swf:tagList.member.1.
33//
34// * tagList.member.2: The key is
35// swf:tagList.member.2.
36//
37// * tagList.member.3: The key is swf:tagList.member.3.
38//
39// *
40// tagList.member.4: The key is swf:tagList.member.4.
41//
42// * taskList: String
43// constraint. The key is swf:taskList.name.
44//
45// * workflowType.name: String
46// constraint. The key is swf:workflowType.name.
47//
48// * workflowType.version: String
49// constraint. The key is swf:workflowType.version.
50//
51// If the caller doesn't have
52// sufficient permissions to invoke the action, or the parameter values fall
53// outside the specified constraints, the action fails. The associated event
54// attribute's cause parameter is set to OPERATION_NOT_PERMITTED. For details and
55// example IAM policies, see Using IAM to Manage Access to Amazon SWF Workflows
56// (https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html)
57// in the Amazon SWF Developer Guide.
58func (c *Client) StartWorkflowExecution(ctx context.Context, params *StartWorkflowExecutionInput, optFns ...func(*Options)) (*StartWorkflowExecutionOutput, error) {
59	if params == nil {
60		params = &StartWorkflowExecutionInput{}
61	}
62
63	result, metadata, err := c.invokeOperation(ctx, "StartWorkflowExecution", params, optFns, addOperationStartWorkflowExecutionMiddlewares)
64	if err != nil {
65		return nil, err
66	}
67
68	out := result.(*StartWorkflowExecutionOutput)
69	out.ResultMetadata = metadata
70	return out, nil
71}
72
73type StartWorkflowExecutionInput struct {
74
75	// The name of the domain in which the workflow execution is created.
76	//
77	// This member is required.
78	Domain *string
79
80	// The user defined identifier associated with the workflow execution. You can use
81	// this to associate a custom identifier with the workflow execution. You may
82	// specify the same identifier if a workflow execution is logically a restart of a
83	// previous execution. You cannot have two open workflow executions with the same
84	// workflowId at the same time within the same domain. The specified string must
85	// not start or end with whitespace. It must not contain a : (colon), / (slash), |
86	// (vertical bar), or any control characters (\u0000-\u001f | \u007f-\u009f). Also,
87	// it must not be the literal string arn.
88	//
89	// This member is required.
90	WorkflowId *string
91
92	// The type of the workflow to start.
93	//
94	// This member is required.
95	WorkflowType *types.WorkflowType
96
97	// If set, specifies the policy to use for the child workflow executions of this
98	// workflow execution if it is terminated, by calling the
99	// TerminateWorkflowExecution action explicitly or due to an expired timeout. This
100	// policy overrides the default child policy specified when registering the
101	// workflow type using RegisterWorkflowType. The supported child policies are:
102	//
103	// *
104	// TERMINATE – The child executions are terminated.
105	//
106	// * REQUEST_CANCEL – A request
107	// to cancel is attempted for each child execution by recording a
108	// WorkflowExecutionCancelRequested event in its history. It is up to the decider
109	// to take appropriate actions when it receives an execution history with this
110	// event.
111	//
112	// * ABANDON – No action is taken. The child executions continue to run.
113	//
114	// A
115	// child policy for this workflow execution must be specified either as a default
116	// for the workflow type or through this parameter. If neither this parameter is
117	// set nor a default child policy was specified at registration time then a fault
118	// is returned.
119	ChildPolicy types.ChildPolicy
120
121	// The total duration for this workflow execution. This overrides the
122	// defaultExecutionStartToCloseTimeout specified when registering the workflow
123	// type. The duration is specified in seconds; an integer greater than or equal to
124	// 0. Exceeding this limit causes the workflow execution to time out. Unlike some
125	// of the other timeout parameters in Amazon SWF, you cannot specify a value of
126	// "NONE" for this timeout; there is a one-year max limit on the time that a
127	// workflow execution can run. An execution start-to-close timeout must be
128	// specified either through this parameter or as a default when the workflow type
129	// is registered. If neither this parameter nor a default execution start-to-close
130	// timeout is specified, a fault is returned.
131	ExecutionStartToCloseTimeout *string
132
133	// The input for the workflow execution. This is a free form string which should be
134	// meaningful to the workflow you are starting. This input is made available to the
135	// new workflow execution in the WorkflowExecutionStarted history event.
136	Input *string
137
138	// The IAM role to attach to this workflow execution. Executions of this workflow
139	// type need IAM roles to invoke Lambda functions. If you don't attach an IAM role,
140	// any attempt to schedule a Lambda task fails. This results in a
141	// ScheduleLambdaFunctionFailed history event. For more information, see
142	// https://docs.aws.amazon.com/amazonswf/latest/developerguide/lambda-task.html
143	// (https://docs.aws.amazon.com/amazonswf/latest/developerguide/lambda-task.html)
144	// in the Amazon SWF Developer Guide.
145	LambdaRole *string
146
147	// The list of tags to associate with the workflow execution. You can specify a
148	// maximum of 5 tags. You can list workflow executions with a specific tag by
149	// calling ListOpenWorkflowExecutions or ListClosedWorkflowExecutions and
150	// specifying a TagFilter.
151	TagList []string
152
153	// The task list to use for the decision tasks generated for this workflow
154	// execution. This overrides the defaultTaskList specified when registering the
155	// workflow type. A task list for this workflow execution must be specified either
156	// as a default for the workflow type or through this parameter. If neither this
157	// parameter is set nor a default task list was specified at registration time then
158	// a fault is returned. The specified string must not start or end with whitespace.
159	// It must not contain a : (colon), / (slash), | (vertical bar), or any control
160	// characters (\u0000-\u001f | \u007f-\u009f). Also, it must not be the literal
161	// string arn.
162	TaskList *types.TaskList
163
164	// The task priority to use for this workflow execution. This overrides any default
165	// priority that was assigned when the workflow type was registered. If not set,
166	// then the default task priority for the workflow type is used. Valid values are
167	// integers that range from Java's Integer.MIN_VALUE (-2147483648) to
168	// Integer.MAX_VALUE (2147483647). Higher numbers indicate higher priority. For
169	// more information about setting task priority, see Setting Task Priority
170	// (https://docs.aws.amazon.com/amazonswf/latest/developerguide/programming-priority.html)
171	// in the Amazon SWF Developer Guide.
172	TaskPriority *string
173
174	// Specifies the maximum duration of decision tasks for this workflow execution.
175	// This parameter overrides the defaultTaskStartToCloseTimout specified when
176	// registering the workflow type using RegisterWorkflowType. The duration is
177	// specified in seconds, an integer greater than or equal to 0. You can use NONE to
178	// specify unlimited duration. A task start-to-close timeout for this workflow
179	// execution must be specified either as a default for the workflow type or through
180	// this parameter. If neither this parameter is set nor a default task
181	// start-to-close timeout was specified at registration time then a fault is
182	// returned.
183	TaskStartToCloseTimeout *string
184}
185
186// Specifies the runId of a workflow execution.
187type StartWorkflowExecutionOutput struct {
188
189	// The runId of a workflow execution. This ID is generated by the service and can
190	// be used to uniquely identify the workflow execution within a domain.
191	RunId *string
192
193	// Metadata pertaining to the operation's result.
194	ResultMetadata middleware.Metadata
195}
196
197func addOperationStartWorkflowExecutionMiddlewares(stack *middleware.Stack, options Options) (err error) {
198	err = stack.Serialize.Add(&awsAwsjson10_serializeOpStartWorkflowExecution{}, middleware.After)
199	if err != nil {
200		return err
201	}
202	err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpStartWorkflowExecution{}, middleware.After)
203	if err != nil {
204		return err
205	}
206	if err = addSetLoggerMiddleware(stack, options); err != nil {
207		return err
208	}
209	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
210		return err
211	}
212	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
213		return err
214	}
215	if err = addResolveEndpointMiddleware(stack, options); err != nil {
216		return err
217	}
218	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
219		return err
220	}
221	if err = addRetryMiddlewares(stack, options); err != nil {
222		return err
223	}
224	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
225		return err
226	}
227	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
228		return err
229	}
230	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
231		return err
232	}
233	if err = addClientUserAgent(stack); err != nil {
234		return err
235	}
236	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
237		return err
238	}
239	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
240		return err
241	}
242	if err = addOpStartWorkflowExecutionValidationMiddleware(stack); err != nil {
243		return err
244	}
245	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartWorkflowExecution(options.Region), middleware.Before); err != nil {
246		return err
247	}
248	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
249		return err
250	}
251	if err = addResponseErrorMiddleware(stack); err != nil {
252		return err
253	}
254	if err = addRequestResponseLogging(stack, options); err != nil {
255		return err
256	}
257	return nil
258}
259
260func newServiceMetadataMiddleware_opStartWorkflowExecution(region string) *awsmiddleware.RegisterServiceMetadata {
261	return &awsmiddleware.RegisterServiceMetadata{
262		Region:        region,
263		ServiceID:     ServiceID,
264		SigningName:   "swf",
265		OperationName: "StartWorkflowExecution",
266	}
267}
268