createWorker method
Creates a worker. A worker tells your instance how much processing power (vCPU), and memory (GiB) you’ll need to assemble the digital assets held within a particular instance. You can specify certain instance types to use, or let the worker know which instances types to exclude.
Deadline Cloud limits the number of workers to less than or equal to the
fleet's maximum worker count. The service maintains eventual consistency
for the worker count. If you make multiple rapid calls to
CreateWorker before the field updates, you might exceed your
fleet's maximum worker count. For example, if your
maxWorkerCount is 10 and you currently have 9 workers, making
two quick CreateWorker calls might successfully create 2
workers instead of 1, resulting in 11 total workers.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerErrorException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter farmId :
The farm ID of the farm to connect to the worker.
Parameter fleetId :
The fleet ID to connect to the worker.
Parameter clientToken :
The unique token which the server uses to recognize retries of the same
request.
Parameter hostProperties :
The IP address and host name of the worker.
Parameter tags :
Each tag consists of a tag key and a tag value. Tag keys and values are
both required, but tag values can be empty strings.
Implementation
Future<CreateWorkerResponse> createWorker({
required String farmId,
required String fleetId,
String? clientToken,
HostPropertiesRequest? hostProperties,
Map<String, String>? tags,
}) async {
final headers = <String, String>{
if (clientToken != null) 'X-Amz-Client-Token': clientToken.toString(),
};
final $payload = <String, dynamic>{
if (hostProperties != null) 'hostProperties': hostProperties,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/2023-10-12/farms/${Uri.encodeComponent(farmId)}/fleets/${Uri.encodeComponent(fleetId)}/workers',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return CreateWorkerResponse.fromJson(response);
}