createComponentVersion method
Creates a component. Components are software that run on Greengrass core devices. After you develop and test a component on your core device, you can use this operation to upload your component to IoT Greengrass. Then, you can deploy the component to other core devices.
You can use this operation to do the following:
-
Create components from recipes
Create a component from a recipe, which is a file that defines the component's metadata, parameters, dependencies, lifecycle, artifacts, and platform capability. For more information, see IoT Greengrass component recipe reference in the IoT Greengrass V2 Developer Guide.
To create a component from a recipe, specify
inlineRecipewhen you call this operation. -
Create components from Lambda functions
Create a component from an Lambda function that runs on IoT Greengrass. This creates a recipe and artifacts from the Lambda function's deployment package. You can use this operation to migrate Lambda functions from IoT Greengrass V1 to IoT Greengrass V2.
This function accepts Lambda functions in all supported versions of Python, Node.js, and Java runtimes. IoT Greengrass doesn't apply any additional restrictions on deprecated Lambda runtime versions.
To create a component from a Lambda function, specify
lambdaFunctionwhen you call this operation.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw RequestAlreadyInProgressException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter clientToken :
A unique, case-sensitive identifier that you can provide to ensure that
the request is idempotent. Idempotency means that the request is
successfully processed only once, even if you send the request multiple
times. When a request succeeds, and you specify the same client token for
subsequent successful requests, the IoT Greengrass V2 service returns the
successful response that it caches from the previous request. IoT
Greengrass V2 caches successful responses for idempotent requests for up
to 8 hours.
Parameter inlineRecipe :
The recipe to use to create the component. The recipe defines the
component's metadata, parameters, dependencies, lifecycle, artifacts, and
platform compatibility.
You must specify either inlineRecipe or
lambdaFunction.
Parameter lambdaFunction :
The parameters to create a component from a Lambda function.
You must specify either inlineRecipe or
lambdaFunction.
Parameter tags :
A list of key-value pairs that contain metadata for the resource. For more
information, see Tag
your resources in the IoT Greengrass V2 Developer Guide.
Implementation
Future<CreateComponentVersionResponse> createComponentVersion({
String? clientToken,
Uint8List? inlineRecipe,
LambdaFunctionRecipeSource? lambdaFunction,
Map<String, String>? tags,
}) async {
final $payload = <String, dynamic>{
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (inlineRecipe != null) 'inlineRecipe': base64Encode(inlineRecipe),
if (lambdaFunction != null) 'lambdaFunction': lambdaFunction,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/greengrass/v2/createComponentVersion',
exceptionFnMap: _exceptionFns,
);
return CreateComponentVersionResponse.fromJson(response);
}