Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/libcloud/common/__pycache__/google.cpython-39.pyc
Ðазад
a q�hox � @ sd d Z ddlmZ zddlZW n ey6 ddlZY n0 ddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlmZ ddlmZmZmZmZmZ ddlmZmZmZ ddlmZ ddlmZmZ z4dd lmZ dd l m!Z! ddl"m#Z# ddl$m%Z% W n e�y dZ#Y n0 d Z&e�'e(�Z)dd� Z*dd� Z+dd� Z,d9dd�Z-G dd� de�Z.G dd� de�Z/G dd� de/�Z0G dd� de/�Z1G dd � d e/�Z2G d!d"� d"e/�Z3G d#d$� d$e/�Z4G d%d&� d&e/�Z5G d'd(� d(e�Z6G d)d*� d*e�Z7G d+d,� d,e�Z8G d-d.� d.e8�Z9G d/d0� d0e8�Z:G d1d2� d2e8�Z;G d3d4� d4e<�Z=G d5d6� d6e<�Z>G d7d8� d8ee�Z?dS ):a� Module for Google Connection and Authentication classes. Information about setting up your Google OAUTH2 credentials: For libcloud, there are two basic methods for authenticating to Google using OAUTH2: Service Accounts and Client IDs for Installed Applications. Both are initially set up from the Cloud Console Console - https://cloud.google.com/console Setting up Service Account authentication (note that you need the cryptography package installed to use this): - Go to the Console - Go to your project and then to "APIs & auth" on the left - Click on "Credentials" - Click on "Create New Client ID..." - Select "Service account" and click on "Create Client ID" - Download the Private Key (should happen automatically). The key you download is in JSON format. - Move the .json file to a safe location. - Optionally, you may choose to Generate a PKCS12 key from the Console. It needs to be converted to the PEM format. Please note, the PKCS12 format is deprecated and may be removed in a future release. - Convert the key using OpenSSL (the default password is 'notasecret'). - Move the .pem file to a safe location. - To Authenticate, you will need to pass the Service Account's "Email address" in as the user_id and the path to the .pem file as the key. Setting up Installed Application authentication: - Go to the Console - Go to your project and then to "APIs & auth" on the left - Click on "Credentials" - Select "Installed application" and "Other" then click on "Create Client ID" - To Authenticate, pass in the "Client ID" as the user_id and the "Client secret" as the key - The first time that you do this, the libcloud will give you a URL to visit. Copy and paste the URL into a browser. - When you go to the URL it will ask you to log in (if you aren't already) and ask you if you want to allow the project access to your account. - Click on Accept and you will be given a code. - Paste that code at the prompt given to you by the Google libcloud connection. - At that point, a token & refresh token will be stored in your home directory and will be used for authentication. Please remember to secure your keys and access tokens. � )�with_statementN)�get_response_object)�b�httplib� urlencode�urlparse�PY3)�ConnectionUserAndKey�JsonResponse�PollingConnection)� BaseDriver)� ProviderError� LibcloudError)�default_backend)� serialization)�SHA256)�PKCS1v15z%Y-%m-%dT%H:%M:%SZc C s t j �� S )z? Mocked in libcloud.test.common.google.GoogleTestCase. )�datetime�utcnow� r r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/libcloud/common/google.py�_utcnowj s r c C s | � t�S )zC Return string of datetime_obj in the UTC Timestamp Format )�strftime�UTC_TIMESTAMP_FORMAT)�datetime_objr r r �_utc_timestampq s r c C s t j �| t�S )zS Return datetime obj where date and time are pulled from timestamp string. )r �strptimer )� timestampr r r �_from_utc_timestampx s r � c C sj z2d| � d� }ddi}t||d�}|jd|jfW S tyd } zdt|�d fW Y d }~S d }~0 0 d S )Nz#http://metadata/computeMetadata/v1/�/zMetadata-FlavorZGoogle)�headersr ���)�lstripr �status�body� Exception�str)�path�urlr! �response�er r r �_get_gce_metadata s r, c @ s e Zd ZdZdd� Zdd� ZdS )�GoogleAuthErrorz6Generic Error class for various authentication errors.c C s || _ d S �N)�value)�selfr/ r r r �__init__� s zGoogleAuthError.__init__c C s t | j�S r. )�reprr/ �r0 r r r �__repr__� s zGoogleAuthError.__repr__N)�__name__� __module__�__qualname__�__doc__r1 r4 r r r r r- � s r- c s e Zd Zd� fdd� Z� ZS )�GoogleBaseErrorNc s || _ tt| ��|||� d S r. )�code�superr9 r1 �r0 r/ � http_coder: �driver�� __class__r r r1 � s zGoogleBaseError.__init__)N�r5 r6 r7 r1 � __classcell__r r r? r r9 � s r9 c @ s e Zd ZdS )�InvalidRequestErrorN�r5 r6 r7 r r r r rC � s rC c @ s e Zd ZdS )�JsonParseErrorNrD r r r r rE � s rE c s e Zd Zd� fdd� Z� ZS )�ResourceNotFoundErrorNc sd || _ t|t�rLd|v rL|d �d�dkrL|d �d�dkrL|d d |d<