Retrieves the protection status of tasks in an Amazon ECS service.
Parameters:
-
cluster
(String)
–
The short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.
-
tasks
(Optional[StringList], default:
None
)
–
A list of up to 100 task IDs or full ARN entries.
Raises:
Examples:
To get the protection status of a task
In this example, we get the protection status for a single task.
>>> client.get_task_protection(cluster='test-task-protection', tasks=['b8b1cf532d0e46ba8d44a40d1de16772'])
Source code in docs_src/capo_ecs/_services/ecs.py
| def get_task_protection(
self,
cluster: "capo_ecs.types.string.String",
*,
config_overrides: Optional[ECSClientConfig] = None,
tasks: Optional["capo_ecs.types.string_list.StringList"] = None,
) -> "capo_ecs.types.get_task_protection_response.GetTaskProtectionResponse":
"""<p>Retrieves the protection status of tasks in an Amazon ECS service.</p>
Args:
cluster: <p>The short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.</p>
tasks: <p>A list of up to 100 task IDs or full ARN entries.</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.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource wasn't found.</p>
capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
capo_ecs.errors.unsupported_feature_exception.UnsupportedFeatureException: <p>The specified task isn't supported in this Region.</p>
capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To get the protection status of a task
In this example, we get the protection status for a single task.
>>> client.get_task_protection(cluster='test-task-protection', tasks=['b8b1cf532d0e46ba8d44a40d1de16772'])
"""
def _handler(
req: "OperationRequest[capo_ecs.types.get_task_protection_request.GetTaskProtectionRequest]",
) -> OperationResponse[
"capo_ecs.types.get_task_protection_response.GetTaskProtectionResponse"
]:
import capo_ecs._operations.amazon_ec2_container_service_v20141113.get_task_protection
output, http_response = (
capo_ecs._operations.amazon_ec2_container_service_v20141113.get_task_protection.get_task_protection(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("GetTaskProtection")
)
input_: capo_ecs.types.get_task_protection_request.GetTaskProtectionRequest = {
"cluster": cluster
}
if tasks is not None:
input_["tasks"] = tasks
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|