
                             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	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.
    )absolute_import)division)unicode_literals)
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,   0   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)Source7   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__:   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)r6   *SourcerepoProjectsReposGetIamPolicyRequestRelativeNamer4   projects_reposGetIamPolicyr7   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)r<   setIamPolicyRequest)r6   SetIamPolicyRequest*SourcerepoProjectsReposSetIamPolicyRequestr>   r4   r?   SetIamPolicy)r7   rB   rF   reqrC   s        r   rJ   Source.SetIamPolicyM   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   YieldFromListr4   r?   r6   "SourcerepoProjectsReposListRequestr>   )r7   project_resourcerR   	page_sizes       r   	ListReposSource.ListRepos\   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.
rN   )r6   !SourcerepoProjectsReposGetRequestr>   r4   r?   GetrA   s      r   GetRepoSource.GetRepog   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*   rN   )parentr%   )
r
   r   r+   r   r6   $SourcerepoProjectsReposCreateRequestr>   Repor4   r?   )r7   rB   rb   rC   s       r   
CreateRepoSource.CreateRepou   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.
rN   N)r6   $SourcerepoProjectsReposDeleteRequestr>   r4   r?   DeleterA   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)rO   updateRepoRequest)r6   #SourcerepoProjectsReposPatchRequestrO   UpdateRepoRequestr4   r?   Patch)r7   r%   update_maskrK   s       r   	PatchRepoSource.PatchRepo   sY    
--
;
;YY--99 : / < 0C <<&&,,S11r   )r4   r6   )N)NN)pubsubConfigs)r   r   r   r   r   r9   r@   rJ   rZ   r_   re   rj   rs   r   r   r   r   r.   r.   7   s-    /?==	47 02r   r.   )r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r!   r	   r
   r#   r"   r   r'   r,   objectr.   r   r   r   <module>r{      sQ    '  ' ' , = * ) 
0-- 0.=^2V ^2r   