HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/surface/artifacts/generic/__pycache__/upload.cpython-312.pyc
�

��T���dZddlmZddlmZddlmZddlZddlmZddlm	Z
ddlmZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZej2ej4ej6j8ej6j:ej6j<�Gd�dej>���Z y)zCImplements the command to upload Generic artifacts to a repository.�)�absolute_import)�division)�unicode_literalsN)�transfer)�
exceptions)�apis)�waiter)�base)�flags)�util)�log)�
properties)�	resources)�scaled_integerc�:�eZdZdZdZddd�Zed��Zd�Zd�Z	y	)
�Uploadz,Uploads an artifact to a generic repository.�v1z
{description}aR    To upload version v0.1.0 of a generic artifact located in /path/to/file/ to a repository in "us-central1":

        $ {command} --location=us-central1 --project=myproject --repository=myrepo           --package=mypackage --version=v0.1.0 --source=/path/to/file/

    To upload version v0.1.0 of a generic artifact located in /path/to/file/ to a repository in "us-central1" within a folder structure:

        $ {command} --location=us-central1 --project=myproject --repository=myrepo           --package=mypackage --version=v0.1.0 --source=/path/to/file/ --destination-path=folder/file
    )�DESCRIPTION�EXAMPLESc���tj�j|�tj�j|�tj
j|�|j
dd��}|jdddd��|jdddd	��|jd
ddd
��|jddd��|jddd��y)z[Set up arguments for this command.

    Args:
      parser: An argparse.ArgumentPaser.
    T)�mutex�requiredz	--package�PACKAGEzThe package to upload.)�metavarr�helpz	--version�VERSIONzWThe version of the package. You cannot overwrite an existing version in the repository.z--destination-path�DESTINATION_PATHFzRUse to specify the path to upload a generic artifact to within a folder structure.z--source�SOURCEz'The path to the file you are uploading.)rrz--source-directory�SOURCE_DIRECTORYz The directory you are uploading.N)r�GetRequiredRepoFlag�AddToParser�GetSkipExistingFlagr
�
ASYNC_FLAG�	add_group�add_argument)�parser�groups  �'lib/surface/artifacts/generic/upload.py�ArgszUpload.Args<s���
����+�+�F�3�	����+�+�F�3��O�O����'����4�$��7�E�
������
%�	�'�
������
J�������"��
5���
�����
6��8�
����"�
/��1�c	��tjd|j�}|j}|j}|j
}|r!|jrtjd��|r!|jrtjd��|r|j||||�S|�rtjjtjj|��|_tjj|j�stjd��t j"j%dj'|��tj(|j�D]@\}}}|D]5}		|j|tjj+||	�||��7�Byy#t,j.$r9}
|jr'dt1|
�vrt!j2d�Yd}
~
���d}
~
wwxYw)	z(Run the generic artifact upload command.�artifactregistryz3Asynchronous uploads not supported for directories.z7Skip existing is not supported for single file uploads.z,Specified path is not an existing directory.zUploading directory: {}zalready existsz6File with the same package and version already exists.N)r�GetClientInstance�api_version�MESSAGES_MODULE�source_directory�source�async_�
ar_exceptions�InvalidInputValueError�
skip_existing�uploadArtifact�os�path�normpath�
expanduser�isdirr
�status�Print�format�walk�joinr	�OperationError�str�warning)�self�args�client�messages�
source_dir�source_filer8�_�files�file�es           r(�Runz
Upload.Runhs����
#�
#�$6��8H�8H�
I�F��%�%�H��&�&�J��+�+�K��d�k�k��0�0�
?�
���t�)�)��0�0�
C�
���
�
 �
 ��{�F�H�
E�E�	�!�g�g�.�.�r�w�w�/A�/A�*�/M�N�d��
�W�W�]�]�4�0�0�
1��2�2�:��	�
�j�j���0�7�7�
�C�D��G�G�D�$9�$9�:�.�$��5��D�
�����r�w�w�|�|�D�$�/�&�(�
��;�
�� �&�&���!�!�&6�#�a�&�&@��k�k�J�����
�s�=2F5�5H�.G<�;G<�<Hc�z�tjtjjj
j
��}|jjj�}|jr�tjj|�}|jr�tjj|j�}tjj!|tjj|��}np|t#|j$�dzd}|jrItjj|j�}tjj!||�}|j'tj(d�}|j+|j-|j.|j0|��|j3���}	t5j6|�}
t8j:j=||
|��}|j>j;|	|��}|j@}
tBjDjG|
jHd��}|jJr|StMjNtMjP|jR�|d	jU|��}|S)
N��/)�	packageId�	versionId�filename)�uploadGenericArtifactRequest�parent)�	mime_type�	chunksize)�uploadz.artifactregistry.projects.locations.operations)�
collectionzUploading file: {})+r�ParseIntegerr�VALUES�storage�upload_chunk_size�Get�CONCEPTS�
repository�Parser1r7r8�basename�destination_pathr9r@�lenr0�replace�sep�JArtifactregistryProjectsLocationsRepositoriesGenericArtifactsUploadRequest�UploadGenericArtifactRequest�package�version�RelativeNamer�GetMimetyperr�FromFile�0projects_locations_repositories_genericArtifacts�	operationr�REGISTRY�ParseRelativeName�namer2r	�WaitFor�CloudOperationPollerNoResources�projects_locations_operationsr>)rDrE�	file_pathrFrGrX�repo_ref�	file_namer8�requestrWrY�op_obj�op�op_ref�results                r(r6zUpload.uploadArtifact�s3���+�+����!�!�3�3�7�7�9��I��}�}�'�'�-�-�/�H��{�{��'�'�"�"�9�-�i�	
�	�	��w�w���� 5� 5�6���G�G�L�L��r�w�w�'7�'7�	�'B�C�	��C�� 5� 5�6�q�8�9�:�i�	
�	�	��w�w���� 5� 5�6���G�G�L�L��y�1�	��!�!�"�&�&�#�.�I��a�a�%-�%J�%J��l�l��l�l��&K�& ��$�$�&�b�(�G�� � ��+�I�
�_�_�
%�
%��Y�)�&�=�F�
�
D�
D�
K�
K���L� �F�	�	�	�B�
�
�
�
1�
1�
���L�2�N�F��{�{�
�m��~�~�
�
0�
0��2�2�4�5;�
�
%�
%�i�
0�2�f��mr*N)
�__name__�
__module__�__qualname__�__doc__r.�
detailed_help�staticmethodr)rNr6�r*r(rr$s=��
5��+�%�
�
�-��)1��)1�V,�\3r*r)!r��
__future__rrrr7�apitools.base.pyr� googlecloudsdk.api_lib.artifactsrr3�googlecloudsdk.api_lib.utilrr	�googlecloudsdk.callioper
�$googlecloudsdk.command_lib.artifactsrr�googlecloudsdk.corer
rr�googlecloudsdk.core.utilr�DefaultUniverseOnly�
ReleaseTracks�ReleaseTrack�ALPHA�BETA�GA�Commandrr�r*r(�<module>r�s���J�&��'�	�%�H�,�.�(�6�5�#�*�)�3�������������T�.�.�3�3�T�5F�5F�5I�5I��a�T�\�\�a���ar*