Skip to content

tag_resource

tag_resource(
    resource_arn: ARN,
    tags: TagsMap,
    *,
    config_overrides: Optional[mgnClientConfig] = None,
) -> None

Adds or overwrites only the specified tags for the specified Application Migration Service resource or resources. When you specify an existing tag key, the value is overwritten with the new value. Each resource can have a maximum of 50 tags. Each tag consists of a key and optional value.

Parameters:

  • resource_arn (ARN) –

    Tag resource by ARN.

  • tags (TagsMap) –

    Tag resource by Tags.

Raises:

Source code in docs_src/capo_mgn/_services/mgn.py
def tag_resource(
    self,
    resource_arn: "capo_mgn.types.arn.ARN",
    tags: "capo_mgn.types.tags_map.TagsMap",
    *,
    config_overrides: Optional[mgnClientConfig] = None,
) -> None:
    """<p>Adds or overwrites only the specified tags for the specified Application Migration Service resource or resources. When you specify an existing tag key, the value is overwritten with the new value. Each resource can have a maximum of 50 tags. Each tag consists of a key and optional value.</p>

    Args:
        resource_arn: <p>Tag resource by ARN.</p>
        tags: <p>Tag resource by Tags.</p>

    Raises:
        capo_mgn.errors.access_denied_exception.AccessDeniedException: <p>Operation denied due to a file permission or access check error.</p>
        capo_mgn.errors.internal_server_exception.InternalServerException: <p>The server encountered an unexpected condition that prevented it from fulfilling the request.</p>
        capo_mgn.errors.resource_not_found_exception.ResourceNotFoundException: <p>Resource not found exception.</p>
        capo_mgn.errors.throttling_exception.ThrottlingException: <p>Reached throttling quota exception.</p>
        capo_mgn.errors.validation_exception.ValidationException: <p>Validate exception.</p>
        capo_mgn.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_mgn.types.tag_resource_request.TagResourceRequest]",
    ) -> OperationResponse[None]:
        import capo_mgn._operations.application_migration_service.tag_resource

        output, http_response = (
            capo_mgn._operations.application_migration_service.tag_resource.tag_resource(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_mgn.types.tag_resource_request.TagResourceRequest",
    ) -> dict[str, Any]:
        import capo_mgn.types.tag_resource_request

        return capo_mgn.types.tag_resource_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("TagResource", redact_input=_redact_input),
    )
    input_: capo_mgn.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