Skip to content

tag_resource

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

Adds or updates tags for a resource in Shield.

Parameters:

  • resource_arn (ResourceArn) –

    The Amazon Resource Name (ARN) of the resource that you want to add or update tags for.

  • tags (TagList) –

    The tags that you want to modify or add to the resource.

Raises:

  • InternalErrorException –

    Exception that indicates that a problem occurred with the service infrastructure. You can retry the request.

  • InvalidParameterException –

    Exception that indicates that the parameters passed to the API are invalid. If available, this exception includes details in additional properties.

  • InvalidResourceException –

    Exception that indicates that the resource is invalid. You might not have access to the resource, or the resource might not exist.

  • ResourceNotFoundException –

    Exception indicating the specified resource does not exist. If available, this exception includes details in additional properties.

  • UnknownServiceError –

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

Source code in docs_src/capo_shield/_services/shield.py
def tag_resource(
    self,
    resource_arn: "capo_shield.types.resource_arn.ResourceArn",
    tags: "capo_shield.types.tag_list.TagList",
    *,
    config_overrides: Optional[ShieldClientConfig] = None,
) -> "capo_shield.types.tag_resource_response.TagResourceResponse":
    """<p>Adds or updates tags for a resource in Shield.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the resource that you want to add or update tags for.</p>
        tags: <p>The tags that you want to modify or add to the resource.</p>

    Raises:
        capo_shield.errors.internal_error_exception.InternalErrorException: <p>Exception that indicates that a problem occurred with the service infrastructure. You can retry the request.</p>
        capo_shield.errors.invalid_parameter_exception.InvalidParameterException: <p>Exception that indicates that the parameters passed to the API are invalid. If available, this exception includes details in additional properties. </p>
        capo_shield.errors.invalid_resource_exception.InvalidResourceException: <p>Exception that indicates that the resource is invalid. You might not have access to the resource, or the resource might not exist.</p>
        capo_shield.errors.resource_not_found_exception.ResourceNotFoundException: <p>Exception indicating the specified resource does not exist. If available, this exception includes details in additional properties. </p>
        capo_shield.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_shield.types.tag_resource_request.TagResourceRequest]",
    ) -> OperationResponse[
        "capo_shield.types.tag_resource_response.TagResourceResponse"
    ]:
        import capo_shield._operations.aws_shield_20160616.tag_resource

        output, http_response = (
            capo_shield._operations.aws_shield_20160616.tag_resource.tag_resource(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

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

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output