class_docstr: Make prediction requests to an Amazon SageMaker endpoint.
class_docstr_tok: ["Make","prediction","requests","to","an","Amazon","SageMaker","endpoint","."]
docstr: Retrieves the lineage context object representing the endpoint.
  
  Examples:
      .. code-block:: python
  
      predictor = Predictor()
      ...
      context = predictor.endpoint_context()
      models = context.models()
  
  Returns:
      ContextEndpoint: The context for the endpoint.
docstr_tok: ["Retrieves","the","lineage","context","object","representing","the","endpoint",".","Examples",":","..","code-block",":",":","python","predictor","=","Predictor","(",")","...","context","=","predictor.endpoint_context","(",")","models","=","context.models","(",")","Returns",":","ContextEndpoint",":","The","context","for","the","endpoint","."]
code: def endpoint_context(self):
      """Retrieves the lineage context object representing the endpoint.
  
      Examples:
          .. code-block:: python
  
          predictor = Predictor()
          ...
          context = predictor.endpoint_context()
          models = context.models()
  
      Returns:
          ContextEndpoint: The context for the endpoint.
      """
      if self._context:
          return self._context
  
      # retrieve endpoint by name to get arn
      response = (
          self.sagemaker_session.sagemaker_client.describe_endpoint(
              EndpointName=self.endpoint_name
          )
      )
      endpoint_arn = response["EndpointArn"]
  
      # list context by source uri using arn
      contexts = list(
          EndpointContext.list(
              sagemaker_session=self.sagemaker_session,
              source_uri=endpoint_arn,
          )
      )
  
      if len(contexts) != 0:
          # create endpoint context object
          self._context = EndpointContext.load(
              sagemaker_session=self.sagemaker_session,
              context_name=contexts[0].context_name,
          )
  
      return self._context
  
imports: from __future__ import print_function, absolute_import
  import abc
  import datetime
  from typing import Any, Dict, Optional, Tuple, Union
  import logging
  from sagemaker.enums import EndpointType
  from sagemaker.deprecations import deprecated_class, deprecated_deserialize, deprecated_serialize, removed_kwargs, renamed_kwargs, renamed_warning
  from sagemaker.deserializers import BytesDeserializer, CSVDeserializer, JSONDeserializer, NumpyDeserializer, StreamDeserializer, StringDeserializer
  from sagemaker.jumpstart.payload_utils import PayloadSerializer
  from sagemaker.jumpstart.types import JumpStartSerializablePayload
  from sagemaker.jumpstart.utils import get_jumpstart_content_bucket
  from sagemaker.model_monitor import DataCaptureConfig, DefaultModelMonitor, ModelBiasMonitor, ModelExplainabilityMonitor, ModelMonitor, ModelQualityMonitor
  from sagemaker.serializers import CSVSerializer, IdentitySerializer, JSONSerializer, NumpySerializer
  from sagemaker.session import production_variant, Session
  from sagemaker.utils import name_from_base, stringify_object, format_tags
  from sagemaker.model_monitor.model_monitoring import DEFAULT_REPOSITORY_NAME
  from sagemaker.lineage.context import EndpointContext
  from sagemaker.compute_resource_requirements.resource_requirements import ResourceRequirements
label_desc: Use image node_id 17 for calling the Predictor obj's underlying member method code with example usage: obj.endpoint_context() and returns: self, self