
    t                        d Z ddlZddlZddlZddlZddlZddl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 dd	lmZ dd
lmZ g dZ ej&                  d      j)                  ej*                         dZ G d dej.                        Z G d dej.                        ZdZd Zd Zd Zd Z G d de      Z d Z! G d de      Z" G d de      Z#y)zBase class for api services.    N)http_client)urllib)message_types)messages)encoding)
exceptions)http_wrapper)util)ApiMethodInfoApiUploadInfoBaseApiClientBaseApiServiceNormalizeApiEndpointzoauth2client.utili   c                       e Zd ZdZ ej
                  dd      Z ej                  d      Z ej
                  d      Z	 ej                  d      Z ej
                  d      Z ej                  d	      Zy
)r   aT  Media upload information for a method.

    Fields:
      accept: (repeated) MIME Media Ranges for acceptable media uploads
          to this method.
      max_size: (integer) Maximum size of a media upload, such as 3MB
          or 1TB (converted to an integer).
      resumable_path: Path to use for resumable uploads.
      resumable_multipart: (boolean) Whether or not the resumable endpoint
          supports multipart uploads.
      simple_path: Path to use for simple uploads.
      simple_multipart: (boolean) Whether or not the simple endpoint
          supports multipart uploads.
       Trepeated               N)__name__
__module____qualname____doc__r   StringFieldacceptIntegerFieldmax_sizeresumable_pathBooleanFieldresumable_multipartsimple_pathsimple_multipart     ,lib/third_party/apitools/base/py/base_api.pyr   r   5   sy     "X!!!d3F$x$$Q'H)X))!,N/(//2&(&&q)K,x,,Q/r'   r   c                      e Zd ZdZ ej
                  d      Z ej
                  d      Z ej
                  d      Z ej
                  d      Z	 ej
                  dd      Z
 ej
                  d	d      Z ej
                  d
d      Z ej
                  d      Z ej
                  d      Z ej
                  d      Z ej
                  dd      Z ej"                  ed      Z ej(                  dd      Z ej
                  d      Zy)r   a  Configuration info for an API method.

    All fields are strings unless noted otherwise.

    Fields:
      relative_path: Relative path for this method.
      flat_path: Expanded version (if any) of relative_path.
      method_id: ID for this method.
      http_method: HTTP verb to use for this method.
      path_params: (repeated) path parameters for this method.
      query_params: (repeated) query parameters for this method.
      ordered_params: (repeated) ordered list of parameters for
          this method.
      description: description of this method.
      request_type_name: name of the request type.
      response_type_name: name of the response type.
      request_field: if not null, the field to pass as the body
          of this POST request. may also be the REQUEST_IS_BODY
          value below to indicate the whole message is the body.
      upload_config: (ApiUploadInfo) Information about the upload
          configuration supported by this method.
      supports_download: (boolean) If True, this method supports
          downloading the request via the `alt=media` query
          parameter.
      api_version_param: API version system parameter for this
          method.
    r   r   r   r   r   Tr   r         	   
       )default      F   N)r   r   r   r   r   r   relative_path	flat_path	method_idhttp_methodpath_paramsquery_paramsordered_paramsdescriptionrequest_type_nameresponse_type_namerequest_fieldMessageFieldr   upload_configr"   supports_downloadapi_version_paramr&   r'   r(   r   r   M   s   8 )H((+M$$$Q'I$$$Q'I&(&&q)K&(&&q48K'8''D9L)X))!d;N&(&&q)K,,,Q/---b1(H((R8M)H))-<M---b%@,,,R0r'   r   z	<request>c                     | j                  d      r%| j                  d      \  }}}t        t        |      S d| vrt        ||       S t	        j
                  d| z        )Nzmessage_types..zUnknown class %s)
