File: api_op_TestState.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.24.1-2~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 554,032 kB
  • sloc: java: 15,941; makefile: 419; sh: 175
file content (252 lines) | stat: -rw-r--r-- 9,999 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// Code generated by smithy-go-codegen DO NOT EDIT.

package sfn

import (
	"context"
	"fmt"
	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
	"github.com/aws/aws-sdk-go-v2/service/sfn/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Accepts the definition of a single state and executes it. You can test a state
// without creating a state machine or updating an existing state machine. Using
// this API, you can test the following:
//   - A state's input and output processing (https://docs.aws.amazon.com/step-functions/latest/dg/test-state-isolation.html#test-state-input-output-dataflow)
//     data flow
//   - An Amazon Web Services service integration (https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-services.html)
//     request and response
//   - An HTTP Task (https://docs.aws.amazon.com/step-functions/latest/dg/connect-third-party-apis.html)
//     request and response
//
// You can call this API on only one state at a time. The states that you can test
// include the following:
//   - All Task types (https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-task-state.html#task-types)
//     except Activity (https://docs.aws.amazon.com/step-functions/latest/dg/concepts-activities.html)
//   - Pass (https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-pass-state.html)
//   - Wait (https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-wait-state.html)
//   - Choice (https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-choice-state.html)
//   - Succeed (https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-succeed-state.html)
//   - Fail (https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-fail-state.html)
//
// The TestState API assumes an IAM role which must contain the required IAM
// permissions for the resources your state is accessing. For information about the
// permissions a state might need, see IAM permissions to test a state (https://docs.aws.amazon.com/step-functions/latest/dg/test-state-isolation.html#test-state-permissions)
// . The TestState API can run for up to five minutes. If the execution of a state
// exceeds this duration, it fails with the States.Timeout error. TestState
// doesn't support Activity tasks (https://docs.aws.amazon.com/step-functions/latest/dg/concepts-activities.html)
// , .sync or .waitForTaskToken service integration patterns (https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html)
// , Parallel (https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-parallel-state.html)
// , or Map (https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-map-state.html)
// states.
func (c *Client) TestState(ctx context.Context, params *TestStateInput, optFns ...func(*Options)) (*TestStateOutput, error) {
	if params == nil {
		params = &TestStateInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "TestState", params, optFns, c.addOperationTestStateMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*TestStateOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type TestStateInput struct {

	// The Amazon States Language (https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html)
	// (ASL) definition of the state.
	//
	// This member is required.
	Definition *string

	// The Amazon Resource Name (ARN) of the execution role with the required IAM
	// permissions for the state.
	//
	// This member is required.
	RoleArn *string

	// A string that contains the JSON input data for the state.
	Input *string

	// Determines the values to return when a state is tested. You can specify one of
	// the following types:
	//   - INFO : Shows the final state output. By default, Step Functions sets
	//   inspectionLevel to INFO if you don't specify a level.
	//   - DEBUG : Shows the final state output along with the input and output data
	//   processing result.
	//   - TRACE : Shows the HTTP request and response for an HTTP Task. This level
	//   also shows the final state output along with the input and output data
	//   processing result.
	// Each of these levels also provide information about the status of the state
	// execution and the next state to transition to.
	InspectionLevel types.InspectionLevel

	// Specifies whether or not to include secret information in the test result. For
	// HTTP Tasks, a secret includes the data that an EventBridge connection adds to
	// modify the HTTP request headers, query parameters, and body. Step Functions
	// doesn't omit any information included in the state definition or the HTTP
	// response. If you set revealSecrets to true , you must make sure that the IAM
	// user that calls the TestState API has permission for the states:RevealSecrets
	// action. For an example of IAM policy that sets the states:RevealSecrets
	// permission, see IAM permissions to test a state (https://docs.aws.amazon.com/step-functions/latest/dg/test-state-isolation.html#test-state-permissions)
	// . Without this permission, Step Functions throws an access denied error. By
	// default, revealSecrets is set to false .
	RevealSecrets bool

	noSmithyDocumentSerde
}

type TestStateOutput struct {

	// A detailed explanation of the cause for the error when the execution of a state
	// fails.
	Cause *string

	// The error returned when the execution of a state fails.
	Error *string

	// Returns additional details about the state's execution, including its input and
	// output data processing flow, and HTTP request and response information. The
	// inspectionLevel request parameter specifies which details are returned.
	InspectionData *types.InspectionData

	// The name of the next state to transition to. If you haven't defined a next
	// state in your definition or if the execution of the state fails, this field
	// doesn't contain a value.
	NextState *string

	// The JSON output data of the state. Length constraints apply to the payload
	// size, and are expressed as bytes in UTF-8 encoding.
	Output *string

	// The execution status of the state.
	Status types.TestExecutionStatus

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationTestStateMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
		return err
	}
	err = stack.Serialize.Add(&awsAwsjson10_serializeOpTestState{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson10_deserializeOpTestState{}, middleware.After)
	if err != nil {
		return err
	}
	if err := addProtocolFinalizerMiddlewares(stack, options, "TestState"); err != nil {
		return fmt.Errorf("add protocol finalizers: %v", err)
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addSetLoggerMiddleware(stack, options); err != nil {
		return err
	}
	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
		return err
	}
	if err = addRetryMiddlewares(stack, options); err != nil {
		return err
	}
	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
		return err
	}
	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = addClientUserAgent(stack, options); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
		return err
	}
	if err = addEndpointPrefix_opTestStateMiddleware(stack); err != nil {
		return err
	}
	if err = addOpTestStateValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opTestState(options.Region), middleware.Before); err != nil {
		return err
	}
	if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	return nil
}

type endpointPrefix_opTestStateMiddleware struct {
}

func (*endpointPrefix_opTestStateMiddleware) ID() string {
	return "EndpointHostPrefix"
}

func (m *endpointPrefix_opTestStateMiddleware) HandleFinalize(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (
	out middleware.FinalizeOutput, metadata middleware.Metadata, err error,
) {
	if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) {
		return next.HandleFinalize(ctx, in)
	}

	req, ok := in.Request.(*smithyhttp.Request)
	if !ok {
		return out, metadata, fmt.Errorf("unknown transport type %T", in.Request)
	}

	req.URL.Host = "sync-" + req.URL.Host

	return next.HandleFinalize(ctx, in)
}
func addEndpointPrefix_opTestStateMiddleware(stack *middleware.Stack) error {
	return stack.Finalize.Insert(&endpointPrefix_opTestStateMiddleware{}, "ResolveEndpointV2", middleware.After)
}

func newServiceMetadataMiddleware_opTestState(region string) *awsmiddleware.RegisterServiceMetadata {
	return &awsmiddleware.RegisterServiceMetadata{
		Region:        region,
		ServiceID:     ServiceID,
		OperationName: "TestState",
	}
}