File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/googleapiclient/__pycache__/discovery.cpython-310.pyc
Back
o �h% � @ s� d Z ddlmZ dZg d�ZddlmZ ddlZddlZddl m Z ddlmZ dd l mZ ddlmZ ddlZddlZddlZddlZddlZddlZddlZddlZddlZdd lmZ ddlmZ ddl m!Z! ddl"Z"ddl#Z#zddl$Z$W n e%y� dZ$Y nw z dd l&m'Z' dZ(W n e%y� dZ(Y nw ddl)m*Z*m+Z+ ddl,m-Z-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z?m@Z@mAZA ddlBmCZC de"_De�EeF�ZGe�Hd�ZIe�Hd�ZJdZKeKZLdZMdZNeOg d��ZPdddd d!�ZQd"d#d$�ZRd%d&dd'�ZSd(d&dd'�ZTd)ZUd*ZVd+ZWd,ZXd-ZYeOg d.��ZZd&d/d0�Z[G d1d2� d2e\�Z]eOd3g�Z^G d4d5� d5e �Z_d6d7� Z`d8d9� Zae.d:�dddde:dddddddddfd;d<��Zbd=d>� Zc dcd?d@�ZddAdB� Zee.d�ddddde:dddddfdCdD��ZfdEdF� ZgdGdH� ZhdIdJ� ZidKdL� ZjdMdN� ZkdOdP� ZldQdR� ZmdSdT� ZnG dUdV� dVeo�ZpdWdX� Zq Y Z ddd[d\�ZrG d]d^� d^eo�Zsd_d`� Ztdadb� ZudS )ezVClient for discovery based APIs. A client library for Google's discovery based APIs. � )�absolute_importz$jcgregorio@google.com (Joe Gregorio))�build�build_from_document�fix_method_name� key2param)�OrderedDictN)�BytesGenerator)� MIMEMultipart)�MIMENonMultipart)�MutualTLSChannelError)�mtls)�service_account)�universeTF)�_auth� mimeparse)�_add_query_parameter� positional)� HttpError�InvalidJsonError�MediaUploadSizeError�UnacceptableMimeTypeError�UnknownApiNameOrVersion�UnknownFileType)�BatchHttpRequest�HttpMock�HttpMockSequence�HttpRequest�MediaFileUpload�MediaUpload� build_http)� JsonModel� MediaModel�RawModel)�Schemas� z{[^}]*}z[a-zA-Z0-9_-]+zDhttps://www.googleapis.com/discovery/v1/apis/{api}/{apiVersion}/restzAhttps://{api}.googleapis.com/$discovery/rest?version={apiVersion}z)A description of how to use this function)�PUT�POST�PATCH� � � �( )�KB�MB�GB�TBzThe request body.�object)�description�typezOThe filename of the media request body, or an instance of a MediaUpload object.�string)r1 r2 �requiredzPThe MIME type of the media request body, or an instance of a MediaUpload object.)� pageToken� nextPageToken�!GOOGLE_API_USE_CLIENT_CERTIFICATE�GOOGLE_API_USE_MTLS_ENDPOINT�GOOGLE_CLOUD_UNIVERSE_DOMAINzgoogleapis.com)�trace�pp�userip�strict�query)r2 �locationc s e Zd Z� fdd�Z� ZS )�APICoreVersionErrorc s d}t � �|� d S )NzIgoogle-api-core >= 2.18.0 is required to use the universe domain feature.)�super�__init__)�self�message�� __class__� �L/usr/local/CyberCP/lib/python3.10/site-packages/googleapiclient/discovery.pyrB � s �zAPICoreVersionError.__init__)�__name__� __module__�__qualname__rB � __classcell__rG rG rE rH r@ � s r@ �bodyc @ s e Zd ZejZdS )�_BytesGeneratorN)rI rJ rK r �write�_write_linesrG rG rG rH rN � s rN c C s2 | � dd�� dd�} t�| �s| tv r| d S | S )z�Fix method names to avoid '$' characters and reserved word conflicts. Args: name: string, method name. Returns: The name with '_' appended if the name is a reserved word and '$' and '-' replaced with '_'. �$�_�-)�replace�keyword� iskeyword�RESERVED_WORDS)�namerG rG rH r � s r c C sT g }t | �} | d �� s|�d� | D ]}|�� r|�|� q|�d� qd�|�S )z�Converts key names into parameter names. For example, converting "max-results" -> "max_results" Args: key: string, the method key name. Returns: A safe method name based on the key name. r �xrR � )�list�isalpha�append�isalnum�join)�key�result�crG rG rH r � s r � c C s� | |d�}|du r|du rd}nd}|du rt � }n|}d}t||�D ]B}t�||�}zt|||| || || |d� }t|||||||| |||d�}W n tye } z|jjt j kr_W Y d}~q#|�d}~ww |du rn|�� |du rztd| |f ��|S )a) Construct a Resource for interacting with an API. Construct a Resource object for interacting with an API. The serviceName and version are the names from the Discovery service. Args: serviceName: string, name of the service. version: string, the version of the service. http: httplib2.Http, An instance of httplib2.Http or something that acts like it that HTTP requests will be made through. discoveryServiceUrl: string, a URI Template that points to the location of the discovery service. It should have two parameters {api} and {apiVersion} that when filled in produce an absolute URI to the discovery document for that service. developerKey: string, key obtained from https://code.google.com/apis/console. model: googleapiclient.Model, converts to and from the wire format. requestBuilder: googleapiclient.http.HttpRequest, encapsulator for an HTTP request. credentials: oauth2client.Credentials or google.auth.credentials.Credentials, credentials to be used for authentication. cache_discovery: Boolean, whether or not to cache the discovery doc. cache: googleapiclient.discovery_cache.base.CacheBase, an optional cache object for the discovery documents. client_options: Mapping object or google.api_core.client_options, client options to set user options on the client. (1) The API endpoint should be set through client_options. If API endpoint is not set, `GOOGLE_API_USE_MTLS_ENDPOINT` environment variable can be used to control which endpoint to use. (2) client_cert_source is not supported, client cert should be provided using client_encrypted_cert_source instead. In order to use the provided client cert, `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true`. More details on the environment variables are here: https://google.aip.dev/auth/4114 adc_cert_path: str, client certificate file path to save the application default client certificate for mTLS. This field is required if you want to use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true` in order to use this field, otherwise this field doesn't nothing. More details on the environment variables are here: https://google.aip.dev/auth/4114 adc_key_path: str, client encrypted private key file path to save the application default client encrypted private key for mTLS. This field is required if you want to use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true` in order to use this field, otherwise this field doesn't nothing. More details on the environment variables are here: https://google.aip.dev/auth/4114 num_retries: Integer, number of times to retry discovery with randomized exponential backoff in case of intermittent/connection issues. static_discovery: Boolean, whether or not to use the static discovery docs included in the library. The default value for `static_discovery` depends on the value of `discoveryServiceUrl`. `static_discovery` will default to `True` when `discoveryServiceUrl` is also not provided, otherwise it will default to `False`. always_use_jwt_access: Boolean, whether always use self signed JWT for service account credentials. This only applies to google.oauth2.service_account.Credentials. Returns: A Resource object with methods for interacting with the service. Raises: google.auth.exceptions.MutualTLSChannelError: if there are any problems setting up mutual TLS channel. )�api� apiVersionNTF)�num_retries�static_discovery) �base�http�developerKey�model�requestBuilder�credentials�client_options� adc_cert_path�adc_key_path�always_use_jwt_access�name: %s version: %s) r �_discovery_service_uri_options�uritemplate�expand�_retrieve_discovery_docr r �resp�status�http_client� NOT_FOUND�closer )�serviceName�versionri �discoveryServiceUrlrj rk rl rm �cache_discovery�cachern ro rp rf rg rq �params�discovery_http�service� discovery_url� requested_url�content�erG rG rH r � s` W�� ��r c C s. | dur| gS |du rt �d� tgS ttgS )aZ Returns Discovery URIs to be used for attempting to build the API Resource. Args: discoveryServiceUrl: string, the Original Discovery Service URL preferred by the customer. version: string, API Version requested Returns: A list of URIs to be tried for the Service Discovery, in order. NzADiscovery V1 does not support empty versions. Defaulting to V2...)�logger�warning�V2_DISCOVERY_URI� DISCOVERY_URI)r~ r} rG rG rH rs Z s �rs c C s. ddl m} |r|du r| �� }|r|�| �} | r| S |r/| �||�} | r'| S td||f ��| }dtjv r?t| dtjd �}|rGt| d|�}t � d|� t|tj|�}|j |d �\} } z| �d �} W n tyl Y nw zt�| �}W n ty� } z t �d| � t� �d}~ww |r�|r�|�| | � | S )a� Retrieves the discovery_doc from cache or the internet. Args: url: string, the URL of the discovery document. http: httplib2.Http, An instance of httplib2.Http or something that acts like it through which HTTP requests will be made. cache_discovery: Boolean, whether or not to cache the discovery doc. serviceName: string, name of the service. version: string, the version of the service. cache: googleapiclient.discovery_cache.base.Cache, an optional cache object for the discovery documents. developerKey: string, Key for controlling API usage, generated from the API Console. num_retries: Integer, number of times to retry discovery with randomized exponential backoff in case of intermittent/connection issues. static_discovery: Boolean, whether or not to use the static discovery docs included in the library. Returns: A unicode string representation of the discovery document. r$ )�discovery_cacheNrr �REMOTE_ADDR�userIpr` zURL being requested: GET %s)rf �utf-8zFailed to parse as JSON: )rZ r� � autodetect�get�get_static_docr �os�environr r� �debugr � null_postproc�execute�decode�AttributeError�json�loads� ValueError�errorr �set)�urlri r r| r} r� rj rf rg r� r� � actual_url�reqrw r� r� rG rG rH rv t sL � ���rv c C s, t st| dd �}|r|tkrt�d S d S d S )N�universe_domain)�HAS_UNIVERSE�getattr�DEFAULT_UNIVERSEr@ )rm �credentials_universerG rG rH �4_check_api_core_compatible_with_credentials_universe� s �r� c C s� |du r t jj�� }t|tjj�rt jj�|�}|dur7|df|j dfg}|D ]\} }| dur6t d�|���q't| t�rBt �| �} n t| t�rOt �| �d��} d| vrbt|ttf�rbt�d� t� �tj�| d | d �}d}tr�t�td�}t�|j|�}|� tj!|�}n t"|d d�}|r�t#�|}|j$r�|j$}t%| �}|du �r�t&| �'d i ��'di ��'di ��(� �}|r�|s�|j r�|r�t jj)�*d ��|j r�t+j,|j |j-|j.d�}|du r�t+j/|j-|j.d�}t0|� |j-s�t+�1||�}|�r t|t2j3��r |�r t4t2j3d��r |�5|�}|�6|� |�rt+�7|�}nt8� }d}t�t9d�}|dv�r&t:d��|�r1|j;�r1t:d��|dk�rX|�rGt4|d��rG|j<�rG|j<}n| �rX| �rXt=�>� �rXt=�?| | �}|�rx|� \}}}t@�rnt|t@jA��rn|jBn|}|�C||d|� d| v �r�|�r�|j$�s�tj�| d | d �}t�tDd�}|dv�r�t:d��|dk�s�|dk�r�|�r�t�r�|tj!k�r�t:dtj!� d���|}n t"|dd�}t0|� |du �r�| �'dg �}tEd|v �}tF|||||| | ||d � S )!a� Create a Resource for interacting with an API. Same as `build()`, but constructs the Resource object from a discovery document that is it given, as opposed to retrieving one over HTTP. Args: service: string or object, the JSON discovery document describing the API. The value passed in may either be the JSON string or the deserialized JSON. base: string, base URI for all HTTP requests, usually the discovery URI. This parameter is no longer used as rootUrl and servicePath are included within the discovery document. (deprecated) future: string, discovery document with future capabilities (deprecated). http: httplib2.Http, An instance of httplib2.Http or something that acts like it that HTTP requests will be made through. developerKey: string, Key for controlling API usage, generated from the API Console. model: Model class instance that serializes and de-serializes requests and responses. requestBuilder: Takes an http request and packages it up to be executed. credentials: oauth2client.Credentials or google.auth.credentials.Credentials, credentials to be used for authentication. client_options: Mapping object or google.api_core.client_options, client options to set user options on the client. (1) The API endpoint should be set through client_options. If API endpoint is not set, `GOOGLE_API_USE_MTLS_ENDPOINT` environment variable can be used to control which endpoint to use. (2) client_cert_source is not supported, client cert should be provided using client_encrypted_cert_source instead. In order to use the provided client cert, `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true`. More details on the environment variables are here: https://google.aip.dev/auth/4114 adc_cert_path: str, client certificate file path to save the application default client certificate for mTLS. This field is required if you want to use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true` in order to use this field, otherwise this field doesn't nothing. More details on the environment variables are here: https://google.aip.dev/auth/4114 adc_key_path: str, client encrypted private key file path to save the application default client encrypted private key for mTLS. This field is required if you want to use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable must be set to `true` in order to use this field, otherwise this field doesn't nothing. More details on the environment variables are here: https://google.aip.dev/auth/4114 always_use_jwt_access: Boolean, whether always use self signed JWT for service account credentials. This only applies to google.oauth2.service_account.Credentials. Returns: A Resource object with methods for interacting with the service. Raises: google.auth.exceptions.MutualTLSChannelError: if there are any problems setting up mutual TLS channel. Nrm zclient_options.credentials_filez,Arguments http and {} are mutually exclusiver� �rootUrlz�You are using HttpMock or HttpMockSequence withouthaving the service discovery doc in cache. Try calling build() without mocking once first to populate the cache.�servicePathr� �auth�oauth2�scopeszGclient_options.credentials_file and credentials are mutually exclusive.)r� �quota_project_id�with_always_use_jwt_access�false)�truer� zQUnsupported GOOGLE_API_USE_CLIENT_CERTIFICATE value. Accepted values: true, falseziClientOptions.client_cert_source is not supported, please use ClientOptions.client_encrypted_cert_source.r� �client_encrypted_cert_sourcerZ �mtlsRootUrl�auto)�neverr� �alwayszTUnsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, alwaysr� z1mTLS is not supported in any universe other than �.�features�dataWrapper� ri �baseUrlrk rj rl �resourceDesc�rootDesc�schemar� )G�google�api_corern � ClientOptions� isinstance�collections�abc�Mapping� from_dict�credentials_filer� �format�strr� r� �bytesr� r r r� r� r �urllib�parse�urljoinr� r� �getenvr9 r �determine_domainr� rT r� r� r@ �api_endpointr# r[ r� �keys� exceptions�DuplicateCredentialArgsr �credentials_from_filer� r� �default_credentialsr� �with_scopesr �Credentials�hasattrr� �_create_self_signed_jwt�authorized_httpr r7 r �client_cert_sourcer� r �has_default_client_cert_source�$default_client_encrypted_cert_source�google_auth_httplib2�AuthorizedHttpri �add_certificater8 r �Resource)r� rh �futureri rj rk rl rm rn ro rp rq �banned_options�optionrX r� �universe_domain_env�client_universe�audience_for_self_signed_jwtr� r� �client_cert_to_use�use_client_cert� cert_path�key_path� passphrase�http_channel� mtls_endpoint�use_mtls_endpoint�http_credentialsr� rG rG rH r � s& K��� �� � ���� �� � �� �������� �� ��� � �� �r c C s� |dkrt | �t d�kst | �t d�kr| S t| �S |dkr$tt| ��S |dkr.tt| ��S |dkr:tt| ���� S t | �t d�ksJt | �t d�krL| S t| �S )af Convert value to a string based on JSON Schema type. See http://tools.ietf.org/html/draft-zyp-json-schema-03 for more details on JSON Schema. Args: value: any, the value to convert schema_type: string, the type that value should be interpreted as Returns: A string representation of 'value' based on the schema_type. r3 rZ �integer�number�boolean)r2 r� �int�float�bool�lower)�value�schema_typerG rG rH �_cast� s r� c C sN t | �dk rdS | dd� �� }t�|�}|dur#t| dd� �|>