@@ -116,9 +116,9 @@ def __init__(
116116 resource_name = endpoint_name ,
117117 )
118118 self ._gca_resource = self ._get_gca_resource (resource_name = endpoint_name )
119+
119120 self ._prediction_client = self ._instantiate_prediction_client (
120- location = location or initializer .global_config .location ,
121- credentials = credentials ,
121+ location = self .location , credentials = credentials ,
122122 )
123123
124124 @property
@@ -324,6 +324,46 @@ def _create(
324324 credentials = credentials ,
325325 )
326326
327+ @classmethod
328+ def _construct_sdk_resource_from_gapic (
329+ cls ,
330+ gapic_resource : proto .Message ,
331+ project : Optional [str ] = None ,
332+ location : Optional [str ] = None ,
333+ credentials : Optional [auth_credentials .Credentials ] = None ,
334+ ) -> "Endpoint" :
335+ """Given a GAPIC Endpoint object, return the SDK representation.
336+
337+ Args:
338+ gapic_resource (proto.Message):
339+ A GAPIC representation of a Endpoint resource, usually
340+ retrieved by a get_* or in a list_* API call.
341+ project (str):
342+ Optional. Project to construct Endpoint object from. If not set,
343+ project set in aiplatform.init will be used.
344+ location (str):
345+ Optional. Location to construct Endpoint object from. If not set,
346+ location set in aiplatform.init will be used.
347+ credentials (auth_credentials.Credentials):
348+ Optional. Custom credentials to use to construct Endpoint.
349+ Overrides credentials set in aiplatform.init.
350+
351+ Returns:
352+ Endpoint:
353+ An initialized Endpoint resource.
354+ """
355+ endpoint = cls ._empty_constructor (
356+ project = project , location = location , credentials = credentials
357+ )
358+
359+ endpoint ._gca_resource = gapic_resource
360+
361+ endpoint ._prediction_client = cls ._instantiate_prediction_client (
362+ location = endpoint .location , credentials = credentials ,
363+ )
364+
365+ return endpoint
366+
327367 @staticmethod
328368 def _allocate_traffic (
329369 traffic_split : Dict [str , int ], traffic_percentage : int ,
0 commit comments