Skip to content

tag_resource async

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

Adds tags to a resource.

Parameters:

  • resource_arn (Arn) –

    The Amazon Resource Name (ARN) of the resource to apply a tag to.

  • tags (TagMap) –

    The tags to be added to a resource.

Raises:

Source code in docs_src/capo_inspector2/_services/async_inspector2.py
async def tag_resource(
    self,
    resource_arn: "capo_inspector2.types.arn.Arn",
    tags: "capo_inspector2.types.tag_map.TagMap",
    *,
    config_overrides: Optional[AsyncInspector2ClientConfig] = None,
) -> "capo_inspector2.types.tag_resource_response.TagResourceResponse":
    """<p>Adds tags to a resource.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the resource to apply a tag to.</p>
        tags: <p>The tags to be added to a resource.</p>

    Raises:
        capo_inspector2.errors.bad_request_exception.BadRequestException: <p>One or more tags submitted as part of the request is not valid.</p>
        capo_inspector2.errors.internal_server_exception.InternalServerException: <p>The request has failed due to an internal failure of the Amazon Inspector service.</p>
        capo_inspector2.errors.resource_not_found_exception.ResourceNotFoundException: <p>The operation tried to access an invalid resource. Make sure the resource is specified correctly.</p>
        capo_inspector2.errors.throttling_exception.ThrottlingException: <p>The limit on the number of requests per second was exceeded.</p>
        capo_inspector2.errors.validation_exception.ValidationException: <p>The request has failed validation due to missing required fields or having invalid inputs.</p>
        capo_inspector2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

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

        (
            output,
            http_response,
        ) = await capo_inspector2._operations.inspector2.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_inspector2.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