1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package iot 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/iot/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates a job. 15func (c *Client) CreateJob(ctx context.Context, params *CreateJobInput, optFns ...func(*Options)) (*CreateJobOutput, error) { 16 if params == nil { 17 params = &CreateJobInput{} 18 } 19 20 result, metadata, err := c.invokeOperation(ctx, "CreateJob", params, optFns, addOperationCreateJobMiddlewares) 21 if err != nil { 22 return nil, err 23 } 24 25 out := result.(*CreateJobOutput) 26 out.ResultMetadata = metadata 27 return out, nil 28} 29 30type CreateJobInput struct { 31 32 // A job identifier which must be unique for your AWS account. We recommend using a 33 // UUID. Alpha-numeric characters, "-" and "_" are valid for use here. 34 // 35 // This member is required. 36 JobId *string 37 38 // A list of things and thing groups to which the job should be sent. 39 // 40 // This member is required. 41 Targets []string 42 43 // Allows you to create criteria to abort a job. 44 AbortConfig *types.AbortConfig 45 46 // A short text description of the job. 47 Description *string 48 49 // The job document. If the job document resides in an S3 bucket, you must use a 50 // placeholder link when specifying the document. The placeholder link is of the 51 // following form: ${aws:iot:s3-presigned-url:https://s3.amazonaws.com/bucket/key} 52 // where bucket is your bucket name and key is the object in the bucket to which 53 // you are linking. 54 Document *string 55 56 // An S3 link to the job document. 57 DocumentSource *string 58 59 // Allows you to create a staged rollout of the job. 60 JobExecutionsRolloutConfig *types.JobExecutionsRolloutConfig 61 62 // The namespace used to indicate that a job is a customer-managed job. When you 63 // specify a value for this parameter, AWS IoT Core sends jobs notifications to 64 // MQTT topics that contain the value in the following format. 65 // $aws/things/THING_NAME/jobs/JOB_ID/notify-namespace-NAMESPACE_ID/ The 66 // namespaceId feature is in public preview. 67 NamespaceId *string 68 69 // Configuration information for pre-signed S3 URLs. 70 PresignedUrlConfig *types.PresignedUrlConfig 71 72 // Metadata which can be used to manage the job. 73 Tags []types.Tag 74 75 // Specifies whether the job will continue to run (CONTINUOUS), or will be complete 76 // after all those things specified as targets have completed the job (SNAPSHOT). 77 // If continuous, the job may also be run on a thing when a change is detected in a 78 // target. For example, a job will run on a thing when the thing is added to a 79 // target group, even after the job was completed by all things originally in the 80 // group. 81 TargetSelection types.TargetSelection 82 83 // Specifies the amount of time each device has to finish its execution of the job. 84 // The timer is started when the job execution status is set to IN_PROGRESS. If the 85 // job execution status is not set to another terminal state before the time 86 // expires, it will be automatically set to TIMED_OUT. 87 TimeoutConfig *types.TimeoutConfig 88} 89 90type CreateJobOutput struct { 91 92 // The job description. 93 Description *string 94 95 // The job ARN. 96 JobArn *string 97 98 // The unique identifier you assigned to this job. 99 JobId *string 100 101 // Metadata pertaining to the operation's result. 102 ResultMetadata middleware.Metadata 103} 104 105func addOperationCreateJobMiddlewares(stack *middleware.Stack, options Options) (err error) { 106 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateJob{}, middleware.After) 107 if err != nil { 108 return err 109 } 110 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateJob{}, middleware.After) 111 if err != nil { 112 return err 113 } 114 if err = addSetLoggerMiddleware(stack, options); err != nil { 115 return err 116 } 117 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 118 return err 119 } 120 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 121 return err 122 } 123 if err = addResolveEndpointMiddleware(stack, options); err != nil { 124 return err 125 } 126 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 127 return err 128 } 129 if err = addRetryMiddlewares(stack, options); err != nil { 130 return err 131 } 132 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 133 return err 134 } 135 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 136 return err 137 } 138 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 139 return err 140 } 141 if err = addClientUserAgent(stack); err != nil { 142 return err 143 } 144 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 145 return err 146 } 147 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 148 return err 149 } 150 if err = addOpCreateJobValidationMiddleware(stack); err != nil { 151 return err 152 } 153 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateJob(options.Region), middleware.Before); err != nil { 154 return err 155 } 156 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 157 return err 158 } 159 if err = addResponseErrorMiddleware(stack); err != nil { 160 return err 161 } 162 if err = addRequestResponseLogging(stack, options); err != nil { 163 return err 164 } 165 return nil 166} 167 168func newServiceMetadataMiddleware_opCreateJob(region string) *awsmiddleware.RegisterServiceMetadata { 169 return &awsmiddleware.RegisterServiceMetadata{ 170 Region: region, 171 ServiceID: ServiceID, 172 SigningName: "execute-api", 173 OperationName: "CreateJob", 174 } 175} 176