Skip to content

get_ontology

get_ontology(
    ontology_id: OntologyIdentifier,
    *,
    config_overrides: Optional[ContextClientConfig] = None,
    version: Optional[OntologyVersionString] = None,
    source_format: Optional[OntologySourceFormat] = None,
) -> GetOntologyResponse

Returns an ontology's status and one of its versions.

Parameters:

  • ontology_id (OntologyIdentifier) –

    The ontology to return, by its ID or ARN (see OntologyIdentifier).

  • version (Optional[OntologyVersionString], default: None ) –

    The version to return, in MAJOR.MINOR.PATCH form, for example 1.0.0. If you omit it, GetOntology returns the current default version.

  • source_format (Optional[OntologySourceFormat], default: None ) –

    Return the version's source document in source, in this format, in place of the template. The response then has no template. The format must be the version's sourceFormat. On a DRAFT ontology, GetOntology returns the draft, with or without version (its only version is 1.0.0). If the ontology is AWS managed, whose source is never returned, or the version has no source document, the request fails with ValidationException. If you omit it, the response has the template and no source.

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.

  • ResourceNotFoundException –

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

  • UnknownServiceError –

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

Examples:

Get an ontology and its source document The following example returns the current default version of an ontology, with its Turtle source document in place of the template.

>>> client.get_ontology(ontology_id='ont-7d3e9a1c5b2f4e8a9c0d1e2f3a4b5c6d', source_format='TURTLE')
Source code in docs_src/capo_context/_services/context.py
def get_ontology(
    self,
    ontology_id: "capo_context.types.ontology_identifier.OntologyIdentifier",
    *,
    config_overrides: Optional[ContextClientConfig] = None,
    version: Optional[
        "capo_context.types.ontology_version_string.OntologyVersionString"
    ] = None,
    source_format: Optional[
        "capo_context.types.ontology_source_format.OntologySourceFormat"
    ] = None,
) -> "capo_context.types.get_ontology_response.GetOntologyResponse":
    """<p>Returns an ontology's status and one of its versions.</p>

    Args:
        ontology_id: <p>The ontology to return, by its ID or ARN (see <code>OntologyIdentifier</code>).</p>
        version: <p>The version to return, in MAJOR.MINOR.PATCH form, for example <code>1.0.0</code>. If you omit it, GetOntology returns the current default version.</p>
        source_format: <p>Return the version's source document in <code>source</code>, in this format, in place of the template. The response then has no <code>template</code>. The format must be the version's <code>sourceFormat</code>. On a <code>DRAFT</code> ontology, GetOntology returns the draft, with or without <code>version</code> (its only version is 1.0.0). If the ontology is AWS managed, whose source is never returned, or the version has no source document, the request fails with <code>ValidationException</code>. If you omit it, the response has the template and no source.</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.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.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Get an ontology and its source document
        The following example returns the current default version of an ontology, with its Turtle source document in place of the template.

        >>> client.get_ontology(ontology_id='ont-7d3e9a1c5b2f4e8a9c0d1e2f3a4b5c6d', source_format='TURTLE')
    """

    def _handler(
        req: "OperationRequest[capo_context.types.get_ontology_request.GetOntologyRequest]",
    ) -> OperationResponse[
        "capo_context.types.get_ontology_response.GetOntologyResponse"
    ]:
        import capo_context._operations.context.get_ontology

        output, http_response = (
            capo_context._operations.context.get_ontology.get_ontology(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_context.types.get_ontology_response.GetOntologyResponse",
    ) -> dict[str, Any]:
        import capo_context.types.get_ontology_response

        return capo_context.types.get_ontology_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetOntology", redact_output=_redact_output),
    )
    input_: capo_context.types.get_ontology_request.GetOntologyRequest = {
        "ontology_id": ontology_id
    }
    if version is not None:
        input_["version"] = version
    if source_format is not None:
        input_["source_format"] = source_format

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