
    ]h)                     v   d dl Z d dlmZmZmZmZmZmZmZm	Z	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 ddlmZmZmZ ddlmZmZ ddl m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZM ddlNmOZO e
r
d dlPmQZQmRZRmSZS eZT	 d"deUde	ee   ee   f   dee	eUeeUeUf   dddf      dedeeUef   f
dZVdedeeW   deddfdZX	 d"deUde	eUeeW   f   dee	eUeeUeUf   dddf      deddf
d ZYg d!ZZy)#    N)	AnyAnyStrcastDictIOIterableOptionalUnionTYPE_CHECKING   )VERSION)
BlobClient)ContainerClient)BlobServiceClient)BlobLeaseClient)StorageStreamDownloader)BlobQueryReader)generate_account_sasgenerate_container_sasgenerate_blob_sas)ExponentialRetryLinearRetry)PartialBatchErrorException)LocationModeResourceTypesAccountSasPermissionsStorageErrorCodeUserDelegationKeyServices)RehydratePriority)"BlobType
BlockStateStandardBlobTierPremiumPageBlobTierBlobImmutabilityPolicyModeSequenceNumberActionPublicAccessBlobAnalyticsLoggingMetricsRetentionPolicyStaticWebsiteCorsRuleContainerPropertiesBlobPropertiesFilteredBlobLeasePropertiesContentSettingsCopyProperties	BlobBlock	PageRangeAccessPolicyContainerSasPermissionsBlobSasPermissionsCustomerProvidedEncryptionKeyContainerEncryptionScopeBlobQueryErrorDelimitedJsonDialectDelimitedTextDialectQuickQueryDialectArrowDialect	ArrowTypeObjectReplicationPolicyObjectReplicationRuleImmutabilityPolicy)
BlobPrefix)AzureNamedKeyCredentialAzureSasCredentialTokenCredentialblob_urldata
credentialrD   rE   rF   kwargsreturnc                     t        j                  | |      5 } t        t         |      j                  d|t        j
                  d|cddd       S # 1 sw Y   yxY w)a
  Upload data to a given URL

    The data will be uploaded as a block blob.

    :param str blob_url:
        The full URI to the blob. This can also include a SAS token.
    :param data:
        The data to upload. This can be bytes, text, an iterable or a file-like object.
    :type data: bytes or str or Iterable
    :param credential:
        The credentials with which to authenticate. This is optional if the
        blob URL already has a SAS token. The value can be a SAS token string,
        an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials,
        an account shared access key, or an instance of a TokenCredentials class from azure.identity.
        If the resource URI already contains a SAS token, this will be ignored in favor of an explicit credential
        - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
        If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
        should be the storage account key.
    :type credential:
        ~azure.core.credentials.AzureNamedKeyCredential or
        ~azure.core.credentials.AzureSasCredential or
        ~azure.core.credentials.TokenCredential or
        str or dict[str, str] or None
    :keyword bool overwrite:
        Whether the blob to be uploaded should overwrite the current data.
        If True, upload_blob_to_url will overwrite any existing data. If set to False, the
        operation will fail with a ResourceExistsError.
    :keyword int max_concurrency:
        The number of parallel connections with which to download.
    :keyword int length:
        Number of bytes to read from the stream. This is optional, but
        should be supplied for optimal performance.
    :keyword dict(str,str) metadata:
        Name-value pairs associated with the blob as metadata.
    :keyword bool validate_content:
        If true, calculates an MD5 hash for each chunk of the blob. The storage
        service checks the hash of the content that has arrived with the hash
        that was sent. This is primarily valuable for detecting bitflips on
        the wire if using http instead of https as https (the default) will
        already validate. Note that this MD5 hash is not stored with the
        blob. Also note that if enabled, the memory-efficient upload algorithm
        will not be used, because computing the MD5 hash requires buffering
        entire blocks, and doing so defeats the purpose of the memory-efficient algorithm.
    :keyword str encoding:
        Encoding to use if text is supplied as input. Defaults to UTF-8.
    :returns: Blob-updated property dict (Etag and last modified)
    :rtype: dict(str, Any)
    rI   )rH   	blob_typeN )r   from_blob_urlr   upload_blobr!   	BLOCKBLOB)rG   rH   rI   rJ   clients        a/var/www/core.comfia.cic-ware.com/crm/lib/python3.12/site-packages/azure/storage/blob/__init__.pyupload_blob_to_urlrU   J   sX    l 
	!	!(z	B gf3tJ'33fI[I[f_efg g gs   1AArS   handlec                 J     | j                   di |}|j                  |       y)z
    Download data to specified open file-handle.

    :param BlobClient client: The BlobClient to download with.
    :param Stream handle: A Stream to download the data into.
    NrO   )download_blobreadinto)rS   rV   rJ   streams       rT   _download_to_streamr[      s%     "V!!+F+F
OOF    outputc                    |j                  dd      }t        j                  | |      5 }t        |d      r#t	        |t        t        t           |      fi | nR|s.t        j                  j                  |      rt        d| d      t        |d      5 }t	        ||fi | ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)	a
  Download the contents of a blob to a local file or stream.

    :param str blob_url:
        The full URI to the blob. This can also include a SAS token.
    :param output:
        Where the data should be downloaded to. This could be either a file path to write to,
        or an open IO handle to write to.
    :type output: str or writable stream.
    :param credential:
        The credentials with which to authenticate. This is optional if the
        blob URL already has a SAS token or the blob is public. The value can be a SAS token string,
        an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials,
        an account shared access key, or an instance of a TokenCredentials class from azure.identity.
        If the resource URI already contains a SAS token, this will be ignored in favor of an explicit credential
        - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError.
        If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key"
        should be the storage account key.
    :type credential:
        ~azure.core.credentials.AzureNamedKeyCredential or
        ~azure.core.credentials.AzureSasCredential or
        ~azure.core.credentials.TokenCredential or
        str or dict[str, str] or None
    :keyword bool overwrite:
        Whether the local file should be overwritten if it already exists. The default value is
        `False` - in which case a ValueError will be raised if the file already exists. If set to
        `True`, an attempt will be made to write to the existing file. If a stream handle is passed
        in, this value is ignored.
    :keyword int max_concurrency:
        The number of parallel connections with which to download.
    :keyword int offset:
        Start of byte range to use for downloading a section of the blob.
        Must be set if length is provided.
    :keyword int length:
        Number of bytes to read from the stream. This is optional, but
        should be supplied for optimal performance.
    :keyword bool validate_content:
        If true, calculates an MD5 hash for each chunk of the blob. The storage
        service checks the hash of the content that has arrived with the hash
        that was sent. This is primarily valuable for detecting bitflips on
        the wire if using http instead of https as https (the default) will
        already validate. Note that this MD5 hash is not stored with the
        blob. Also note that if enabled, the memory-efficient upload algorithm
        will not be used, because computing the MD5 hash requires buffering
        entire blocks, and doing so defeats the purpose of the memory-efficient algorithm.
    :rtype: None
    	overwriteFrM   writez
