
    E                        S r SSKJr  SSKJr  SSKJ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r\R&                  " S5      rS rS\4S jrS rS\S\S\4S jrS\4S jrS\4S jrS\S\S\4S jrS\S\4S jrS\S\4S jrS\4S jr S\S\4S jr!S\4S jr"S r#S\S\4S jr$S\S\4S jr%S\S\4S  jr&S\4S! jr'S\S\S"\\   4S# jr(g)$z<Remote repo utils for Artifact Registry repository commands.    )absolute_import)division)unicode_literalsN)List)
exceptions)base)requests)	arg_utilszhttps://github.comz#(http(|s))://proxy\.golang\.org(|/)c                  B   [         R                  " S[        SSS9S9[         R                  " S[        SSS9S9[         R                  " S[        S	SS9S9[         R                  " S
[        SSS9S9[         R                  " S[        SSS9S9[         R                  " S[        SSS9S9[         R                  " S[	        5       S9[         R                  " SSS9[         R                  " SSS9[         R                  " SSSS9[         R                  " S[        5       SS9/$ )z$Adds the remote-<facade>-repo flags.z--remote-mvn-repoMavenFfacadehide_custom_remotes)helpz--remote-docker-repoDockerz--remote-npm-repoNpmz--remote-python-repoPythonz--remote-apt-repoAptTz--remote-yum-repoYumz--remote-go-repoz--remote-usernamez-Remote Repository upstream registry username.z --remote-password-secret-versionzw          Secret Manager secret version that contains password for the
          remote repository upstream.
          z--service-directory-configz          Service Directory config link for using Private Networks. Format:
          projects/<project>/locations/<location>/namespaces/<namespace>/services/<service>
          )r   hiddenz--remote-repo)r   Argument_RemoteRepoHelpText_OsPackageRemoteRepoHelpText_GoRemoteRepoHelpText_CommonRemoteRepoHelpText     <lib/googlecloudsdk/command_lib/artifacts/remote_repo_util.pyArgsr   #   s*   
 mm
"'uM mm
 "(N mm
"%UK mm
 "(N mm
+ mm
+ mm
#8#: mm
> mm
, mm
& . 	 mm
(*4c5
 5r   returnc                 n    [        U S5      =(       a#    [        R                  " U R                  5      S:H  $ )zCReturns whether or not the repo mode specifies a remote repository.modeREMOTE_REPOSITORY)hasattrr
   ChoiceToEnumNamer"   )	repo_argss    r   IsRemoteRepoRequestr'   _   s1     i  L

$
$Y^^
48K
Kr   c                 >   U R                  5       nUR                  Ul        UR                  nUR                  nU(       d  U(       aY  U R                  5       nU R                  5       Ul        U(       a  XFR                  l        U(       a  XVR                  l	        Xcl
        UR                  (       a  SUl        UR                  (       a  SUl        OSUl        UR                  nU(       a%  U R!                  5       Ul        XsR"                  l        UR&                  (       a  SUR&                  p[)        X5      n
U
(       a'  U R+                  5       Ul        XR,                  l        GO[1        U	5      (       a'  U R3                  5       Ul        XR4                  l        GOn[9        U	5      (       a'  U R3                  5       Ul        XR4                  l        GO7[;        X5        GO*UR<                  (       a  SUR<                  p[)        X5      n
U
(       a'  U R?                  5       Ul         XR@                  l        GO[1        U	5      (       a'  U R3                  5       Ul        XR4                  l        GO[9        U	5      (       a'  U R3                  5       Ul        XR4                  l        GOe[;        X5        GOXURB                  (       a  SURB                  p[)        X5      n
U
(       a'  U RE                  5       Ul#        XRF                  l        GO[1        U	5      (       a'  U R3                  5       Ul        XR4                  l        GO[9        U	5      (       a'  U R3                  5       Ul        XR4                  l        GO[;        X5        GOURH                  (       a  SURH                  p[)        X5      n
U
(       a'  U RK                  5       Ul&        XRL                  l        GO/[1        U	5      (       a'  U R3                  5       Ul        XR4                  l        GO[9        U	5      (       a'  U R3                  5       Ul        XR4                  l        GO[;        X5        GOURN                  (       Ga@  SURN                  URP                  pn[)        X5      n
U
(       aj  U RS                  5       Ul*        U RW                  5       URT                  l        XRT                  R.                  l,        XRT                  R.                  l-        GO[1        []        X5      5      (       a1  U R3                  5       Ul        []        X5      UR4                  l        GO[9        U5      (       aD  U(       a  [^        R`                  " S5      eU R3                  5       Ul        XR4                  l        GOo[;        X5        GObURb                  (       Ga@  S	URb                  URd                  pn[)        X5      n
U
(       aj  U Rg                  5       Ul4        U Rk                  5       URh                  l        XRh                  R.                  l,        XRh                  R.                  l-        GO[1        []        X5      5      (       a1  U R3                  5       Ul        []        X5      UR4                  l        GOq[9        U5      (       aD  U(       a  [^        R`                  " S
5      eU R3                  5       Ul        XR4                  l        GO[;        X5        GOURl                  (       a  SURl                  p[1        U	5      (       ae  U	S   S:X  a  U	SS n	U	[n        :w  a'  [p        Rs                  U	5      (       d  [u        XS/5        U R3                  5       Ul        XR4                  l        O}[9        U	5      (       a  [w        U5        Oa[;        X5        OUURx                  (       aB  URx                  n	[1        U	5      (       a%  U R3                  5       Ul        XR4                  l        OU$ X2Rz                  l>        U$ )zTAdds remote repository config to CreateRepositoryRequest or UpdateRepositoryRequest.TFr   r   r   r   r   zR--remote-apt-repo-path is not supported for Artifact Registry Repository upstream.r   zR--remote-yum-repo-path is not supported for Artifact Registry Repository upstream.Go/Nzhttps://proxy.golang.org)?RemoteRepositoryConfigremote_repo_config_descdescriptionremote_usernameremote_password_secret_versionUpstreamCredentialsUsernamePasswordCredentialsusernamePasswordCredentialsusernamepasswordSecretVersionupstreamCredentialsdisable_remote_validationdisableUpstreamValidationenable_ingestion_attestationenableIngestionAttestationservice_directory_configServiceDirectoryConfigserviceDirectoryConfigserviceremote_mvn_repo_ChoiceToRemoteEnumMavenRepositorymavenRepositorypublicRepository_IsRemoteURICommonRemoteRepositorycommonRepositoryuri_IsARRemote_RaiseRemoteRepoUpstreamErrorremote_docker_repoDockerRepositorydockerRepositoryremote_npm_repoNpmRepositorynpmRepositoryremote_python_repoPythonRepositorypythonRepositoryremote_apt_reporemote_apt_repo_pathAptRepositoryaptRepositorySGoogleDevtoolsArtifactregistryV1RemoteRepositoryConfigAptRepositoryPublicRepositoryrepositoryBaserepositoryPath_OsPackageUriar_exceptionsInvalidInputValueErrorremote_yum_reporemote_yum_repo_pathYumRepositoryyumRepositorySGoogleDevtoolsArtifactregistryV1RemoteRepositoryConfigYumRepositoryPublicRepositoryremote_go_repo
GITHUB_URIGOOGLE_MODULE_PROXYmatch$_RaiseCustomUpstreamUnsupportedError._RaiseArtifactRegistryUpstreamUnsupportedErrorremote_repo
repositoryremoteRepositoryConfig)messagesr&   request
remote_cfgr4   secretcreds	sd_configr   remote_inputenum_messageremote_baseremote_paths                r   AppendRemoteRepoConfigToRequestru   g   sU   ..0*$<<*&&(33&((*E(0(L(L(NE%3;''0@F''=%*" ((+/J( ++,0J),1J) 00)(0(G(G(IJ%09%%- "I$=$=L&v<L#+#;#;#=j 4@  1	l	#	#$,$C$C$Ej!(4!!%	\	"	"$,$C$C$Ej!(4!!%#F9 ###Y%A%AL&v<L$,$=$=$?j!5A!!2	l	#	#$,$C$C$Ej!(4!!%	\	"	"$,$C$C$Ej!(4!!%#F9    )";";L&v<L!)!7!7!9j2>/	l	#	#$,$C$C$Ej!(4!!%	\	"	"$,$C$C$Ej!(4!!%#F9 ###Y%A%AL&v<L$,$=$=$?j!5A!!2	l	#	#$,$C$C$Ej!(4!!%	\	"	"$,$C$C$Ej!(4!!%#F9    !!&& %F
 'v;L!)!7!7!9j

f
f
h / BN//>AL//>	mK=	>	>$,$C$C$Ej!(5k(Oj!!%	[	!	!	22$
 	
 %-$C$C$Ej!(3!!%#F8    !!&& %F
 'v;L!)!7!7!9j

f
f
h / BN//>AL//>	mK=	>	>$,$C$C$Ej!(5k(Oj!!%	[	!	!	22$
 	
 %-$C$C$Ej!(3!!%#F8 !9!9LL!!	b	S	 #CR(		#,?,E,E
- - 	-#=">	
 %-$C$C$Ej!(4!!%	\	"	"4V<#F9 ((LL!!$,$C$C$Ej!(4!!%N.8+	.r   r   r   c                     U(       a2  SR                  U U R                  5       [        U 5      [        U 5      S9$ SR                  U U R                  5       [        U 5      [        U 5      S9$ )Nzu({facade} only) Repo upstream for {facade_lower} remote repository.
REMOTE_{command}_REPO must be one of: [{enums}].
)r   facade_lowercommandenumsz({facade} only) Repo upstream for {facade_lower} remote repository.
REMOTE_{command}_REPO can be either:
  - one of the following enums: [{enums}].
  - an http/https custom registry uri (ex: https://my.{facade_lower}.registry)
)formatlower_LanguagePackageCommandName_EnumsStrForFacader   s     r   r   r   $  ss     F\\^+F3 (	  

 F<<>)&1v&	  
r   c                       g)Nzf(Go only) Repo upstream for Go remote repository. "https://proxy.golang.org/" is the only valid value.r   r   r   r   r   r   <  s    =r   c                       g)NzAn upstream for a given remote repository. Ex: "https://github.com", "https://docker.io/v2/" are valid values for their given formats of Go and Docker respectively.r   r   r   r   r   r   C  s    %r   c                     U(       a7  SR                  U U R                  5       U R                  5       [        U 5      S9$ SR                  U U R                  5       U R                  5       [        U 5      S9$ )Nz|({facade} only) Repository base for {facade_lower} remote repository.
REMOTE_{facade_upper}_REPO must be one of: [{enums}].
)r   rw   facade_upperry   z({facade} only) Repository base for {facade_lower} remote repository.
REMOTE_{facade_upper}_REPO can be either:
  - one of the following enums: [{enums}].
  - an http/https custom registry uri (ex: https://my.{facade_lower}.registry)
)rz   r{   upperr}   r   s     r   r   r   K  su     F\\^\\^ (	  

 F<<><<>v&	  
r   c                 0    U S:X  a  gU R                  5       $ )Nr   MVN)r   r   s    r   r|   r|   c  s    w	r   rq   c                     [        U 5      n[        R                  " U5      n UR                  U5      $ ! [         a     gf = f)zJConverts the remote repo input to a PublicRepository Enum message or None.N)_EnumsMessageForFacader
   r%   lookup_by_nameKeyError)r   rq   ry   names       r   r@   r@   i  sD    
 
(%		#	#L	1$%%	 s   4 
A Ac                 p   [         R                  " 5       R                  5       R                  [         R                  " 5       R	                  5       R                  [         R                  " 5       R                  5       R                  [         R                  " 5       R                  5       R                  [         R                  " 5       R                  5       R                  [         R                  " 5       R                  5       R                  [         R                  " 5       R                  5       S.nX;  a  gX   $ )z8Returns the PublicRepository enum messages for a facade.)r   r   r   r   r   r   RubyN)ar_requestsGetMessagesrA   PublicRepositoryValueValuesEnumrK   rN   rQ   rW   RepositoryBaseValueValuesEnumra   rE   )r   facade_to_enums     r   r   r   s  s     
!
!
#?** 
!
!
#** 
!
!
#=?** 
!
!
#** 
!
!
#^^`(( 
!
!
#^^`(( 
!
!
#!!#C#.H !		r   c                 *    [        [        U 5      5      $ )zFReturns the human-readable PublicRepository enum strings for a facade.)_EnumsMessageToStrr   r   s    r   r}   r}     s    	26:	;;r   c                     U c  gSR                  S [        U R                  5       R                  5       5       5       5      $ )z9Returns the human-readable PublicRepository enum strings. , c              3   b   #    U  H%  u  pUS :w  d  M  [         R                  " U5      v   M'     g7f)r   N)r
   EnumNameToChoice).0r   numbers      r   	<genexpr>%_EnumsMessageToStr.<locals>.<genexpr>  s0      9,$	1 'i  &&9s   //)joinsortedto_dictitems)ry   s    r   r   r     s<    
]	  !6!6!89 
 r   c                 8    U(       d  U $ U S   S:w  a  U S-   n X-   $ )Nr*   r+   r   )rs   rt   s     r   rZ   rZ     s*    	_#K		""r   c                 T    U R                  S5      =(       d    U R                  S5      $ )Nzhttps://zhttp://
startswithrq   s    r   rD   rD     s*    		 	 	, 
0G0G1 r   c                 $    U R                  S5      $ )Nz	projects/r   r   s    r   rH   rH     s    		 	 	--r   c                     Sn[        U 5      (       a  [        U 5      nSU S3nSn[        R                  " SU SU U 35      e)z1Raises an error for a remote repo upstream error.r   zJ If you intended to enter a well known upstream repo, valid choices are: [z].zd If you intended to enter a custom upstream URI, this value must start with 'https://' or 'http://'.z.Invalid repo upstream for remote repository: 'z'.)r}   r   r[   r\   )r   rq   well_known_enum_requirementry   custom_uri_requirements        r   rI   rI     sp     ""6*E		  '  	,,.678N7OQ	 r   c                 6    [         R                  " SU  S35      e)Nz0Artifact Registry upstream is not supported for .)r[   r\   r   s    r   rg   rg     s!    ,,8B	 r   allowedc           	      d    SR                  U5      n[        R                  " SU SU  SU S35      e)Nr   zCustom upstream z is not supported for z. Valid choices are [z].
)r   r[   r\   )r   rq   r   allowed_choicess       r   rf   rf     sF     IIg&/,,&<VH E&'t-	 r   ))__doc__
__future__r   r   r   retypingr    googlecloudsdk.api_lib.artifactsr   r[   googlecloudsdk.callioper   $googlecloudsdk.command_lib.artifactsr	   r   $googlecloudsdk.command_lib.util.apisr
   rc   compilerd   r   boolr'   ru   strr   r   r   r   r|   r@   r   r}   r   rZ   rD   rH   rI   rg   rf   r   r   r   <module>r      s_   C &  ' 	  H ( H :!
jj* 
9xd zz $ 3 0s 3  4 C 0   3 ( 3 ( V<s <s <
 #s t .c .d .# S (3 "-1#Yr   