
                         f    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
  G d d	e      Zy
)zDFunctions for creating a client to talk to the App Engine Admin API.    )absolute_import)division)unicode_literals)apis)
properties)	resourcesc                   `    e Zd ZdZd Zed        Zed        Zedd       Z	d Z
d Zd	 Zd
 Zy)AppengineApiClientBasez%Base class for App Engine API client.c                     || _         t        j                  j                  j                  j                  d      | _        y )NT)required)clientr   VALUEScoreprojectGet)selfr   s     ?lib/googlecloudsdk/api_lib/app/api/appengine_api_client_base.py__init__zAppengineApiClientBase.__init__   s0    DK$$))1155t5DDL    c                 .    | j                   j                  S N)r   MESSAGES_MODULE)r   s    r   messageszAppengineApiClientBase.messages!   s    ;;&&&r   c                      y)Nv1 )clss    r   
ApiVersionz!AppengineApiClientBase.ApiVersion%   s    r   Nc                 ^    || j                         } | t        j                  d|            S )aT  Initializes an AppengineApiClient using the specified API version.

    Uses the api_client_overrides/appengine property to determine which client
    version to use if api_version is not set. Additionally uses the
    api_endpoint_overrides/appengine property to determine the server endpoint
    for the App Engine API.

    Args:
      api_version: The api version override.

    Returns:
      An AppengineApiClient used by gcloud to communicate with the App Engine
      API.

    Raises:
      ValueError: If default_version does not correspond to a supported version
      of the API.
    	appengine)r   	core_apisGetClientInstance)r   api_versions     r   GetApiClientz#AppengineApiClientBase.GetApiClient)   s.    ( NN$ky**;DEEr   c                 z    t         j                  j                  | j                  i d      }|j	                         S )Nzappengine.appsparams
collectionr   REGISTRYParser   RelativeName)r   ress     r   
_FormatAppz!AppengineApiClientBase._FormatAppB   s8    



"
"R,< # >Cr   c                 ~    t         j                  j                  |d| j                  id      }|j	                         S )NappsIdzappengine.apps.servicesr&   r)   )r   service_namer-   s      r   _GetServiceRelativeNamez.AppengineApiClientBase._GetServiceRelativeNameG   s@    



"
"$,,', # .C r   c                     t         j                  j                  || j                  |dd      }|j	                         S )N)r0   
servicesIdz appengine.apps.services.versionsr&   r)   )r   r1   
version_idr-   s       r   _FormatVersionz%AppengineApiClientBase._FormatVersionN   sC    



"
",,*,5	 # 7C
 r   c                 ~    t         j                  j                  |d| j                  id      }|j	                         S )Nr0   zappengine.apps.operationsr&   r)   )r   op_idr-   s      r   _FormatOperationz'AppengineApiClientBase._FormatOperationV   s@    



"
"$,,'. # 0C r   r   )__name__
__module____qualname____doc__r   propertyr   classmethodr   r$   r.   r2   r6   r9   r   r   r   r
   r
      s]    -E ' '   F F0
r   r
   N)r=   
__future__r   r   r   googlecloudsdk.api_lib.utilr   r!   googlecloudsdk.corer   r   objectr
   r   r   r   <module>rD      s+    K &  ' 9 * )AV Ar   