Skip to content

tag_resource async

tag_resource(
    resource_arn: Arn,
    tags: TagList,
    *,
    config_overrides: Optional[AsyncECRPUBLICClientConfig] = None,
) -> TagResourceResponse

Associates the specified tags to a resource with the specified resourceArn. If existing tags on a resource aren't specified in the request parameters, they aren't changed. When a resource is deleted, the tags associated with that resource are also deleted.

Parameters:

  • resource_arn (Arn) –

    The Amazon Resource Name (ARN) of the resource to add tags to. Currently, the supported resource is an Amazon ECR Public repository.

  • tags (TagList) –

    The tags to add to the resource. A tag is an array of key-value pairs. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

Raises:

  • InvalidParameterException –

    The specified parameter is invalid. Review the available parameters for the API request.

  • InvalidTagParameterException –

    An invalid parameter has been specified. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

  • RepositoryNotFoundException –

    The specified repository can't be found. Check the spelling of the specified repository and ensure that you're performing operations on the correct registry.

  • ServerException –

    These errors are usually caused by a server-side issue.

  • TooManyTagsException –

    The list of tags on the repository is over the limit. The maximum number of tags that can be applied to a repository is 50.

  • UnsupportedCommandException –

    The action isn't supported in this Region.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_ecr_public/_services/async_ecrpublic.py
async def tag_resource(
    self,
    resource_arn: "capo_ecr_public.types.arn.Arn",
    tags: "capo_ecr_public.types.tag_list.TagList",
    *,
    config_overrides: Optional[AsyncECRPUBLICClientConfig] = None,
) -> "capo_ecr_public.types.tag_resource_response.TagResourceResponse":
    """<p>Associates the specified tags to a resource with the specified <code>resourceArn</code>. If existing tags on a resource aren't specified in the request parameters, they aren't changed. When a resource is deleted, the tags associated with that resource are also deleted.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the resource to add tags to. Currently, the supported resource is an Amazon ECR Public repository.</p>
        tags: <p>The tags to add to the resource. A tag is an array of key-value pairs. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.</p>

    Raises:
        capo_ecr_public.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter is invalid. Review the available parameters for the API request.</p>
        capo_ecr_public.errors.invalid_tag_parameter_exception.InvalidTagParameterException: <p>An invalid parameter has been specified. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.</p>
        capo_ecr_public.errors.repository_not_found_exception.RepositoryNotFoundException: <p>The specified repository can't be found. Check the spelling of the specified repository and ensure that you're performing operations on the correct registry.</p>
        capo_ecr_public.errors.server_exception.ServerException: <p>These errors are usually caused by a server-side issue.</p>
        capo_ecr_public.errors.too_many_tags_exception.TooManyTagsException: <p>The list of tags on the repository is over the limit. The maximum number of tags that can be applied to a repository is 50.</p>
        capo_ecr_public.errors.unsupported_command_exception.UnsupportedCommandException: <p>The action isn't supported in this Region.</p>
        capo_ecr_public.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ecr_public.types.tag_resource_request.TagResourceRequest]",
    ) -> AsyncOperationResponse[
        "capo_ecr_public.types.tag_resource_response.TagResourceResponse"
    ]:
        import capo_ecr_public._operations.spencer_frontend_service.tag_resource

        (
            output,
            http_response,
        ) = await capo_ecr_public._operations.spencer_frontend_service.tag_resource.async_tag_resource(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TagResource")
    )
    input_: capo_ecr_public.types.tag_resource_request.TagResourceRequest = {
        "resource_arn": resource_arn,
        "tags": tags,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output