startswith	partitiongetattrr   r   GeneratedClientError)namemessages_module_	classnames       r(   
_LoadClassrM   ~   s[    '(..-1i}i00	D----.@4.GHHr'   c                     |D ]^  }|j                         }t        | d|z        rt        | |      r/d|dt        |       j                  d}t        j                  |       y )Nz%szNo z specified for object of class rD   )upperhasattrrG   typer   r   rH   )objattrsattr	attr_namemsgs        r(   _RequireClassAttrsrW      sW    JJL	sD9,-WS)5L49--/C11#66 r'   c                 2    | j                  d      s| dz  } | S )N/)endswith)api_endpoints    r(   r   r      s       %r'   c                     |j                  d      s|j                  d      r t        j                  j                  | |      S | j	                  d      r| n| dz   }|j                  d      r|dd n|}||z   S )z8Custom urljoin replacement supporting : before / in url.zhttp://zhttps://rY   r   N)rE   r   parseurljoinrZ   )baseurlnew_basenew_urls       r(   _urljoinrc      sk     ~~i CNN:$>||##D#..}}S)ttczH,c!"g#Ggr'   c                   |    e Zd ZdZd	dZed        Zed        Zej                  d        Zed        Z
ed        Zy)
_UrlBuilderz"Convenient container for url data.Nc                    t         j                  j                  t        ||xs d            }|j                  r"t        j                  d|j                  z        t         j                  j                  |j                  xs d      | _	        || j                  j                  |       |j                  | _        |j                  | _        |j                  xs d| _        y )Nr/   zUnexpected url fragment: %s)r   r]   urlsplitrc   fragmentr   ConfigurationValueErrorparse_qsqueryr9   updatescheme_UrlBuilder__schemenetloc_UrlBuilder__netlocpathr4   )selfbase_urlr4   r9   
componentss        r(   __init__z_UrlBuilder.__init__   s    \\**8m)r,+ ,
44-
0C0CCE E"LL11*2B2B2HbI#$$\2"))"))'__2r'   c                 8   t         j                  j                  |      }t         j                  j                  |j                        }t         j                  j                  |j                  |j                  dd d f      }|j                  xs d} | |||      S )Nr/   )r4   r9   )	r   r]   rg   rj   rk   
urlunsplitrm   ro   rq   )clsr`   urlpartsr9   rs   r4   s         r(   FromUrlz_UrlBuilder.FromUrl   s~    <<((-||,,X^^<<<**OOX__b$,> ? +MN 	Nr'   c                 r    t         j                  j                  | j                  | j                  dddf      S )Nr/   )r   r]   rw   rn   rp   rr   s    r(   rs   z_UrlBuilder.base_url   s/    ||&&]]DMM2r268 	8r'   c                     t         j                  j                  |      }|j                  s|j                  s|j
                  rt        j                  d|z        |j                  | _	        |j                  | _        y )NzInvalid base url: %s)r   r]   rg   rq   rk   rh   r   ri   rm   rn   ro   rp   )rr   valuert   s      r(   rs   z_UrlBuilder.base_url   sb    \\**51
??j..*2E2E44&.0 0"))"))r'   c                 V    t         j                  j                  | j                  d      S )NT)r   r]   	urlencoder9   r|   s    r(   rk   z_UrlBuilder.query   s!     ||%%d&7&7>>r'   c                    d| j                   v sd| j                   v r"t        j                  d| j                   z        t        j                  j                  | j                  | j                  | j                   | j                  df      S )N{}z'Cannot create url with relative path %sr/   )	r4   r   ri   r   r]   rw   rn   rp   rk   r|   s    r(   r`   z_UrlBuilder.url   s|    $$$$t/A/A(A449D<N<NNP P||&&MM4==$*<*<djj"(N O 	Or'   )NN)r   r   r   r   ru   classmethodrz   propertyrs   setterrk   r`   r&   r'   r(   re   re      sv    ,3 N N 8 8 __* * ? ? O Or'   re   c                       y)z0Hook for skipping credentials. For internal use.Fr&   r&   r'   r(   _SkipGetCredentialsr      s    r'   c                      e Zd ZdZdZdZdZdZdZg Z	dZ
	 	 	 	 	 	 ddZd Zed        Zed        Zed        Zed	        Zed
        Zed        Zed        Zed        Zd Zed        Zej4                  d        Zed        Zej4                  d        Zed        Zej>                  d        Zed        Z e j>                  d        Z ej4                  d        Z!d Z"d Z#d Z$d Z%d Z&d Z'y)r   z Base class for client libraries.Nr/   c                 Z   t        | d       | t        j                  || j                         || _        || _        || _        d| _        d| _        || _	        |	| _
        || _        |xr t                }|r|s|
