Skip to content

tag_resource

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

Adds tags to an agent context, connection, curation policy, customer-owned ontology, or ontology induction.

Parameters:

  • resource_arn (TaggableResourceArn) –

    The ARN of the resource to tag.

  • tags (TagMap) –

    The tags to add, 1–200 per request. Keys must not start with aws:.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.

  • InternalServerException –

    The request failed because of an internal error. Retry the request.

  • ThrottlingException –

    The request was denied because it exceeded a request rate quota. Wait, then retry the request.

  • ValidationException –

    The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.

  • ConflictException –

    The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.

  • ResourceNotFoundException –

    The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.

  • ServiceQuotaExceededException –

    The request would exceed a service quota. Check the quota that quotaCode names, reduce your usage, and then retry the request.

  • UnknownServiceError –

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

Examples:

Add tags to an agent context The following example adds two tags to the agent context ac-a1b2c3d4e5f64a7b8c9d0e1f2a3b4c5d.

>>> client.tag_resource(resource_arn='arn:aws:context:us-east-1:111122223333:agent-context/ac-a1b2c3d4e5f64a7b8c9d0e1f2a3b4c5d', tags={'team': 'sales-analytics', 'environment': 'production'})
Source code in docs_src/capo_context/_services/context.py
def tag_resource(
    self,
    resource_arn: "capo_context.types.taggable_resource_arn.TaggableResourceArn",
    tags: "capo_context.types.tag_map.TagMap",
    *,
    config_overrides: Optional[ContextClientConfig] = None,
) -> "capo_context.types.tag_resource_response.TagResourceResponse":
    """<p>Adds tags to an agent context, connection, curation policy, customer-owned ontology, or ontology induction.</p>

    Args:
        resource_arn: <p>The ARN of the resource to tag.</p>
        tags: <p>The tags to add, 1–200 per request. Keys must not start with <code>aws:</code>.</p>

    Raises:
        capo_context.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.</p>
        capo_context.errors.internal_server_exception.InternalServerException: <p>The request failed because of an internal error. Retry the request.</p>
        capo_context.errors.throttling_exception.ThrottlingException: <p>The request was denied because it exceeded a request rate quota. Wait, then retry the request.</p>
        capo_context.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.</p>
        capo_context.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.</p>
        capo_context.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.</p>
        capo_context.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a service quota. Check the quota that <code>quotaCode</code> names, reduce your usage, and then retry the request.</p>
        capo_context.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Add tags to an agent context
        The following example adds two tags to the agent context ac-a1b2c3d4e5f64a7b8c9d0e1f2a3b4c5d.

        >>> client.tag_resource(resource_arn='arn:aws:context:us-east-1:111122223333:agent-context/ac-a1b2c3d4e5f64a7b8c9d0e1f2a3b4c5d', tags={'team': 'sales-analytics', 'environment': 'production'})
    """

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

        output, http_response = (
            capo_context._operations.context.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_context.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