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 CreateHIT operation creates a new Human Intelligence Task (HIT). The new HIT
15// is made available for Workers to find and accept on the Amazon Mechanical Turk
16// website. This operation allows you to specify a new HIT by passing in values for
17// the properties of the HIT, such as its title, reward amount and number of
18// assignments. When you pass these values to CreateHIT, a new HIT is created for
19// you, with a new HITTypeID. The HITTypeID can be used to create additional HITs
20// in the future without needing to specify common parameters such as the title,
21// description and reward amount each time. An alternative way to create HITs is to
22// first generate a HITTypeID using the CreateHITType operation and then call the
23// CreateHITWithHITType operation. This is the recommended best practice for
24// Requesters who are creating large numbers of HITs. CreateHIT also supports
25// several ways to provide question data: by providing a value for the Question
26// parameter that fully specifies the contents of the HIT, or by providing a
27// HitLayoutId and associated HitLayoutParameters. If a HIT is created with 10 or
28// more maximum assignments, there is an additional fee. For more information, see
29// Amazon Mechanical Turk Pricing (https://requester.mturk.com/pricing).
30func (c *Client) CreateHIT(ctx context.Context, params *CreateHITInput, optFns ...func(*Options)) (*CreateHITOutput, error) {
31	if params == nil {
32		params = &CreateHITInput{}
33	}
34
35	result, metadata, err := c.invokeOperation(ctx, "CreateHIT", params, optFns, addOperationCreateHITMiddlewares)
36	if err != nil {
37		return nil, err
38	}
39
40	out := result.(*CreateHITOutput)
41	out.ResultMetadata = metadata
42	return out, nil
43}
44
45type CreateHITInput struct {
46
47	// The amount of time, in seconds, that a Worker has to complete the HIT after
48	// accepting it. If a Worker does not complete the assignment within the specified
49	// duration, the assignment is considered abandoned. If the HIT is still active
50	// (that is, its lifetime has not elapsed), the assignment becomes available for
51	// other users to find and accept.
52	//
53	// This member is required.
54	AssignmentDurationInSeconds *int64
55
56	// A general description of the HIT. A description includes detailed information
57	// about the kind of task the HIT contains. On the Amazon Mechanical Turk web site,
58	// the HIT description appears in the expanded view of search results, and in the
59	// HIT and assignment screens. A good description gives the user enough information
60	// to evaluate the HIT before accepting it.
61	//
62	// This member is required.
63	Description *string
64
65	// An amount of time, in seconds, after which the HIT is no longer available for
66	// users to accept. After the lifetime of the HIT elapses, the HIT no longer
67	// appears in HIT searches, even if not all of the assignments for the HIT have
68	// been accepted.
69	//
70	// This member is required.
71	LifetimeInSeconds *int64
72
73	// The amount of money the Requester will pay a Worker for successfully completing
74	// the HIT.
75	//
76	// This member is required.
77	Reward *string
78
79	// The title of the HIT. A title should be short and descriptive about the kind of
80	// task the HIT contains. On the Amazon Mechanical Turk web site, the HIT title
81	// appears in search results, and everywhere the HIT is mentioned.
82	//
83	// This member is required.
84	Title *string
85
86	// The Assignment-level Review Policy applies to the assignments under the HIT. You
87	// can specify for Mechanical Turk to take various actions based on the policy.
88	AssignmentReviewPolicy *types.ReviewPolicy
89
90	// The number of seconds after an assignment for the HIT has been submitted, after
91	// which the assignment is considered Approved automatically unless the Requester
92	// explicitly rejects it.
93	AutoApprovalDelayInSeconds *int64
94
95	// The HITLayoutId allows you to use a pre-existing HIT design with placeholder
96	// values and create an additional HIT by providing those values as
97	// HITLayoutParameters. Constraints: Either a Question parameter or a HITLayoutId
98	// parameter must be provided.
99	HITLayoutId *string
100
101	// If the HITLayoutId is provided, any placeholder values must be filled in with
102	// values using the HITLayoutParameter structure. For more information, see
103	// HITLayout.
104	HITLayoutParameters []types.HITLayoutParameter
105
106	// The HIT-level Review Policy applies to the HIT. You can specify for Mechanical
107	// Turk to take various actions based on the policy.
108	HITReviewPolicy *types.ReviewPolicy
109
110	// One or more words or phrases that describe the HIT, separated by commas. These
111	// words are used in searches to find HITs.
112	Keywords *string
113
114	// The number of times the HIT can be accepted and completed before the HIT becomes
115	// unavailable.
116	MaxAssignments *int32
117
118	// Conditions that a Worker's Qualifications must meet in order to accept the HIT.
119	// A HIT can have between zero and ten Qualification requirements. All requirements
120	// must be met in order for a Worker to accept the HIT. Additionally, other actions
121	// can be restricted using the ActionsGuarded field on each
122	// QualificationRequirement structure.
123	QualificationRequirements []types.QualificationRequirement
124
125	// The data the person completing the HIT uses to produce the results. Constraints:
126	// Must be a QuestionForm data structure, an ExternalQuestion data structure, or an
127	// HTMLQuestion data structure. The XML question data must not be larger than 64
128	// kilobytes (65,535 bytes) in size, including whitespace. Either a Question
129	// parameter or a HITLayoutId parameter must be provided.
130	Question *string
131
132	// An arbitrary data field. The RequesterAnnotation parameter lets your application
133	// attach arbitrary data to the HIT for tracking purposes. For example, this
134	// parameter could be an identifier internal to the Requester's application that
135	// corresponds with the HIT. The RequesterAnnotation parameter for a HIT is only
136	// visible to the Requester who created the HIT. It is not shown to the Worker, or
137	// any other Requester. The RequesterAnnotation parameter may be different for each
138	// HIT you submit. It does not affect how your HITs are grouped.
139	RequesterAnnotation *string
140
141	// A unique identifier for this request which allows you to retry the call on error
142	// without creating duplicate HITs. This is useful in cases such as network
143	// timeouts where it is unclear whether or not the call succeeded on the server. If
144	// the HIT already exists in the system from a previous call using the same
145	// UniqueRequestToken, subsequent calls will return a
146	// AWS.MechanicalTurk.HitAlreadyExists error with a message containing the HITId.
147	// Note: It is your responsibility to ensure uniqueness of the token. The unique
148	// token expires after 24 hours. Subsequent calls using the same UniqueRequestToken
149	// made after the 24 hour limit could create duplicate HITs.
150	UniqueRequestToken *string
151}
152
153type CreateHITOutput struct {
154
155	// Contains the newly created HIT data. For a description of the HIT data structure
156	// as it appears in responses, see the HIT Data Structure documentation.
157	HIT *types.HIT
158
159	// Metadata pertaining to the operation's result.
160	ResultMetadata middleware.Metadata
161}
162
163func addOperationCreateHITMiddlewares(stack *middleware.Stack, options Options) (err error) {
164	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateHIT{}, middleware.After)
165	if err != nil {
166		return err
167	}
168	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateHIT{}, middleware.After)
169	if err != nil {
170		return err
171	}
172	if err = addSetLoggerMiddleware(stack, options); err != nil {
173		return err
174	}
175	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
176		return err
177	}
178	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
179		return err
180	}
181	if err = addResolveEndpointMiddleware(stack, options); err != nil {
182		return err
183	}
184	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
185		return err
186	}
187	if err = addRetryMiddlewares(stack, options); err != nil {
188		return err
189	}
190	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
191		return err
192	}
193	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
194		return err
195	}
196	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
197		return err
198	}
199	if err = addClientUserAgent(stack); err != nil {
200		return err
201	}
202	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
203		return err
204	}
205	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
206		return err
207	}
208	if err = addOpCreateHITValidationMiddleware(stack); err != nil {
209		return err
210	}
211	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateHIT(options.Region), middleware.Before); err != nil {
212		return err
213	}
214	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
215		return err
216	}
217	if err = addResponseErrorMiddleware(stack); err != nil {
218		return err
219	}
220	if err = addRequestResponseLogging(stack, options); err != nil {
221		return err
222	}
223	return nil
224}
225
226func newServiceMetadataMiddleware_opCreateHIT(region string) *awsmiddleware.RegisterServiceMetadata {
227	return &awsmiddleware.RegisterServiceMetadata{
228		Region:        region,
229		ServiceID:     ServiceID,
230		SigningName:   "mturk-requester",
231		OperationName: "CreateHIT",
232	}
233}
234