xs i }
 | j                  di |
 t        |      | _        |xs t!        j"                         | _        | j                  *| j                  j'                  | j$                        | _        d | _        |xs i | _        || _        || _        || _        d| _        |}d| _        y )N)_package_scopesrJ   r   <   Fprotor&   )rW   r
   	Typecheckparams_type%_BaseApiClient__default_global_paramslog_requestlog_response_BaseApiClient__num_retries_BaseApiClient__max_retry_waitnum_retriesmax_retry_wait_credentialsr   _SetCredentialsr   _urlr	   GetHttp_http	authorize_BaseApiClient__include_fieldsadditional_http_headerscheck_response_func
retry_funcresponse_encoding(overwrite_transfer_urls_with_client_base#_BaseApiClient__response_type_model)rr   r`   credentialsget_credentialshttpmodelr   r   r   r   credentials_argsdefault_global_paramsr   r   r   r   rK   s                    r(   ru   zBaseApiClient.__init__   s-    	4!KL ,NN0$2B2BC'<$&( "&,')G2E2G.G;/52 D  4#34(-	3\113
(**44TZZ@DJ $'>'D"$#6 $!2 9>5 %,"r'   c                     | j                   | | j                  | j                  | j                  | j                  | j
                  d}|j                  |       ddlm}  |j                  di || _
        y)aF  Fetch credentials, and set them for this client.

        Note that we can't simply return credentials, since creating them
        may involve side-effecting self.

        Args:
          **kwds: Additional keyword arguments are passed on to GetCredentials.

        Returns:
          None. Sets self._credentials.
        )api_keyclient	client_idclient_secretpackage_namescopes
user_agentr   )credentials_libNr&   )_API_KEY
_CLIENT_ID_CLIENT_SECRET_PACKAGE_SCOPES_USER_AGENTrl   apitools.base.pyr   GetCredentialsr   )rr   kwdsargsr   s       r(   r   zBaseApiClient._SetCredentials  sg     }}!00 MMll**
 	D4 ;O::BTBr'   c           	          | j                   | j                  dj                  t        t	        j
                  | j                                    | j                  dS )N )r   r   scoper   )r   r   joinsortedr
   NormalizeScopesr   r   rx   s    r(   
ClientInfozBaseApiClient.ClientInfo=  sE      //XXfT%9%9#++%FGH//	
 	
r'   c                      y Nr&   r|   s    r(   base_model_classzBaseApiClient.base_model_classF  s    r'   c                     | j                   S r   )r   r|   s    r(   r   zBaseApiClient.httpJ  s    zzr'   c                     | j                   S r   )r   r|   s    r(   r`   zBaseApiClient.urlN  s    yyr'   c                     | j                   S r   )r   r   s    r(   	GetScopeszBaseApiClient.GetScopesR  s    {{r'   c                 .    t        d| j                        S )NStandardQueryParameters)rM   MESSAGES_MODULEr|   s    r(   r   zBaseApiClient.params_typeV  s    3T5I5IJJr'   c                     | j                   S r   )r   r|   s    r(   r   zBaseApiClient.user_agentZ  s    r'   c                 \    | j                   | j                         | _         | j                   S r   )r   r   r|   s    r(   _default_global_paramsz$BaseApiClient._default_global_params^  s+    ''/+/+;+;+=D(+++r'   c                 6    | j                   }t        |||       y r   )r   setattr)rr   rI   r~   paramss       r(   AddGlobalParamzBaseApiClient.AddGlobalParame  s    ,,e$r'   c                 @    t        j                  | j                        S r   )r   CopyProtoMessager   r|   s    r(   global_paramszBaseApiClient.global_paramsi  s    (()D)DEEr'   c              #   0   K   || _         d  d | _         y wr   )r   )rr   include_fieldss     r(   IncludeFieldszBaseApiClient.IncludeFieldsm  s      . $s   c                     | j                   S r   )r   r|   s    r(   response_type_modelz!BaseApiClient.response_type_models  s    )))r'   c              #   H   K   | j                   }d| _        d || _        yw)z2In this context, return raw JSON instead of proto.jsonN)r   r   )rr   	old_models     r(   JsonResponseModelzBaseApiClient.JsonResponseModelw  s&      ,,	%+"%."    "c                     | j                   S r   )r   r|   s    r(   r   zBaseApiClient.num_retries  s    !!!r'   c                     t        j                  |t        j                         |dk  rt	        j
                  d      || _        y )Nr   z*Cannot have negative value for num_retries)r
   r   sixinteger_typesr   InvalidDataErrorr   rr   r~   s     r(   r   zBaseApiClient.num_retries  s;    uc//019--<> >"r'   c                     | j                   S r   )r   r|   s    r(   r   zBaseApiClient.max_retry_wait  s    $$$r'   c                     t        j                  |t        j                         |dk  rt	        j
                  d      || _        y )Nr   z)max_retry_wait must be a postiive integer)r
   r   r   r   r   r   r   r   s     r(   r   zBaseApiClient.max_retry_wait  s;    uc//0A:--;= = %r'   c              #   H   K   | j                   }|| _         d  || _         y wr   )r   )rr   r   old_num_retriess      r(   WithRetrieszBaseApiClient.WithRetries  s$     **&*r   c                 v    | j                   r,t        j                  d|j                  |j                  |       |S )z$Hook for pre-processing of requests.zCalling method %s with %s: %s)r   logginginfor6   r<   )rr   method_configrequests      r(   ProcessRequestzBaseApiClient.ProcessRequest  s4    LL/1H1H//: r'   c                    |j                   j                  | j                         | j                  rt	        j
                  d|j                  |j                         t	        j
                  dt        j                  |j                                |j                  r0t	        j
                  d|j                  xs |j                         |S t	        j
                  d       |S )z)Hook for pre-processing of http requests.zMaking http %s to %szHeaders: %szBody:
