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// Records a WorkflowExecutionTerminated event and forces closure of the workflow
15// execution identified by the given domain, runId, and workflowId. The child
16// policy, registered with the workflow type or specified when starting this
17// execution, is applied to any open child workflow executions of this workflow
18// execution. If the identified workflow execution was in progress, it is
19// terminated immediately. If a runId isn't specified, then the
20// WorkflowExecutionTerminated event is recorded in the history of the current open
21// workflow with the matching workflowId in the domain. You should consider using
22// RequestCancelWorkflowExecution action instead because it allows the workflow to
23// gracefully close while TerminateWorkflowExecution doesn't. Access Control You
24// can use IAM policies to control this action's access to Amazon SWF resources as
25// follows:
26//
27// * Use a Resource element with the domain name to limit the action to
28// only specified domains.
29//
30// * Use an Action element to allow or deny permission to
31// call this action.
32//
33// * You cannot use an IAM policy to constrain this action's
34// parameters.
35//
36// If the caller doesn't have sufficient permissions to invoke the
37// action, or the parameter values fall outside the specified constraints, the
38// action fails. The associated event attribute's cause parameter is set to
39// OPERATION_NOT_PERMITTED. For details and example IAM policies, see Using IAM to
40// Manage Access to Amazon SWF Workflows
41// (https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dev-iam.html)
42// in the Amazon SWF Developer Guide.
43func (c *Client) TerminateWorkflowExecution(ctx context.Context, params *TerminateWorkflowExecutionInput, optFns ...func(*Options)) (*TerminateWorkflowExecutionOutput, error) {
44	if params == nil {
45		params = &TerminateWorkflowExecutionInput{}
46	}
47
48	result, metadata, err := c.invokeOperation(ctx, "TerminateWorkflowExecution", params, optFns, addOperationTerminateWorkflowExecutionMiddlewares)
49	if err != nil {
50		return nil, err
51	}
52
53	out := result.(*TerminateWorkflowExecutionOutput)
54	out.ResultMetadata = metadata
55	return out, nil
56}
57
58type TerminateWorkflowExecutionInput struct {
59
60	// The domain of the workflow execution to terminate.
61	//
62	// This member is required.
63	Domain *string
64
65	// The workflowId of the workflow execution to terminate.
66	//
67	// This member is required.
68	WorkflowId *string
69
70	// If set, specifies the policy to use for the child workflow executions of the
71	// workflow execution being terminated. This policy overrides the child policy
72	// specified for the workflow execution at registration time or when starting the
73	// execution. The supported child policies are:
74	//
75	// * TERMINATE – The child executions
76	// are terminated.
77	//
78	// * REQUEST_CANCEL – A request to cancel is attempted for each
79	// child execution by recording a WorkflowExecutionCancelRequested event in its
80	// history. It is up to the decider to take appropriate actions when it receives an
81	// execution history with this event.
82	//
83	// * ABANDON – No action is taken. The child
84	// executions continue to run.
85	//
86	// A child policy for this workflow execution must be
87	// specified either as a default for the workflow type or through this parameter.
88	// If neither this parameter is set nor a default child policy was specified at
89	// registration time then a fault is returned.
90	ChildPolicy types.ChildPolicy
91
92	// Details for terminating the workflow execution.
93	Details *string
94
95	// A descriptive reason for terminating the workflow execution.
96	Reason *string
97
98	// The runId of the workflow execution to terminate.
99	RunId *string
100}
101
102type TerminateWorkflowExecutionOutput struct {
103	// Metadata pertaining to the operation's result.
104	ResultMetadata middleware.Metadata
105}
106
107func addOperationTerminateWorkflowExecutionMiddlewares(stack *middleware.Stack, options Options) (err error) {
108	err = stack.Serialize.Add(&awsAwsjson10_serializeOpTerminateWorkflowExecution{}, middleware.After)
109	if err != nil {
110		return err
111	}
112	err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpTerminateWorkflowExecution{}, middleware.After)
113	if err != nil {
114		return err
115	}
116	if err = addSetLoggerMiddleware(stack, options); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
120		return err
121	}
122	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
123		return err
124	}
125	if err = addResolveEndpointMiddleware(stack, options); err != nil {
126		return err
127	}
128	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
129		return err
130	}
131	if err = addRetryMiddlewares(stack, options); err != nil {
132		return err
133	}
134	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
135		return err
136	}
137	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
138		return err
139	}
140	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
141		return err
142	}
143	if err = addClientUserAgent(stack); err != nil {
144		return err
145	}
146	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
147		return err
148	}
149	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
150		return err
151	}
152	if err = addOpTerminateWorkflowExecutionValidationMiddleware(stack); err != nil {
153		return err
154	}
155	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opTerminateWorkflowExecution(options.Region), middleware.Before); err != nil {
156		return err
157	}
158	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
159		return err
160	}
161	if err = addResponseErrorMiddleware(stack); err != nil {
162		return err
163	}
164	if err = addRequestResponseLogging(stack, options); err != nil {
165		return err
166	}
167	return nil
168}
169
170func newServiceMetadataMiddleware_opTerminateWorkflowExecution(region string) *awsmiddleware.RegisterServiceMetadata {
171	return &awsmiddleware.RegisterServiceMetadata{
172		Region:        region,
173		ServiceID:     ServiceID,
174		SigningName:   "swf",
175		OperationName: "TerminateWorkflowExecution",
176	}
177}
178