
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ e
j                  j                  d	iZe
j                  j                  fd
Z G d de      Zy)z5The Secure Source Manager repositories client module.    )absolute_import)division)unicode_literals)
list_pager)apis)base)	resourcesv1c                 X    t         j                  |       }t        j                  d|      S )Nsecuresourcemanager)VERSION_MAPgetr   GetClientInstance)release_trackapi_versions     >lib/googlecloudsdk/api_lib/securesourcemanager/repositories.pyr   r      s$    .+			 5{	CC    c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	RepositoriesClientz.Client for Secure Source Manager repositories.c                 *   t        t        j                  j                        | _        | j                  j
                  | _        | j                  j                  | _        t        j                         | _        | j                  j                  dd       y )Nr   r
   )r   r   ReleaseTrackALPHAclientMESSAGES_MODULEmessagesprojects_locations_repositories_servicer	   Registry_resource_parserRegisterApiByName)selfs    r   __init__zRepositoriesClient.__init__%   sd    #D$5$5$;$;<DKKK//DMKK??DM%..0D++,A4Hr   c                    | j                   j                  ||||      }| j                  j                  d|j                  |j
                  |dd      }	| j                   j                  ||	j                         |      }
| j                   j                  |j                         j                         |
|j                        }| j                  j                  |      S )a  Create a new Secure Source Manager repository.

    Args:
      repository_ref: a resource reference to
        securesourcemanager.projects.locations.repositories.
      instance_id: a resource id for
        securesourcemanager.projects.locations.instances.
      description: description of the repository
      default_branch: default branch name of the repository
      gitignores: list of gitignore template names
      license_name: license template name
      readme: README template name

    Returns:
      Created repository.
    )defaultBranch
gitignoreslicensereadmeN
projectsIdlocationsIdinstancesId0securesourcemanager.projects.locations.instancesparams
collection)descriptioninstanceinitialConfig)parent
repositoryrepositoryId)r   InitialConfigr   Parser)   r*   
RepositoryRelativeName=SecuresourcemanagerProjectsLocationsRepositoriesCreateRequestParentrepositoriesIdr   Create)r!   repository_refinstance_idr0   default_branchr%   license_namer'   initial_configr1   r4   
create_reqs               r   r=   zRepositoriesClient.Create,   s    4 ]]00$	 1 N $$**(33)55&

 F + H ))&&($ * J
 \\$$&335#22 ] J
 ==
++r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zGet metadata for a Secure Source Manager repository.

    Args:
      repository_ref: a resource reference to
        securesourcemanager.projects.locations.repositories.

    Returns:
    Description of repository.
    )name)r   :SecuresourcemanagerProjectsLocationsRepositoriesGetRequestr9   r   Get)r!   r>   get_reqs      r   DescribezRepositoriesClient.Describea   sA     mmVV((* W G ==W%%r   c                     | j                   j                  ||j                               }| j                  j	                  |      S )a{  Delete a Secure Source Manager repository.

    Args:
      repository_ref: a Resource reference to a
        securesourcemanager.projects.locations.repositories resource.
      allow_missing: Optional. If set to true, and the repository is not found,
        the request will succeed but no action will be taken on the server.

    Returns:
    Deleted Repository Resource.
    )allowMissingrE   )r   =SecuresourcemanagerProjectsLocationsRepositoriesDeleteRequestr9   r   Delete)r!   r>   allow_missing
delete_reqs       r   rM   zRepositoriesClient.Deletep   sC     \\")D)D)F ] J ==
++r   c           
      <   | j                   j                  d|j                  |j                  |dd      }| j                  j                  |j                         |j                               }t        t        j                  | j                  |||dd            S )	a@  Lists repositories in a Secure Source Manager instance.

    Args:
      location_ref: a Resource reference to a
        securesourcemanager.projects.locations resource.
      instance_id: a resource id for
        securesourcemanager.projects.locations.instances.
      page_size: Optional. Requested page size. Server may return fewer items
        than requested. If unspecified, server will pick an appropriate default.
      limit: Optional. The maximum number of items to return. If unspecified,
        treated as unlimited.

    Returns:
    List of repositories.
    Nr(   r,   r-   )r3   r1   repositoriespageSize)limit
batch_sizefieldbatch_size_attribute)r   r7   r)   r*   r   ;SecuresourcemanagerProjectsLocationsRepositoriesListRequestr9   listr   YieldFromListr   )r!   location_refr?   	page_sizerS   r1   list_reqs          r   ListzRepositoriesClient.List   s      $$**&11'33&

 F + H }}XX((*&&( Y H
   MM  !+	
	 	r   c                    | j                   j                  |j                         |      }| j                   j                  |j                         |dj	                  |      |      }| j
                  j                  |      S )a-  Update a Secure Source Manager repository.

    Args:
      repository_ref: a Resource reference to a
        securesourcemanager.projects.locations.repositories resource.
      update_mask: Field mask is used to specify the fields to be overwritten in
        the repository resource by the update.
      validate_only: Optional. If set to true, and the repository is not found,
        the request will succeed but no action will be taken on the server.
      description: Description of the repository.

    Returns:
    Updated Repository Resource.
    )rE   r0   ,)rE   r4   
updateMaskvalidateOnly)r   r8   r9   <SecuresourcemanagerProjectsLocationsRepositoriesPatchRequestjoinr   Patch)r!   r>   update_maskvalidate_onlyr0   r4   
update_reqs          r   UpdatezRepositoriesClient.Update   s}      ))((* * J [[((*88K("	 \ J ==z**r   N)
__name__
__module____qualname____doc__r"   r=   rI   rM   r]   rh    r   r   r   r   "   s&    6I3,j&,$'R+r   r   N)rl   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.corer	   r   r   r   r   objectr   rm   r   r   <module>rt      sZ    < &  ' ' , ( )  &&- %)$5$5$;$; D
c+ c+r   