%szBody: (none))headersrl   r   r   r   r   r7   r`   pprintpformatbodyloggable_body)rr   http_requests     r(   ProcessHttpRequestz BaseApiClient.ProcessHttpRequest  s    ##D$@$@ALL/%11<3C3CELL|7K7K(LM   [)77L<;L;LN  ^,r'   c                 `    | j                   r!t        j                  d|j                  |       |S )NzResponse of type %s: %s)r   r   r   r=   )rr   r   responses      r(   ProcessResponsezBaseApiClient.ProcessResponse  s+    LL2&998Er'   c                 D    t        j                  || j                        S )N)r   )r   MessageToJsonr   )rr   messages     r(   SerializeMessagezBaseApiClient.SerializeMessage  s     %%D$9$9; 	;r'   c           	          	 t        j                  ||      }|S # t        j                  t        j
                  t        f$ r-}t        j                  d|d|j                  d|      d}~ww xY w)z:Deserialize the given data as method_config.response_type.zError decoding response "z
" as type z: N)r   JsonToMessager   InvalidDataFromServerErrorr   ValidationError
ValueErrorr   )rr   response_typedatar  es        r(   DeserializeMessagez BaseApiClient.DeserializeMessage  sm    	6,,]DAG  55((*6 	677-00!56 6	6s    (A/(A**A/c                 0   t         j                  |      }t        | j                  dd      r#| j                  j                  |j
                  d<   | j                  r0t         j                  | j                        }|j                  |_        |j                  S )z?Modify the url for a given transfer, based on auth and version.keyN)
re   rz   rG   r   r  r9   r   r   rs   r`   )rr   r`   url_builderclient_url_builders       r(   FinalizeTransferUrlz!BaseApiClient.FinalizeTransferUrl  sv    !))#.4%%ud3.2.@.@.D.DK$$U+88!,!4!4TYY!?#5#>#>K r'   )NTNNFFr   r   NNNNNN)(r   r   r   r   r   r   r   r   r   r   r   ru   r   r   r   r   r   r   r`   r   r   r   r   r   r   
contextlibcontextmanagerr   r   r   r   r   r   r   r   r   r   r  r  r  r&   r'   r(   r   r      s   *OHJNHGKIM=BDHEI6:#')-VC> 
 
         K K     , ,% F F % %
 * * / / " " # # % % & & + + ;	r'   r   c                       e Zd ZdZd Zed        Zed        Zd Ze	d        Z
