
    %                     l   S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSK	J
r
  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  \R*                  " \R,                  R.                  \R,                  R0                  \R,                  R2                  5       " S S\R4                  5      5       rg)z<Implements the command to upload Go modules to a repository.    )absolute_import)division)unicode_literalsN)transfer)
exceptions)apis)waiter)base)flags)go_util)	resourcesc                   <    \ rS rSrSrSrSSS.r\S 5       rS r	S	r
g
)Upload"   z-Upload a Go module to an artifact repository.v1z{description}a      To upload version v0.1.0 of a Go module located in /path/to/code/ to a repository in "us-central1":

        $ {command} --location=us-central1 --project=myproject --repository=myrepo           --module-path=the/module/path --version=v0.1.0 --source=/path/to/code
    )DESCRIPTIONEXAMPLESc                     [         R                  " 5       R                  U 5        [        R                  R                  U 5        U R                  SSSSSS9  U R                  SSS	S
S9  U R                  SSS	SS9  g)zPSet up arguements for this command.

Args:
  parser: An argparse.ArgumentPaser.
z--sourceSOURCEF.zSThe root directory of the go module source code, defaults to the current directory.)metavarrequireddefaulthelpz--module-pathMODULE_PATHTz!The module path of the Go module.)r   r   r   z	--versionVERSIONzThe version of the Go module.N)r   GetRequiredRepoFlagAddToParserr
   
ASYNC_FLAGadd_argument)parsers    "lib/surface/artifacts/go/upload.pyArgsUpload.Args5   s     
++F3OO'
-  . 0	  2
 ,	  .    c                    [         R                  " SU R                  5      nSUR                  S'   UR                  n[
        R                  " 5       n[        R                  R                  US5      n[        R                  " 5       nU" UR                  UR                  UR                  US9nUR                  (       a#  [         R"                  " SUR$                  -   5      eUR&                  R(                  R+                  5       nUR-                  UR/                  5       UR1                  5       S9n	[2        R4                  R7                  USS	9n
UR8                  R5                  XS
9nUR:                  n[<        R>                  RA                  URB                  SS9nURD                  (       a  U$ [F        RH                  " [F        RJ                  " URL                  5      US5      nU$ )z!Run the go module upload command.artifactregistry	multipartzX-Goog-Upload-Protocolzgo.zip)module_pathversionsourceoutputz!failed to package the go module: )uploadGoModuleRequestparentzapplication/zip)	mime_type)uploadz.artifactregistry.projects.locations.operations)
collectionzUploading package)'r   GetClientInstanceapi_versionadditional_http_headersMESSAGES_MODULEtempfilemkdtempospathjoinr   PackOperationr)   r*   r+   	exit_coder   InvalidGoModuleErrorstderrCONCEPTS
repositoryParseCArtifactregistryProjectsLocationsRepositoriesGoModulesUploadRequestUploadGoModuleRequestRelativeNamer   r   FromFile)projects_locations_repositories_goModules	operationr   REGISTRYParseRelativeNamenameasync_r	   WaitForCloudOperationPollerNoResourcesprojects_locations_operations)selfargsclientmessagestempdirzip_pathpackpack_resultrepo_refrequestr0   op_objopop_refresults                  r"   Run
Upload.RunQ   s    ##$68H8HIF?JF""#;<%%H Gww||GX.H  "D$${{	K
 ++
-0B0B
BD D }}''--/HZZ&<<>$$& [ (G __%%h:K%LF==DD E  F			B11
L 2 NF {{m~~

0
02245;
f mr%    N)__name__
__module____qualname____firstlineno____doc__r3   detailed_helpstaticmethodr#   r]   __static_attributes__r_   r%   r"   r   r   "   s6     6+ 	
- . .6(r%   r   )rd   
__future__r   r   r   r8   r6   apitools.base.pyr    googlecloudsdk.api_lib.artifactsr   googlecloudsdk.api_lib.utilr   r	   googlecloudsdk.callioper
   $googlecloudsdk.command_lib.artifactsr   r   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHABETAGACommandr   r_   r%   r"   <module>ru      s    C &  ' 	  % 7 , . ( 6 8 ) D%%++T->->-C-C%%((*UT\\ U*Ur%   