
    7                     Z    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  G d de	      Z
y	)
zCAPI client library for Certificate Manager certificate map entries.    )absolute_import)division)unicode_literals)
list_pager)
api_clientc                   L    e Zd ZdZd	dZ	 	 	 	 d
dZd Z	 	 	 	 d
dZd ZddZ	y)CertificateMapEntryClientz;API client for Certificate Manager certificate map entries.Nc                     |xs t        j                         | _        | j                  j                  | _        |xs | j                  j
                  | _        y )N)r   GetClientInstance_client8projects_locations_certificateMaps_certificateMapEntries_serviceMESSAGES_MODULEmessages)selfclientr   s      Ilib/googlecloudsdk/api_lib/certificate_manager/certificate_map_entries.py__init__z"CertificateMapEntryClient.__init__   s>    ;Z99;DLLLYYDM< < <DM    c                 f   | j                   j                  |j                         || j                   j                  |||s*| j                   j                  j                  j
                  nd|D cg c]  }|j                          c}|            }| j                  j                  |      S c c}w )a  Creates a certificate map entry.

    Args:
      parent_ref: a Resource reference to a
        certificatemanager.projects.locations.certificateMaps resource for the
        parent of this certificate map entry.
      entry_id: str, the ID of the entry to create.
      hostname: str, hostname of map entry. If None, primary entry is created.
      cert_refs: Resource references to
        certificatemanager.projects.locations.certificates resources to be
        attached to this entry.
      description: str, user-provided description.
      labels: Unified GCP Labels for the resource.

    Returns:
      Operation: the long running operation to create a map entry.
    N)labelshostnamematchercertificatesdescription)parentcertificateMapEntryIdcertificateMapEntry)r   TCertificatemanagerProjectsLocationsCertificateMapsCertificateMapEntriesCreateRequestRelativeNameCertificateMapEntryMatcherValueValuesEnumPRIMARYr   Create)	r   
parent_refentry_idr   	cert_refsr   r   refreqs	            r   r$   z CertificateMapEntryClient.Create"   s    0 --
l
l&&(& MM==$ MM55LLW$8AB	#**,	B# > 
 m 
C ==$$	 Cs   .B.c                     | j                   j                  |j                               }| j                  j	                  |      S )a  Gets certificate map entry.

    Args:
      entry_ref: a Resource reference to a
        certificatemanager.projects.locations.certificateMaps.certificateMapEntries
        resource to get.

    Returns:
      Certificate Map Entry API representation.
    name)r   QCertificatemanagerProjectsLocationsCertificateMapsCertificateMapEntriesGetRequestr    r   Get)r   	entry_refget_reqs      r   r.   zCertificateMapEntryClient.GetH   s?     mmmm##% n 'G==W%%r   c           
          | j                   j                  |j                         ||      }t        j                  | j
                  |||dddd      S )a  List certificate map entries in a given certificate map.

    Args:
      parent_ref: a Resource reference to a
        certificatemanager.projects.locations.certificateMaps resource to list
        entries for.
      limit: int, the total number of results to return from the API.
      page_size: int, the number of results in each batch from the API.
      list_filter: str, filter to apply in the list request.
      order_by: str, fields used for resource ordering.

    Returns:
      A list of the entries in the certificate map.
    )r   filterorderBy	pageTokennextPageTokencertificateMapEntriespageSize)
batch_sizelimitcurrent_token_attributenext_token_attributefieldbatch_size_attribute)r   RCertificatemanagerProjectsLocationsCertificateMapsCertificateMapEntriesListRequestr    r   YieldFromListr   )r   r%   r9   	page_sizelist_filterorder_bylist_reqs          r   ListzCertificateMapEntryClient.ListW   s^    , }}oo&&(h p PH## +,%') )r   c                     | j                   j                  |j                               }| j                  j	                  |      S )a$  Deletes certificate map entry.

    Args:
      entry_ref: a Resource reference to a
        certificatemanager.projects.locations.certificateMaps.certificateMapEntries
        resource to delete.

    Returns:
      Operation: the long running operation to delete certificate map entry.
    r+   )r   TCertificatemanagerProjectsLocationsCertificateMapsCertificateMapEntriesDeleteRequestr    r   Delete)r   r/   
delete_reqs      r   rG   z CertificateMapEntryClient.Deletey   s?     ss##% t 'J==
++r   c                    | j                   j                         }g }|||_        |j                  d       |||_        |j                  d       |H|j
                  j                  |D cg c]  }|j                          c}       |j                  d       dj                  |      }| j                   j                  ||j                         |      }	| j                  j                  |	      S c c}w )aO  Updates a certificate map entry.

    Used for updating labels, description and attached certificates.

    Args:
      entry_ref: a Resource reference to a
        certificatemanager.projects.locations.certificateMaps.certificateMapEntries
        resource.
      labels: unified GCP Labels for the resource.
      description: str, new description
      cert_refs: Resource references to
        certificatemanager.projects.locations.certificates resources to be
        attached to this entry.

    Returns:
      Operation: the long running operation to patch certificate map entry.
    r   r   r   ,)r   r,   
updateMask)r   r!   r   appendr   r   extendr    joinSCertificatemanagerProjectsLocationsCertificateMapsCertificateMapEntriesPatchRequestr   Patch)
r   r/   r   r   r'   certificate_map_entryupdated_fieldsr(   update_mask	patch_reqs
             r   rP   zCertificateMapEntryClient.Patch   s    $ !MM==?N%+"H%*5'M*((//)2
3#3
35N+((>*Kqq1##% r  I ==y)) 4s   ,C3)NN)NNNN)NNN)
__name__
__module____qualname____doc__r   r$   r.   rD   rG   rP    r   r   r	   r	      sA    C= $%L&$  )D,$*r   r	   N)rX   
__future__r   r   r   apitools.base.pyr   *googlecloudsdk.api_lib.certificate_managerr   objectr	   rY   r   r   <module>r^      s(    J &  ' ' AR* R*r   