Lists the attributes for Amazon ECS resources within a specified target type and cluster. When you specify a target type and cluster, ListAttributes returns a list of attribute objects, one for each attribute on each resource. You can filter the list of results to a single attribute name to only return results that have that name. You can also filter the results by attribute name and value. You can do this, for example, to see which container instances in a cluster are running a Linux AMI (ecs.os-type=linux).
Parameters:
-
cluster
(Optional[String], default:
None
)
–
The short name or full Amazon Resource Name (ARN) of the cluster to list attributes. If you do not specify a cluster, the default cluster is assumed.
-
target_type
(TargetType)
–
The type of the target to list attributes with.
-
attribute_name
(Optional[String], default:
None
)
–
The name of the attribute to filter the results with.
-
attribute_value
(Optional[String], default:
None
)
–
The value of the attribute to filter results with. You must also specify an attribute name to use this parameter.
-
next_token
(Optional[String], default:
None
)
–
The nextToken value returned from a ListAttributes request indicating that more results are available to fulfill the request and further calls are needed. If maxResults was provided, it's possible the number of results to be fewer than maxResults.
This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.
-
max_results
(Optional[BoxedInteger], default:
None
)
–
The maximum number of cluster results that ListAttributes returned in paginated output. When this parameter is used, ListAttributes only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListAttributes request with the returned nextToken value. This value can be between 1 and 100. If this parameter isn't used, then ListAttributes returns up to 100 results and a nextToken value if applicable.
Raises:
-
AccessDeniedException
–
You don't have authorization to perform the requested action.
-
ClientException
–
These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.
-
ClusterNotFoundException
–
The specified cluster wasn't found. You can view your available clusters with ListClusters. Amazon ECS clusters are Region specific.
-
InvalidParameterException
–
The specified parameter isn't valid. Review the available parameters for the API request.
For more information about service event errors, see Amazon ECS service event messages.
-
ServerException
–
These errors are usually caused by a server issue.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To list container instances that have a specific attribute
This example lists attributes for a container instance with the attribute "stack" equal to the value "production".
>>> await client.list_attributes(cluster='MyCluster', target_type='container-instance', attribute_name='stack', attribute_value='production')
Source code in docs_src/capo_ecs/_services/async_ecs.py
| async def list_attributes(
self,
target_type: "capo_ecs.types.target_type.TargetType",
*,
config_overrides: Optional[AsyncECSClientConfig] = None,
cluster: Optional["capo_ecs.types.string.String"] = None,
attribute_name: Optional["capo_ecs.types.string.String"] = None,
attribute_value: Optional["capo_ecs.types.string.String"] = None,
next_token: Optional["capo_ecs.types.string.String"] = None,
max_results: Optional["capo_ecs.types.boxed_integer.BoxedInteger"] = None,
) -> "capo_ecs.types.list_attributes_response.ListAttributesResponse":
"""<p>Lists the attributes for Amazon ECS resources within a specified target type and cluster. When you specify a target type and cluster, <code>ListAttributes</code> returns a list of attribute objects, one for each attribute on each resource. You can filter the list of results to a single attribute name to only return results that have that name. You can also filter the results by attribute name and value. You can do this, for example, to see which container instances in a cluster are running a Linux AMI (<code>ecs.os-type=linux</code>). </p>
Args:
cluster: <p>The short name or full Amazon Resource Name (ARN) of the cluster to list attributes. If you do not specify a cluster, the default cluster is assumed.</p>
target_type: <p>The type of the target to list attributes with.</p>
attribute_name: <p>The name of the attribute to filter the results with. </p>
attribute_value: <p>The value of the attribute to filter results with. You must also specify an attribute name to use this parameter.</p>
next_token: <p>The <code>nextToken</code> value returned from a <code>ListAttributes</code> request indicating that more results are available to fulfill the request and further calls are needed. If <code>maxResults</code> was provided, it's possible the number of results to be fewer than <code>maxResults</code>.</p> <note> <p>This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.</p> </note>
max_results: <p>The maximum number of cluster results that <code>ListAttributes</code> returned in paginated output. When this parameter is used, <code>ListAttributes</code> only returns <code>maxResults</code> results in a single page along with a <code>nextToken</code> response element. The remaining results of the initial request can be seen by sending another <code>ListAttributes</code> request with the returned <code>nextToken</code> value. This value can be between 1 and 100. If this parameter isn't used, then <code>ListAttributes</code> returns up to 100 results and a <code>nextToken</code> value if applicable.</p>
Raises:
capo_ecs.errors.access_denied_exception.AccessDeniedException: <p>You don't have authorization to perform the requested action.</p>
capo_ecs.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.</p>
capo_ecs.errors.cluster_not_found_exception.ClusterNotFoundException: <p>The specified cluster wasn't found. You can view your available clusters with <a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ListClusters.html">ListClusters</a>. Amazon ECS clusters are Region specific.</p>
capo_ecs.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter isn't valid. Review the available parameters for the API request.</p> <p>For more information about service event errors, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages-list.html">Amazon ECS service event messages</a>. </p>
capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To list container instances that have a specific attribute
This example lists attributes for a container instance with the attribute "stack" equal to the value "production".
>>> await client.list_attributes(cluster='MyCluster', target_type='container-instance', attribute_name='stack', attribute_value='production')
"""
async def _handler(
req: "AsyncOperationRequest[capo_ecs.types.list_attributes_request.ListAttributesRequest]",
) -> AsyncOperationResponse[
"capo_ecs.types.list_attributes_response.ListAttributesResponse"
]:
import capo_ecs._operations.amazon_ec2_container_service_v20141113.list_attributes
(
output,
http_response,
) = await capo_ecs._operations.amazon_ec2_container_service_v20141113.list_attributes.async_list_attributes(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("ListAttributes")
)
input_: capo_ecs.types.list_attributes_request.ListAttributesRequest = {
"target_type": target_type
}
if cluster is not None:
input_["cluster"] = cluster
if attribute_name is not None:
input_["attribute_name"] = attribute_name
if attribute_value is not None:
input_["attribute_value"] = attribute_value
if next_token is not None:
input_["next_token"] = next_token
if max_results is not None:
input_["max_results"] = max_results
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|