HEX
Server: LiteSpeed
System: Linux us-phx-web629.main-hosting.eu 5.14.0-503.23.2.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 12 05:52:18 EST 2025 x86_64
User: u756937133 (756937133)
PHP: 8.2.27
Disabled: passthru,chgrp
Upload Files
File: //opt/gsutil/third_party/apitools/apitools/base/py/__pycache__/base_api.cpython-39.pyc
a

�z�g,u�@s6dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddl
mZddl
mZddl
mZdd	l
mZdd
l
mZgd�Ze�d��ej�d
ZGdd�dej�ZGdd�dej�ZdZdd�Zdd�Zdd�Zdd�ZGdd�de�Z dd�Z!Gdd �d e�Z"Gd!d"�d"e�Z#dS)#zBase class for api services.�N)�http_client)�urllib)�
message_types)�messages)�encoding)�
exceptions)�http_wrapper)�util)�
ApiMethodInfo�
ApiUploadInfo�
BaseApiClient�BaseApiService�NormalizeApiEndpointzoauth2client.utilic@sPeZdZdZejddd�Ze�d�Ze�d�Z	e�
d�Ze�d�Ze�
d	�Z
d
S)raTMedia 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_sizeZresumable_path�BooleanFieldZresumable_multipartZsimple_pathZsimple_multipart�r r �=/opt/gsutil/third_party/apitools/apitools/base/py/base_api.pyr5s



rc@s�eZdZdZe�d�Ze�d�Ze�d�Ze�d�Z	ejddd�Z
ejd	dd�Zejd
dd�Ze�d�Z
e�d�Ze�d
�Zejddd�Ze�ed�Zejddd�Ze�d�ZdS)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.
    rrrrrTrr���	�
��)�default��
F�N)rrrrrr�
relative_pathZ	flat_path�	method_id�http_method�path_params�query_paramsZordered_params�description�request_type_name�response_type_name�
request_field�MessageFieldr�
upload_configrZsupports_download�api_version_paramr r r r!r
Ms






r
z	<request>cCsH|�d�r$|�d�\}}}tt|�Sd|vr6t||�St�d|��dS)Nzmessage_types.�.zUnknown class %s)�
startswith�	partition�getattrrr�GeneratedClientError)�name�messages_module�_�	classnamer r r!�
_LoadClass~s


rAcCsJ|D]@}|��}t|d|�r(t||�sd|t|�jf}t�|��qdS)Nz%sz'No %s specified for object of class %s.)�upper�hasattrr;�typerrr<)�obj�attrs�attr�	attr_name�msgr r r!�_RequireClassAttrs�s
�rJcCs|�d�s|d7}|S)N�/)�endswith)Zapi_endpointr r r!r�s
rcCsZ|�d�s|�d�r"tj�||�S|�d�r0|n|d}|�d�rN|dd�n|}||S)z8Custom urljoin replacement supporting : before / in url.zhttp://zhttps://rKrN)r9r�parse�urljoinrL)�base�url�new_base�new_urlr r r!�_urljoin�s