The file 'z' already exists.wbN)popr   rP   hasattrr[   r   r   bytesospathisfile
ValueErroropen)rG   r]   rI   rJ   r_   rS   file_handles          rT   download_blob_from_urlrk      s    h 

;.I		!	!(z	B Cf67#RY(?J6J!7 :fX5F!GHHfd# C{#FKB6BCC CC CC Cs$   A,CB5$C5B>	:CC
)8rU   rk   r   r   r   r!   r   r   r   r   r   r   r"   r#   r$   r&   r%   rB   r'   r(   r)   r*   r+   r,   r-   r.   rC   r/   r0   r1   r2   r3   r4   r5   r=   r6   r7   r   r   r   r8   r    r   r   r   r   r9   r:   r;   r<   r>   r?   r   r@   rA   r   )N)[re   typingr   r   r   r   r   r   r	   r
   r   _versionr   _blob_clientr   _container_clientr   _blob_service_clientr   _leaser   	_downloadr   _quick_query_helperr   _shared_access_signaturer   r   r   _shared.policiesr   r   _shared.response_handlersr   _shared.modelsr   r   r   r   r   r   _generated.modelsr    _modelsr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   _list_blobs_helperrC   azure.core.credentialsrD   rE   rF   __version__strrU   rd   r[   rk   __all__rO   r\   rT   <module>r      s   
 X X X  $ . 3 # . 0 e e ; A  1# # # # # # # # #H +cc |@7g7g
 "V*,
-7g sDcN4MOcevvwx7g 	7g
 
#s(^7gt
 BuI  QU  |@<C<C#r%y.!<C sDcN4MOcevvwx<C 	<C
 
<C~9r\   