d Zd Zd	 Zd
 Zd Zd Zd Z	 ddZd Zd Zd Zd Zd Z	 	 ddZ	 	 ddZddZy)r   z&Base class for generated API services.c                 .    || _         i | _        i | _        y r   )_BaseApiService__client_method_configs_upload_configs)rr   r   s     r(   ru   zBaseApiService.__init__  s    !!r'   c                     | j                   S r   r  r|   s    r(   _clientzBaseApiService._client      }}r'   c                     | j                   S r   r  r|   s    r(   r   zBaseApiService.client  r  r'   c                     | j                   j                  |      }|r|S t        | |d      }|t        |      t        |dd      }|t        |       |       x| j                   |<   }|S )z6Returns service cached method config for given method.Nr   )r  getrG   KeyError)rr   methodr   funcconfigs        r(   GetMethodConfigzBaseApiService.GetMethodConfig  sz    ,,008  tVT*<6""ot< 6""0=?V$vr'   c                     t        j                  | j                        D cg c]  }t        |dd       r|j                   c}S c c}w )Nr   )r   
itervalues__dict__rG   r   )rx   fs     r(   GetMethodsListzBaseApiService.GetMethodsList  sD    $'NN3<<$@ 6$@q1ot4 

$@ 6 	6 6s    Ac                 8    | j                   j                  |      S r   )r  r  )rr   r!  s     r(   GetUploadConfigzBaseApiService.GetUploadConfig  s    ##''//r'   c                 x    | j                  |      }t        | j                  j                  |j                        S r   )r$  rG   r   r   r<   rr   r!  r   s      r(   GetRequestTypezBaseApiService.GetRequestType  s4    ,,V4t{{22$668 	8r'   c                 x    | j                  |      }t        | j                  j                  |j                        S r   )r$  rG   r   r   r=   r-  s      r(   GetResponseTypezBaseApiService.GetResponseType  s4    ,,V4t{{22$779 	9r'   c                    t        j                  |t        d      | j                  j                  f       | j                  j	                         }|xs | j                  j	                         }|j                         D ]Y  }|j                  |j                        }||j                  |j                        }|dg dfvsCt        ||j                  |       [ |S )z+Combine the given params with the defaults.Nr&   )	r
   r   rQ   r  r   
all_fieldsget_assigned_valuerI   r   )rr   r   default_paramsresultfieldr~   s         r(   __CombineGlobalParamsz$BaseApiService.__CombineGlobalParams  s    }tDz4==3L3L&MN**,%D)B)B)D&&(E!44UZZ@E}&99%**ET2rN*

E2 ) r'   c                 b    |j                  dd      sd|d<   |j                  dd      sd|d<   |S )NprettyPrintTr   pp)pop)rr   
query_infos     r(   __EncodePrettyPrintz"BaseApiService.__EncodePrettyPrint  s<     ~~mT2()J}% ~~dD) Jtr'   c                 h   t        |t        j                        r|t        j                  |      S t        |t
        j                        r|j                  d      S t        |t
        j                        r|j                  d      S t        |t        j                        r|j                         S |S )zAEncode value for the URL, using field to skip encoding for bytes.utf8)
