putAttributes method

Future<PutAttributesResponse> putAttributes({
  1. required List<Attribute> attributes,
  2. String? cluster,
})

Create or update an attribute on an Amazon ECS resource. If the attribute does not exist, it is created. If the attribute exists, its value is replaced with the specified value. To delete an attribute, use DeleteAttributes. For more information, see Attributes in the Amazon Elastic Container Service Developer Guide.

May throw ClusterNotFoundException. May throw TargetNotFoundException. May throw AttributeLimitExceededException. May throw InvalidParameterException.

Parameter attributes : The attributes to apply to your resource. You can specify up to 10 custom attributes per resource. You can specify up to 10 attributes in a single call.

Parameter cluster : The short name or full Amazon Resource Name (ARN) of the cluster that contains the resource to apply attributes. If you do not specify a cluster, the default cluster is assumed.

Implementation

Future<PutAttributesResponse> putAttributes({
  required List<Attribute> attributes,
  String? cluster,
}) async {
  ArgumentError.checkNotNull(attributes, 'attributes');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonEC2ContainerServiceV20141113.PutAttributes'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'attributes': attributes,
      if (cluster != null) 'cluster': cluster,
    },
  );

  return PutAttributesResponse.fromJson(jsonResponse.body);
}