1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package mturk
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/mturk/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// The CreateHITWithHITType operation creates a new Human Intelligence Task (HIT)
15// using an existing HITTypeID generated by the CreateHITType operation. This is an
16// alternative way to create HITs from the CreateHIT operation. This is the
17// recommended best practice for Requesters who are creating large numbers of HITs.
18// CreateHITWithHITType also supports several ways to provide question data: by
19// providing a value for the Question parameter that fully specifies the contents
20// of the HIT, or by providing a HitLayoutId and associated HitLayoutParameters. If
21// a HIT is created with 10 or more maximum assignments, there is an additional
22// fee. For more information, see Amazon Mechanical Turk Pricing
23// (https://requester.mturk.com/pricing).
24func (c *Client) CreateHITWithHITType(ctx context.Context, params *CreateHITWithHITTypeInput, optFns ...func(*Options)) (*CreateHITWithHITTypeOutput, error) {
25	if params == nil {
26		params = &CreateHITWithHITTypeInput{}
27	}
28
29	result, metadata, err := c.invokeOperation(ctx, "CreateHITWithHITType", params, optFns, addOperationCreateHITWithHITTypeMiddlewares)
30	if err != nil {
31		return nil, err
32	}
33
34	out := result.(*CreateHITWithHITTypeOutput)
35	out.ResultMetadata = metadata
36	return out, nil
37}
38
39type CreateHITWithHITTypeInput struct {
40
41	// The HIT type ID you want to create this HIT with.
42	//
43	// This member is required.
44	HITTypeId *string
45
46	// An amount of time, in seconds, after which the HIT is no longer available for
47	// users to accept. After the lifetime of the HIT elapses, the HIT no longer
48	// appears in HIT searches, even if not all of the assignments for the HIT have
49	// been accepted.
50	//
51	// This member is required.
52	LifetimeInSeconds *int64
53
54	// The Assignment-level Review Policy applies to the assignments under the HIT. You
55	// can specify for Mechanical Turk to take various actions based on the policy.
56	AssignmentReviewPolicy *types.ReviewPolicy
57
58	// The HITLayoutId allows you to use a pre-existing HIT design with placeholder
59	// values and create an additional HIT by providing those values as
60	// HITLayoutParameters. Constraints: Either a Question parameter or a HITLayoutId
61	// parameter must be provided.
62	HITLayoutId *string
63
64	// If the HITLayoutId is provided, any placeholder values must be filled in with
65	// values using the HITLayoutParameter structure. For more information, see
66	// HITLayout.
67	HITLayoutParameters []types.HITLayoutParameter
68
69	// The HIT-level Review Policy applies to the HIT. You can specify for Mechanical
70	// Turk to take various actions based on the policy.
71	HITReviewPolicy *types.ReviewPolicy
72
73	// The number of times the HIT can be accepted and completed before the HIT becomes
74	// unavailable.
75	MaxAssignments *int32
76
77	// The data the person completing the HIT uses to produce the results. Constraints:
78	// Must be a QuestionForm data structure, an ExternalQuestion data structure, or an
79	// HTMLQuestion data structure. The XML question data must not be larger than 64
80	// kilobytes (65,535 bytes) in size, including whitespace. Either a Question
81	// parameter or a HITLayoutId parameter must be provided.
82	Question *string
83
84	// An arbitrary data field. The RequesterAnnotation parameter lets your application
85	// attach arbitrary data to the HIT for tracking purposes. For example, this
86	// parameter could be an identifier internal to the Requester's application that
87	// corresponds with the HIT. The RequesterAnnotation parameter for a HIT is only
88	// visible to the Requester who created the HIT. It is not shown to the Worker, or
89	// any other Requester. The RequesterAnnotation parameter may be different for each
90	// HIT you submit. It does not affect how your HITs are grouped.
91	RequesterAnnotation *string
92
93	// A unique identifier for this request which allows you to retry the call on error
94	// without creating duplicate HITs. This is useful in cases such as network
95	// timeouts where it is unclear whether or not the call succeeded on the server. If
96	// the HIT already exists in the system from a previous call using the same
97	// UniqueRequestToken, subsequent calls will return a
98	// AWS.MechanicalTurk.HitAlreadyExists error with a message containing the HITId.
99	// Note: It is your responsibility to ensure uniqueness of the token. The unique
100	// token expires after 24 hours. Subsequent calls using the same UniqueRequestToken
101	// made after the 24 hour limit could create duplicate HITs.
102	UniqueRequestToken *string
103}
104
105type CreateHITWithHITTypeOutput struct {
106
107	// Contains the newly created HIT data. For a description of the HIT data structure
108	// as it appears in responses, see the HIT Data Structure documentation.
109	HIT *types.HIT
110
111	// Metadata pertaining to the operation's result.
112	ResultMetadata middleware.Metadata
113}
114
115func addOperationCreateHITWithHITTypeMiddlewares(stack *middleware.Stack, options Options) (err error) {
116	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateHITWithHITType{}, middleware.After)
117	if err != nil {
118		return err
119	}
120	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateHITWithHITType{}, middleware.After)
121	if err != nil {
122		return err
123	}
124	if err = addSetLoggerMiddleware(stack, options); err != nil {
125		return err
126	}
127	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
128		return err
129	}
130	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
131		return err
132	}
133	if err = addResolveEndpointMiddleware(stack, options); err != nil {
134		return err
135	}
136	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
137		return err
138	}
139	if err = addRetryMiddlewares(stack, options); err != nil {
140		return err
141	}
142	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
143		return err
144	}
145	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
146		return err
147	}
148	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
149		return err
150	}
151	if err = addClientUserAgent(stack); err != nil {
152		return err
153	}
154	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
155		return err
156	}
157	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
158		return err
159	}
160	if err = addOpCreateHITWithHITTypeValidationMiddleware(stack); err != nil {
161		return err
162	}
163	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateHITWithHITType(options.Region), middleware.Before); err != nil {
164		return err
165	}
166	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
167		return err
168	}
169	if err = addResponseErrorMiddleware(stack); err != nil {
170		return err
171	}
172	if err = addRequestResponseLogging(stack, options); err != nil {
173		return err
174	}
175	return nil
176}
177
178func newServiceMetadataMiddleware_opCreateHITWithHITType(region string) *awsmiddleware.RegisterServiceMetadata {
179	return &awsmiddleware.RegisterServiceMetadata{
180		Region:        region,
181		ServiceID:     ServiceID,
182		SigningName:   "mturk-requester",
183		OperationName: "CreateHITWithHITType",
184	}
185}
186