isinstancer   
BytesFieldbase64urlsafe_b64encoder   	text_typeencodebinary_typedecodedatetime	isoformat)rr   r~   r6  s      r(   __FinalUrlValuezBaseApiService.__FinalUrlValue   s    eX001e6G++E22s}}-<<''s/<<''x001??$$r'   c                    	  j                   j                  j                        t        j                   j                  j
                  j                         D cg c]  }|j                   c} j                  j
                        }t              t         fd|D              }t        j                  |t                    }t              	|j                  	 fd|D               t        d |j                         D              } j                  |      }t        j                  |t                    }|S c c}w )z<Construct a dictionary of query parameters for this request.c           	   3   n   K   | ],  }|j                  t        |      t        |            f . y wr   _BaseApiService__FinalUrlValuerG   ).0paramr   global_params_typerr   s     r(   	<genexpr>z8BaseApiService.__ConstructQueryParams.<locals>.<genexpr>5  sF      - , !!'-"?")*<e"DFG ,s   25c           	   3   p   K   | ]-  }|j                  t        |d       t        |            f / y wr   rM  )rO  rP  r   request_typerr   s     r(   rR  z8BaseApiService.__ConstructQueryParams.<locals>.<genexpr>=  sG      , + !!''5$"?"),">@A +s   36c              3   .   K   | ]  \  }}|||f  y wr   r&   )rO  kvs      r(   rR  z8BaseApiService.__ConstructQueryParams.<locals>.<genexpr>B  s%      ,-?TQ] a&-?s   )$_BaseApiService__CombineGlobalParamsr  r   r
   MapParamNamesr   r2  rI   rQ   dictrl   items"_BaseApiService__EncodePrettyPrintMapRequestParams)
rr   r9   r   r   xglobal_param_namesr<  query_param_namesrQ  rT  s
   ` ``    @@r(   __ConstructQueryParamsz%BaseApiService.__ConstructQueryParams,  s%    224==668!//!]]66AACDCQVVCDMM%%' "-0 - ,	- -
 !..|T']KG} , +	, 	,
  ,Z-=-=-? , ,
--j9
**:tG}E
) Es   !E	Nc                    t        j                  |j                  t        |            }t	        |D cg c]  }|t        ||d      f c}      }t        j                  |t        |            }t        j                  |||      S c c}w )z(Determine the relative path for request.Nr4   )r
   rY  r8   rQ   rZ  rG   r]  ExpandRelativePath)rr   r   r   r4   python_param_namesrP  r   s          r(   __ConstructRelativePathz&BaseApiService.__ConstructRelativePathH  s     "//%%tG}6$68$65 wwt<=$68 9&&vtG}=&&}f5BD 	D8s   Bc                     |j                   dk(  rYt        |j                        t        kD  r=d|_         d|j                  d<   d|j                  d<   |j
                  |_        i |_        |j                  |_        y)z2Make any final general adjustments to the request.GETPOSTzx-http-method-overridez!application/x-www-form-urlencodedcontent-typeN)r7   lenr`   _MAX_URL_LENGTHr   rk   r   r9   )rr   r   r  s      r(   __FinalizeRequestz BaseApiService.__FinalizeRequestS  st    $$-L$$%7'-L$=BL  !9:"E     + 1 1L')K$&??r'   c                    |j                   t        j                  t        j                  t        j                  fvr"t
        j                  j                  |||      |j                   t        j                  k(  r,t        j                  |j                  d|j                        }|j                  }| j                  j                  r5t        |t               r%|j#                  | j                  j                        }| j$                  j&                  dk(  r|S t)        |j*                  | j$                  j,                        }| j$                  j/                  ||      S )z Process the given http response.)r   r   z{})r   contentrequest_urlr   )status_coder   OKCREATED
NO_CONTENTr   	HttpErrorFromResponser	   Responser   rp  ro  r  r   r@  bytesrG  r  r   rM   r=   r   r  )rr   r   http_responser   ro  r	  s         r(   __ProcessHttpResponsez$BaseApiService.__ProcessHttpResponse_  s   $$[^^-8-@-@-8-C-C-E E &&33]G 4 M M$$(>(>> )11"'')557M  ''<<))j%.HnnT\\%C%CDG==,,6N"=#C#C#'==#@#@B}}//wGGr'   c                 ~    |j                   xs d}||j                  d<   d|j                  d<   d|j                  d<   y)z*Fill in the basic headers on http_request.zapitools-client/1.0z
user-agentapplication/jsonr   zgzip, deflatezaccept-encodingN)r   r   )rr   r   r   r   s       r(   __SetBaseHeaderszBaseApiService.__SetBaseHeadersw  sF     &&?*?
-7\*);X&2A./r'   c                 P    |j                   r|j                   |j                  d<   yy)z;Fill in the system parameters to always set for the method.zX-Goog-Api-VersionN)rB   r   )rr   r   r   s      r(   __SetBaseSystemParamsz$BaseApiService.__SetBaseSystemParams  s*    		(	(-- 

