File manager - Edit - /opt/gsutil/gslib/__pycache__/cloud_api.cpython-39.pyc
Back
a +(Wgޣ � @ s\ d Z ddlmZ ddlmZ ddlmZ G dd� de�ZG dd� de�ZG d d � d e�Z G dd� de�Z G d d� de �ZG dd� de�ZG dd� de�Z G dd� de �ZG dd� de �ZG dd� de �ZG dd� de�ZG dd� de�ZG dd� de�ZG dd � d e�ZG d!d"� d"e�ZG d#d$� d$e�ZG d%d&� d&e�ZG d'd(� d(e�ZG d)d*� d*e�Zd+S ),z8Gsutil API for interacting with cloud storage providers.� )�absolute_import)�division)�unicode_literalsc @ s� e Zd ZdZdQdd�Zdd� ZdRdd �ZdSd d�ZdTdd �Zdd� Z dUdd�Z dVdd�ZdWdd�ZdXdd�Z dYdd�ZG dd� de�ZG dd� de�ZdZdd�Zd[d d!�Zd\d"d#�Zd]d$d%�Zd^d&d'�ZG d(d)� d)e�Zdddd*ejddddddfd+d,�Zd_d-d.�Zd`d/d0�Zdad1d2�Zdbd3d4�Zdcd5d6�Zddd7d8�Zded9d:�Z dfd;d<�Z!dgd=d>�Z"dhd?d@�Z#didAdB�Z$djdCdD�Z%dkdEdF�Z&dGdH� Z'dIdJ� Z(dKdL� Z)dldMdN�Z*dOdP� Z+dS )m�CloudApiay Abstract base class for interacting with cloud storage providers. Implementations of the gsutil Cloud API are not guaranteed to be thread-safe. Behavior when calling a gsutil Cloud API instance simultaneously across threads is undefined and doing so will likely cause errors. Therefore, a separate instance of the gsutil Cloud API should be instantiated per-thread. Nr c C s: || _ || _|| _|| _|| _|| _|| _|| _| | _dS )aF Performs necessary setup for interacting with the cloud storage provider. Args: bucket_storage_uri_class: boto storage_uri class, used by APIs that provide boto translation or mocking. logger: logging.logger for outputting log messages. status_queue: Queue for relaying status to UI. provider: Default provider prefix describing cloud storage provider to connect to. debug: Debug level for the API implementation (0..3). http_headers (dict|None): Arbitrary headers to be included in every request. trace_token: Google internal trace token to pass to the API implementation (string). perf_trace_token: Performance trace token to use when making API calls. user_project: Project to be billed for this request. N) �bucket_storage_uri_class�logger�status_queue�provider�debug�http_headers�trace_token�perf_trace_token�user_project) �selfr r r r r r r r r � r �/opt/gsutil/gslib/cloud_api.py�__init__ s zCloudApi.__init__c C s t d��dS )z%Returns the service account email id.z'GetServiceAccountId must be overridden.N��NotImplementedError�r r r r �GetServiceAccountIdC s zCloudApi.GetServiceAccountIdc C s t d��dS )a� Gets Bucket metadata. Args: bucket_name: Name of the bucket. provider: Cloud storage provider to connect to. If not present, class-wide default is used. fields: If present, return only these Bucket metadata fields, for example, ['logging', 'defaultObjectAcl'] Raises: ArgumentException for errors during input validation. ServiceException for errors interacting with cloud storage providers. Returns: Bucket object. zGetBucket must be overloadedNr �r �bucket_namer �fieldsr r r � GetBucketG s zCloudApi.GetBucketc C s t d��dS )a� Returns an IAM policy for the specified Bucket. Args: bucket_name: Name of the bucket. provider: Cloud storage provider to connect to. If not present, class-wide default is used. fields: If present, return only the IAM policy fields specified. Raises: ArgumentException for errors during input validation. ServiceException for errors interacting with the cloud storage providers. Returns: Policy object of the bucket. z%GetBucketIamPolicy must be overloadedNr r r r r �GetBucketIamPolicyZ s zCloudApi.GetBucketIamPolicyc C s t d��dS )a� Sets an IAM policy for the specified Bucket. Args: bucket_name: Name of the bucket. policy: A Policy object describing the IAM policy. provider: Cloud storage provider to connect to. If not present, class-wide default is used. Raises: ArgumentException for errors during input validation. ServiceException for errors interacting with the cloud storage providers. Returns: Policy object of the bucket. May differ from input Policy. z%SetBucketIamPolicy must be overloadedNr )r r �policyr r r r �SetBucketIamPolicyl s zCloudApi.SetBucketIamPolicyc C s t d��dS )aW Sign a url using service account's system managed private key. Args: method: The HTTP method to be used with the signed URL. duration: timedelta for which the constructed signed URL should be valid. path: String path to the bucket or object for signing, in the form 'bucket' or 'bucket/object'. generation: If not None, specifies a version of an object for signing. logger: logging.Logger for warning and debug output. region: Geographic region in which the requested resource resides. signed_headers: Dict containing the header info like host content-type etc. string_to_sign_debug: If true AND logger is enabled for debug level, print string to sign to debug. Used to differentiate user's signed URL from the probing permissions-check signed URL. Raises: ArgumentException for errors during input validation. ServiceException for errors interacting with cloud storage providers. CommandException for errors because of invalid account used for signing. Returns: The signed url. zSignUrl must be overloadedNr ) r �methodZduration�path� generationr �region�signed_headersZstring_to_sign_debugr r r �SignUrl~ s zCloudApi.SignUrlc C s t d��dS )a� Lists bucket metadata for the given project. Args: project_id: Project owning the buckets, default from config if None. provider: Cloud storage provider to connect to. If not present, class-wide default is used. fields: If present, return only these metadata fields for the listing, for example: ['items/logging', 'items/defaultObjectAcl']. Note that the WildcardIterator class should be used to list buckets instead of calling this function directly. It amends the fields definition from get-like syntax such as ['logging', 'defaultObjectAcl'] so that the caller does not need to prepend 'items/' or specify fields necessary for listing (like nextPageToken). Raises: ArgumentException for errors during input validation. ServiceException for errors interacting with cloud storage providers. Returns: Iterator over Bucket objects. zListBuckets must be overloadedNr )r � project_idr r r r r �ListBuckets� s zCloudApi.ListBucketsc C s t d��dS )a� Updates bucket metadata for the bucket with patch semantics. Args: bucket_name: Name of bucket to update. metadata: Bucket object defining metadata to be updated. canned_acl: Canned ACL to apply to the bucket. canned_def_acl: Canned default object ACL to apply to the bucket. preconditions: Preconditions for the request. provider: Cloud storage provider to connect to. If not present, class-wide default is used. fields: If present, return only these Bucket metadata fields. Raises: ArgumentException for errors during input validation. ServiceException for errors interacting with cloud storage providers. Returns: Bucket object describing new bucket metadata. zPatchBucket must be overloadedNr )r r �metadata� canned_aclZcanned_def_acl� preconditionsr r r r r �PatchBucket� s zCloudApi.PatchBucketc C s t d��dS )a� Locks the Retention Policy on the bucket. Args: bucket_name: Name of bucket to update. metageneration: Bucket metageneration to use as a precondition. provider: Cloud storage provider to connect to. If not present, class-wide default is used. Raises: ServiceException for errors interacting with cloud storage providers. Returns: None z&LockRetentionPolicy must be overloadedNr )r r �metagenerationr r r r �LockRetentionPolicy� s zCloudApi.LockRetentionPolicyc C s t d��dS )a� Creates a new bucket with the specified metadata. Args: bucket_name: Name of the new bucket. project_id: Project owner of the new bucket, default from config if None. metadata: Bucket object defining new bucket metadata. provider: Cloud storage provider to connect to. If not present, class-wide default is used. fields: If present, return only these Bucket metadata fields. Raises: ArgumentException for errors during input validation. ServiceException for errors interacting with cloud storage providers. Returns: Bucket object describing new bucket metadata. zCreateBucket must be overloadedNr )r r r$ r&