rSc@sXeZdZdZddd�Zedd��Zedd��Zej	d	d��Zed
d��Z
edd
��ZdS)�_UrlBuilderz"Convenient container for url data.NcCsttj�t||pd��}|jr,t�d|j��tj�|jp:d�|_	|durT|j	�
|�|j|_|j
|_|jpld|_dS)Nr'zUnexpected url fragment: %s)rrM�urlsplitrS�fragmentr�ConfigurationValueError�parse_qs�queryr0�update�scheme�_UrlBuilder__scheme�netloc�_UrlBuilder__netloc�pathr,)�self�base_urlr,r0�
componentsr r r!�__init__�s��z_UrlBuilder.__init__cCsLtj�|�}tj�|j�}tj�|j|jdddf�}|jp<d}||||d�S)Nr')r,r0)	rrMrUrXrY�
urlunsplitr[r]r_)�clsrP�urlpartsr0rar,r r r!�FromUrl�s�
�z_UrlBuilder.FromUrlcCstj�|j|jdddf�S)Nr')rrMrdr\r^�r`r r r!ra�s�z_UrlBuilder.base_urlcCs@tj�|�}|js|js|jr,t�d|��|j|_	|j
|_dS)NzInvalid base url: %s)rrMrUr_rYrVrrWr[r\r]r^)r`�valuerbr r r!ra�s�cCstj�|jd�S)NT)rrM�	urlencoder0rhr r r!rY�sz_UrlBuilder.querycCsBd|jvsd|jvr$t�d|j��tj�|j|j|j|jdf�S)N�{�}z'Cannot create url with relative path %sr')	r,rrWrrMrdr\r^rYrhr r r!rP�s��z_UrlBuilder.url)NN)rrrrrc�classmethodrg�propertyra�setterrYrPr r r r!rT�s


	


rTcCsdS)z0Hook for skipping credentials. For internal use.Fr r r r r!�_SkipGetCredentials�srpc@sLeZdZdZdZdZdZdZdZgZ	dZ
d:dd	�Zd
d�Ze
dd
��Zedd��Zedd��Zedd��Ze
dd��Zedd��Zedd��Zedd��Zdd�Zedd��Zejd d!��Zed"d#��Zejd$d%��Zed&d'��Zejd(d'��Zed)d*��Z e jd+d*��Z ejd,d-��Z!d.d/�Z"d0d1�Z#d2d3�Z$d4d5�Z%d6d7�Z&d8d9�Z'dS);rz Base class for client libraries.Nr'TFr�<cCs�t|d�|dur t�||j�||_||_||_d|_d|_||_	|	|_
||_|oZt�}|r||s||
pji}
|j
fi|
��t|�|_|p�t��|_|jdur�|j�|j�|_d|_|p�i|_|
|_||_||_d|_|}d|_dS)N)Z_packageZ_scopesr>rrqF�proto)rJr	�	Typecheck�params_type�%_BaseApiClient__default_global_params�log_request�log_response�_BaseApiClient__num_retries�_BaseApiClient__max_retry_wait�num_retries�max_retry_wait�_credentialsrp�_SetCredentialsr�_urlrZGetHttp�_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)r`rP�credentials�get_credentials�http�modelrvrwrzr{Zcredentials_argsZdefault_global_paramsr�r�r�r�r?r r r!rc�s6



zBaseApiClient.__init__cKsL|j||j|j|j|j|jd�}|�|�ddlm}|j	fi|��|_
dS)aFFetch 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_libN)�_API_KEY�
_CLIENT_ID�_CLIENT_SECRET�_PACKAGE�_SCOPES�_USER_AGENTrZ�apitools.base.pyr�ZGetCredentialsr|)r`�kwds�argsr�r r r!r}s
�	
zBaseApiClient._SetCredentialscCs&|j|jd�tt�|j���|jd�S)N� )r�r��scoper�)r�r��join�sortedr	ZNormalizeScopesr�r��rer r r!�
ClientInfo=s
�zBaseApiClient.ClientInfocCsdS�Nr rhr r r!�base_model_classFszBaseApiClient.base_model_classcCs|jSr�)rrhr r r!r�JszBaseApiClient.httpcCs|jSr�)r~rhr r r!rPNszBaseApiClient.urlcCs|jSr�)r�r�r r r!�	GetScopesRszBaseApiClient.GetScopescCstd|j�S)N�StandardQueryParameters)rA�MESSAGES_MODULErhr r r!rtVszBaseApiClient.params_typecCs|jSr�)r�rhr r r!r�ZszBaseApiClient.user_agentcCs|jdur|��|_|jSr�)rurtrhr r r!�_default_global_params^s

z$BaseApiClient._default_global_paramscCs|j}t|||�dSr�)r��setattr)r`r=ri�paramsr r r!�AddGlobalParameszBaseApiClient.AddGlobalParamcCst�|j�Sr�)rZCopyProtoMessager�rhr r r!�
global_paramsiszBaseApiClient.global_paramsccs||_dVd|_dSr�)r�)r`�include_fieldsr r r!�
IncludeFieldsmszBaseApiClient.IncludeFieldscCs|jSr�)r�rhr r r!�response_type_modelssz!BaseApiClient.response_type_modelccs|j}d|_dV||_dS)z2In this context, return raw JSON instead of proto.�jsonN)r�r�)r`Z	old_modelr r r!�JsonResponseModelwszBaseApiClient.JsonResponseModelcCs|jSr�)rxrhr r r!rzszBaseApiClient.num_retriescCs*t�|tj�|dkr t�d��||_dS)Nrz*Cannot have negative value for num_retries)r	rs�six�
integer_typesr�InvalidDataErrorrx�r`rir r r!rz�s�cCs|jSr�)ryrhr r r!r{�szBaseApiClient.max_retry_waitcCs*t�|tj�|dkr t�d��||_dS)Nrz)max_retry_wait must be a postiive integer)r	rsr�r�rr�ryr�r r r!r{�s�ccs|j}||_dV||_dSr�)rz)r`rzZold_num_retriesr r r!�WithRetries�szBaseApiClient.WithRetriescCs|jrt�d|j|j|�|S)z$Hook for pre-processing of requests.zCalling method %s with %s: %s)rv�logging�infor-r2)r`�
method_config�requestr r r!�ProcessRequest�s�zBaseApiClient.ProcessRequestcCsd|j�|j�|jr`t�d|j|j�t�dt�	|j��|j
rVt�d|jpP|j
�n
t�d�|S)z)Hook for pre-processing of http requests.zMaking http %s to %szHeaders: %szBody:
%szBody: (none))�headersrZr�rvr�r�r.rP�pprint�pformat�bodyZ
loggable_body)r`�http_requestr r r!�ProcessHttpRequest�s�
�
z BaseApiClient.ProcessHttpRequestcCs|jrt�d|j|�|S)NzResponse of type %s: %s)rwr�r�r3)r`r��responser r r!�ProcessResponse�s
�zBaseApiClient.ProcessResponsecCstj||jd�S)N)r�)rZ
MessageToJsonr�)r`�messager r r!�SerializeMessage�s�zBaseApiClient.SerializeMessagec
CsZzt�||�}WnDtjtjtfyT}z"t�d||j|f��WYd}~n
d}~00|S)z:Deserialize the given data as method_config.response_type.z+Error decoding response "%s" as type %s: %sN)rZ
JsonToMessagerZInvalidDataFromServerErrorr�ValidationError�
ValueErrorr)r`�
response_type�datar��er r r!�DeserializeMessage�s���z BaseApiClient.DeserializeMessagecCsFt�|�}t|jdd�r&|jj|jd<|jr@t�|j�}|j|_|j	S)z?Modify the url for a given transfer, based on auth and version.�keyN)
rTrgr;r�r�r0r�r~rarP)r`rP�url_builderZclient_url_builderr r r!�FinalizeTransferUrl�s
z!BaseApiClient.FinalizeTransferUrl)NTNNFFrrqNNNNNN)(rrrrr�r�r�r�r�r�r�rcr}rmr�rnr�r�rPr�rtr�r�r�r��
contextlib�contextmanagerr�r�r�rzror{r�r�r�r�r�r�r�r r r r!r�sr�
+
















rc@s�eZdZdZdd�Zedd��Zedd��Zdd	�Ze	d
d��Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd-dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd.d'd(�Zd/d)d*�Zd0d+d,�ZdS)1r
z&Base class for generated API services.cCs||_i|_i|_dSr�)�_BaseApiService__client�_method_configs�_upload_configs)r`r�r r r!rc�szBaseApiService.__init__cCs|jSr��r�rhr r r!�_client�szBaseApiService._clientcCs|jSr�r�rhr r r!r��szBaseApiService.clientcCs`|j�|�}|r|St||d�}|dur0t|��t|dd�}|durLt|��|�|j|<}|S)z6Returns service cached method config for given method.Nr�)r��getr;�KeyError)r`�methodr��func�configr r r!�GetMethodConfig�szBaseApiService.GetMethodConfigcCsdd�t�|j�D�S)NcSsg|]}t|dd�r|j�qS)r�N)r;r)�.0�fr r r!�
<listcomp>�s�z1BaseApiService.GetMethodsList.<locals>.<listcomp>)r��
itervalues�__dict__r�r r r!�GetMethodsList�szBaseApiService.GetMethodsListcCs|j�|�Sr�)r�r�)r`r�r r r!�GetUploadConfig�szBaseApiService.GetUploadConfigcCs|�|�}t|jj|j�Sr�)r�r;r�r�r2�r`r�r�r r r!�GetRequestType�s
�zBaseApiService.GetRequestTypecCs|�|�}t|jj|j�Sr�)r�r;r�r�r3r�r r r!�GetResponseTypes
�zBaseApiService.GetResponseTypecCs~t�|td�|jjf�|j��}|p.|j��}|��D]@}|�|j�}|dur\|�|j�}|dgdfvr8t||j|�q8|S)z+Combine the given params with the defaults.Nr )	r	rsrDr�rt�
all_fields�get_assigned_valuer=r�)r`r�Zdefault_params�result�fieldrir r r!Z__CombineGlobalParamss
z$BaseApiService.__CombineGlobalParamscCs,|�dd�sd|d<|�dd�s(d|d<|S)N�prettyPrintTr�pp)�pop)r`�
query_infor r r!Z__EncodePrettyPrints
z"BaseApiService.__EncodePrettyPrintcCsbt|tj�r|durt�|�St|tj�r4|�d�St|tj�rJ|�	d�St|t
j
�r^|��S|S)zAEncode value for the URL, using field to skip encoding for bytes.N�utf8)�
isinstancer�
BytesField�base64�urlsafe_b64encoder��	text_type�encode�binary_type�decode�datetime�	isoformat)r`rir�r r r!Z__FinalUrlValue s


zBaseApiService.__FinalUrlValuecs�����jj��t�dd��jj��D��jj�}t���t���fdd�|D��}t�|t���}t���|�	���fdd�|D��tdd�|�
�D��}��|�}t�|t���}|S)z<Construct a dictionary of query parameters for this request.cSsg|]
}|j�qSr )r=)r��xr r r!r�2�z9BaseApiService.__ConstructQueryParams.<locals>.<listcomp>c3s*|]"}|��t�|�t�|��fVqdSr���_BaseApiService__FinalUrlValuer;�r��param)r��global_params_typer`r r!�	<genexpr>5s���z8BaseApiService.__ConstructQueryParams.<locals>.<genexpr>c3s,|]$}|��t�|d�t�|��fVqdSr�r�r�)r��request_typer`r r!r=s���css"|]\}}|dur||fVqdSr�r )r��k�vr r r!rBs
�)
�$_BaseApiService__CombineGlobalParamsr�r�r	�
MapParamNamesrtr�rD�dictrZ�items�"_BaseApiService__EncodePrettyPrint�MapRequestParams)r`r0r�r�Zglobal_param_namesr�Zquery_param_namesr )r�r�r�rr`r!Z__ConstructQueryParams,s(����
z%BaseApiService.__ConstructQueryParamsNcsHt�|jt���}t�fdd�|D��}t�|t���}tj|||d�S)z(Determine the relative path for request.csg|]}|t�|d�f�qSr�)r;r��r�r r!r�Ms�z:BaseApiService.__ConstructRelativePath.<locals>.<listcomp>�r,)r	rr/rDrr	ZExpandRelativePath)r`r�r�r,Zpython_param_namesr�r r
r!Z__ConstructRelativePathHs
���z&BaseApiService.__ConstructRelativePathcCsL|jdkr@t|j�tkr@d|_d|jd<d|jd<|j|_i|_|j|_dS)z2Make any final general adjustments to the request.�GET�POSTzx-http-method-overridez!application/x-www-form-urlencoded�content-typeN)r.�lenrP�_MAX_URL_LENGTHr�rYr�r0)r`r�r�r r r!Z__FinalizeRequestSs
�
��z BaseApiService.__FinalizeRequestcCs�|jtjtjtjfvr(tjj|||d��|jtjkrHtj	|j
d|jd�}|j}|j
jrnt|t�rn|�|j
j�}|jjdkr~|St|j|jj�}|j�||�S)z Process the given http response.)r�r�z{})r��content�request_urlr�)�status_coder�OK�CREATED�
NO_CONTENTr�	HttpError�FromResponser�Responser�rrr�r�r��bytesr�r�r�rAr3r�r�)r`r��
http_responser�rr�r r r!Z__ProcessHttpResponse_s*����z$BaseApiService.__ProcessHttpResponsecCs,|jpd}||jd<d|jd<d|jd<dS)z*Fill in the basic headers on http_request.zapitools-client/1.0z
user-agent�application/jsonrz
gzip, deflatezaccept-encodingN)r�r�)r`r�r�r�r r r!Z__SetBaseHeadersws


zBaseApiService.__SetBaseHeaderscCs|jr|j|jd<dS)z;Fill in the system parameters to always set for the method.zX-Goog-Api-VersionN)r7r�)r`r�r�r r r!Z__SetBaseSystemParams�s�z$BaseApiService.__SetBaseSystemParamsc	Cs�|js
dSt|j|jj�}|jtkr.|}|}n,t||j�}|�|j�}t�	|t
j�|j}|pb|�}|rp|spdSt�	||�d|j
d<|j�|�|_dS)z!Fill in the body on http_request.Nrr)r4rAr2r�r��REQUEST_IS_BODYr;�
field_by_namer	rsrr5rDr�r�r�)	r`r�r�r��uploadrZ
body_valueZ	body_typeZ
body_fieldr r r!Z	__SetBody�s(
�
�

zBaseApiService.__SetBodyc
Cs�t|j|jj�}t�||�|j�||�}tj|j	d�}|�
||j�|�||�|�||||�t
|jj|jd�}	|�|j||�|	_|dur�|�|||	�|dur�|�||	�|j|||	jd�|	_|�||	�|j�|�S)z$Prepares an HTTP request to be sent.)r.rN)rAr2r�r�r	rsr�r�Requestr.�_BaseApiService__SetBaseHeaders�$_BaseApiService__SetBaseSystemParams�_BaseApiService__SetBodyrTrPr,�%_BaseApiService__ConstructQueryParamsr0ZConfigureRequest�&_BaseApiService__ConstructRelativePath� _BaseApiService__FinalizeRequestr�)
r`r�r�r�rr6�downloadrr�r�r r r!�PrepareHttpRequest�s4
��
���z!BaseApiService.PrepareHttpRequestcCs�|dur|durt�d��|�||||||�}|durJ|j||jd�dSd}|durf|j||jd�}|dur�|jj}	|r�|jr�|j}	|jj	|jj
d�}
|jjr�|jj|
d<|jjr�|jj|
d<t
j|	|fi|
��}|�|||�S)zCall this method with request.Nz/Cannot yet use both upload and download at once)r�)Zretriesr{r�r�)rZNotYetImplementedErrorr(ZInitializeDownloadr�ZInitializeUploadr�r�Z
bytes_httprzr{r�r�rZMakeRequest�ProcessHttpResponse)r`r�r�r�rr6r'r�rr��optsr r r!�
_RunMethod�sB�
��
���zBaseApiService._RunMethodcCs|j�||�|||��S)z6Convert an HTTP response to the expected message type.)r�r��$_BaseApiService__ProcessHttpResponse)r`r�rr�r r r!r)�s�z"BaseApiService.ProcessHttpResponse)N)NNNN)NNNN)N)rrrrrcrnr�r�r�rmr�r�r�r�rrr�r$r%r&r,r!r"r#r(r+r)r r r r!r
�s<



�
	�
 �
,r
)$rr�r�r�r�r�r��	six.movesrr�apitools.base.protorpcliterrr�rrrr	�__all__�	getLogger�setLevel�ERRORr�Messagerr
rrArJrrS�objectrTrprr
r r r r!�<module>s:
.
	:q