3
4 
)r'   c                    |j                   syt        |j                  | j                  j                        }|j                   t
        k(  r|}|}nat        ||j                         }|j                  |j                         }t        j                  |t        j                         |j                  }|xs  |       }|r|syt        j                  ||       d|j                  d<   | j                  j                  |      |_        y)z!Fill in the body on http_request.Nr|  rj  )r>   rM   r<   r  r   REQUEST_IS_BODYrG   field_by_namer
   r   r   r?   rQ   r   r  r   )	rr   r   r   r   uploadrT  
body_value	body_type
body_fields	            r(   	__SetBodyzBaseApiService.__SetBody  s    **!++T]]-J-JL&&/9 J$I -*E*EFJ%33++-JNN:x'<'<="I  .9;
*z9-/A^, MM:::Fr'   c                 
   t        |j                  | j                  j                        }t	        j
                  ||       | j                  j                  ||      }t        j                  |j                        }| j                  || j                         | j                  ||       | j                  ||||       t        | j                  j                  |j                        }	| j!                  |j"                  ||      |	_        ||j%                  |||	       ||j%                  ||	       | j'                  |||	j                        |	_        | j)                  ||	       | j                  j+                  |      S )z$Prepares an HTTP request to be sent.)r7   rc  )rM   r<   r  r   r
   r   r   r	   Requestr7   _BaseApiService__SetBaseHeaders$_BaseApiService__SetBaseSystemParams_BaseApiService__SetBodyre   r`   r4   %_BaseApiService__ConstructQueryParamsr9   ConfigureRequest&_BaseApiService__ConstructRelativePath _BaseApiService__FinalizeRequestr   )
rr   r   r   r   r  r@   downloadrT  r   r  s
             r(   PrepareHttpRequestz!BaseApiService.PrepareHttpRequest  sT    "++T]]-J-JLw---..}gF#++%113lDMM:""<?|]GVD!MM]-H-HJ#'#>#>&&$@ 
 ##M<M%%lK@$($@$@7+2K2K %A %M!|[9}}//==r'   c                    ||t        j                  d      | j                  ||||||      }||j                  || j                         yd}||j                  || j                        }|| j                  j                  }	|r|j                  r|j                  }	| j                  j                  | j                  j                  d}
| j                  j                  r| j                  j                  |
d<   | j                  j                  r| j                  j                  |
d<   t        j                  |	|fi |
}| j                  |||      S )zCall this method with request.Nz/Cannot yet use both upload and download at once)r   )retriesr   r   r   )r   NotYetImplementedErrorr  InitializeDownloadr   InitializeUploadr  r   
bytes_httpr   r   r   r   r	   MakeRequestProcessHttpResponse)rr   r   r   r   r  r@   r  r   ry  r   optss              r(   
_RunMethodzBaseApiService._RunMethod  sY    ("6 33AC C ..7M6= ''T[['I"33T[[ 4 2M ==%%D&++((==44"&--">">D }}00.2mm.O.O*+}}''%)]]%=%=\"(44l,&*,M ''}gNNr'   c                 \    | j                   j                  || j                  |||            S )z6Convert an HTTP response to the expected message type.)r  r   $_BaseApiService__ProcessHttpResponse)rr   r   ry  r   s       r(   r  z"BaseApiService.ProcessHttpResponse  s0    }},,&&}mWMO 	Or'   r   )NNNN)r   r   r   r   ru   r   r  r   r$  r   r)  r+  r.  r0  rX  r\  rN  r  r  r  r  r  r  r  r  r  r  r&   r'   r(   r   r     s    0"
     6 608
9
	
: /3	D
+H0B/G6 HLEI>@ @D=A*OXOr'   r   )$r   rB  r  rH  r   r   r   	six.movesr   r   apitools.base.protorpcliter   r   r   r   r   r	   r
   __all__	getLoggersetLevelERRORrl  Messager   r   r  rM   rW   r   rc   objectre   r   r   r   r&   r'   r(   <module>r     s   " #       !  5 / % ' ) !   % & / / >0H$$ 00+1H$$ +1\ I7"7O& 7Ot
mF m`ZOV ZOr'   