
    9                         S 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
r
 " S S	\R                  5      rS
 rS r " S S\5      rg)zSourceRepo APIs layer.

Parse methods accepts strings from command-line arguments, and it can accept
more formats like "https://...". Get methods are strict about the arguments.
    )
list_pager)apis)
exceptions)
properties)	resourcesNc                       \ rS rSrSrSrg)RepoResourceError   z'Raised when a repo could not be parsed. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       /lib/googlecloudsdk/api_lib/source/sourcerepo.pyr	   r	      s    /r   r	   c                     [         R                  R                  U S[        R                  R
                  R                  R                  0SS9$ ! [        R                   a$  n[        [        R                  " U5      5      eSnAff = f)z7Parse a string as a sourcerepo.projects.repos resource.
projectsIdzsourcerepo.projects.repos)params
collectionN)r   REGISTRYParser   VALUEScoreproject	GetOrFailcore_exceptionsErrorr	   six	text_type)repoes     r   	ParseRepor$   "   sw    .##j//44<<FFG. $ 0 0 
		 .
CMM!,
--.s   AA B#BBc                      [         R                  R                  S[        R                  R
                  R                  R                  5       S9$ )z=Create a sourcerepo.projects resource of the default project.sourcerepo.projectsr   )r   r   Creater   r   r   r   r   r   r   r   GetDefaultProjectr)   -   sA    				"	"""''//99; 
# 
= =r   c                   T    \ rS rSrSrSS jrS rS rSS jrS r	S	 r
S
 rSS jrSrg)Source4   z'Base class for sourcerepo api wrappers.Nc                 |    Uc  [         R                  " SS5      nXl        [         R                  " SS5      U l        g )N
sourcerepov1)r   GetClientInstance_clientGetMessagesModulemessages)selfclients     r   __init__Source.__init__7   s2    ~%%lD9fL**<>DMr   c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5      $ )zGets IAM policy for a repo.

Args:
  repo_resource:  The repo resource with collection type
    sourcerepo.projects.repos
Returns:
  (messages.Policy) The IAM policy.
)resource)r3   *SourcerepoProjectsReposGetIamPolicyRequestRelativeNamer1   projects_reposGetIamPolicyr4   repo_resourcerequests      r   r=   Source.GetIamPolicy=   sE     mmFF++- G /G<<&&33G<<r   c                     U R                   R                  US9nU R                   R                  UR                  5       US9nU R                  R
                  R                  U5      $ )zSets the IAM policy from a policy string.

Args:
  repo_resource: The repo as a resource with colleciton type
    sourcerepo.projects.repos
  policy: (string) The file containing the new IAM policy.
Returns:
  (messages.Policy) The IAM policy.
)policy)r9   setIamPolicyRequest)r3   SetIamPolicyRequest*SourcerepoProjectsReposSetIamPolicyRequestr;   r1   r<   SetIamPolicy)r4   r?   rC   reqr@   s        r   rG   Source.SetIamPolicyJ   s_     --
+
+6
+
:CmmFF++-3 G HG<<&&33G<<r   c           	          [         R                  " U R                  R                  U R                  R                  UR                  5       S9USUSS9$ )zReturns list of repos.namepageSizerepos)limitbatch_size_attribute
batch_sizefield)r   YieldFromListr1   r<   r3   "SourcerepoProjectsReposListRequestr;   )r4   project_resourcerO   	page_sizes       r   	ListReposSource.ListReposY   sQ    ####88!..0 	9 	2' r   c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5      $ )a  Finds details on the named repo, if it exists.

Args:
  repo_resource: (Resource) A resource representing the repo to create.
Returns:
  (messages.Repo) The full definition of the new repo, as reported by
    the server.
  Returns None if the repo does not exist.
rK   )r3   !SourcerepoProjectsReposGetRequestr;   r1   r<   Getr>   s      r   GetRepoSource.GetRepod   sD     mm=='') > +G<<&&**733r   c                 6   [         R                  R                  SUR                  S9nU R                  R                  UR                  5       U R                  R                  UR                  5       S9S9nU R                  R                  R                  U5      $ )zCreates a repo.

Args:
  repo_resource: (Resource) A resource representing the repo to create.
Returns:
  (messages.Repo) The full definition of the new repo, as reported by
    the server.
r&   r'   rK   )parentr"   )
r   r   r(   r   r3   $SourcerepoProjectsReposCreateRequestr;   Repor1   r<   )r4   r?   r_   r@   s       r   
CreateRepoSource.CreateRepor   s     &&-*B*B ' DFmm@@""$]]]%?%?%AB A DG <<&&--g66r   c                     U R                   R                  UR                  5       S9nU R                  R                  R                  U5        g)z_Deletes a repo.

Args:
  repo_resource: (Resource) A resource representing the repo to create.
rK   N)r3   $SourcerepoProjectsReposDeleteRequestr;   r1   r<   Deleter>   s      r   
DeleteRepoSource.DeleteRepo   sB     mm@@'') A +GLL&&w/r   c                     U R                   R                  UR                  U R                   R                  XS9S9nU R                  R
                  R                  U5      $ )zUpdates a repo's configuration.)r"   
updateMask)rL   updateRepoRequest)r3   #SourcerepoProjectsReposPatchRequestrL   UpdateRepoRequestr1   r<   Patch)r4   r"   update_maskrH   s       r   	PatchRepoSource.PatchRepo   sY    
--
;
;YY--99 : / < 0C <<&&,,S11r   )r1   r3   )N)NN)pubsubConfigs)r   r   r   r   r   r6   r=   rG   rW   r\   rb   rg   rp   r   r   r   r   r+   r+   4   s-    /?==	47 02r   r+   )r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   r   r   r    r   r	   r$   r)   objectr+   r   r   r   <module>rw      sH    ( , = * ) 
0-- 0.=^2V ^2r   