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 an AWS IoT OTAUpdate on a target group of things or groups. 15func (c *Client) CreateOTAUpdate(ctx context.Context, params *CreateOTAUpdateInput, optFns ...func(*Options)) (*CreateOTAUpdateOutput, error) { 16 if params == nil { 17 params = &CreateOTAUpdateInput{} 18 } 19 20 result, metadata, err := c.invokeOperation(ctx, "CreateOTAUpdate", params, optFns, addOperationCreateOTAUpdateMiddlewares) 21 if err != nil { 22 return nil, err 23 } 24 25 out := result.(*CreateOTAUpdateOutput) 26 out.ResultMetadata = metadata 27 return out, nil 28} 29 30type CreateOTAUpdateInput struct { 31 32 // The files to be streamed by the OTA update. 33 // 34 // This member is required. 35 Files []types.OTAUpdateFile 36 37 // The ID of the OTA update to be created. 38 // 39 // This member is required. 40 OtaUpdateId *string 41 42 // The IAM role that grants AWS IoT access to the Amazon S3, AWS IoT jobs and AWS 43 // Code Signing resources to create an OTA update job. 44 // 45 // This member is required. 46 RoleArn *string 47 48 // The devices targeted to receive OTA updates. 49 // 50 // This member is required. 51 Targets []string 52 53 // A list of additional OTA update parameters which are name-value pairs. 54 AdditionalParameters map[string]string 55 56 // The criteria that determine when and how a job abort takes place. 57 AwsJobAbortConfig *types.AwsJobAbortConfig 58 59 // Configuration for the rollout of OTA updates. 60 AwsJobExecutionsRolloutConfig *types.AwsJobExecutionsRolloutConfig 61 62 // Configuration information for pre-signed URLs. 63 AwsJobPresignedUrlConfig *types.AwsJobPresignedUrlConfig 64 65 // Specifies the amount of time each device has to finish its execution of the job. 66 // A timer is started when the job execution status is set to IN_PROGRESS. If the 67 // job execution status is not set to another terminal state before the timer 68 // expires, it will be automatically set to TIMED_OUT. 69 AwsJobTimeoutConfig *types.AwsJobTimeoutConfig 70 71 // The description of the OTA update. 72 Description *string 73 74 // The protocol used to transfer the OTA update image. Valid values are [HTTP], 75 // [MQTT], [HTTP, MQTT]. When both HTTP and MQTT are specified, the target device 76 // can choose the protocol. 77 Protocols []types.Protocol 78 79 // Metadata which can be used to manage updates. 80 Tags []types.Tag 81 82 // Specifies whether the update will continue to run (CONTINUOUS), or will be 83 // complete after all the things specified as targets have completed the update 84 // (SNAPSHOT). If continuous, the update may also be run on a thing when a change 85 // is detected in a target. For example, an update will run on a thing when the 86 // thing is added to a target group, even after the update was completed by all 87 // things originally in the group. Valid values: CONTINUOUS | SNAPSHOT. 88 TargetSelection types.TargetSelection 89} 90 91type CreateOTAUpdateOutput struct { 92 93 // The AWS IoT job ARN associated with the OTA update. 94 AwsIotJobArn *string 95 96 // The AWS IoT job ID associated with the OTA update. 97 AwsIotJobId *string 98 99 // The OTA update ARN. 100 OtaUpdateArn *string 101 102 // The OTA update ID. 103 OtaUpdateId *string 104 105 // The OTA update status. 106 OtaUpdateStatus types.OTAUpdateStatus 107 108 // Metadata pertaining to the operation's result. 109 ResultMetadata middleware.Metadata 110} 111 112func addOperationCreateOTAUpdateMiddlewares(stack *middleware.Stack, options Options) (err error) { 113 err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateOTAUpdate{}, middleware.After) 114 if err != nil { 115 return err 116 } 117 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateOTAUpdate{}, middleware.After) 118 if err != nil { 119 return err 120 } 121 if err = addSetLoggerMiddleware(stack, options); err != nil { 122 return err 123 } 124 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 125 return err 126 } 127 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 128 return err 129 } 130 if err = addResolveEndpointMiddleware(stack, options); err != nil { 131 return err 132 } 133 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 134 return err 135 } 136 if err = addRetryMiddlewares(stack, options); err != nil { 137 return err 138 } 139 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 140 return err 141 } 142 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 143 return err 144 } 145 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 146 return err 147 } 148 if err = addClientUserAgent(stack); err != nil { 149 return err 150 } 151 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 152 return err 153 } 154 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 155 return err 156 } 157 if err = addOpCreateOTAUpdateValidationMiddleware(stack); err != nil { 158 return err 159 } 160 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateOTAUpdate(options.Region), middleware.Before); err != nil { 161 return err 162 } 163 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 164 return err 165 } 166 if err = addResponseErrorMiddleware(stack); err != nil { 167 return err 168 } 169 if err = addRequestResponseLogging(stack, options); err != nil { 170 return err 171 } 172 return nil 173} 174 175func newServiceMetadataMiddleware_opCreateOTAUpdate(region string) *awsmiddleware.RegisterServiceMetadata { 176 return &awsmiddleware.RegisterServiceMetadata{ 177 Region: region, 178 ServiceID: ServiceID, 179 SigningName: "execute-api", 180 OperationName: "CreateOTAUpdate", 181 } 182} 183