
    l                        d Z ddlmZ ddlmZ ddlmZ ddl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e
j                  j                  fdZ G d de      Zy)z2The Secure Source Manager instances client module.    )absolute_import)division)unicode_literalsN)apis)waiter)base)	resourcesv1c                 X    t         j                  |       }t        j                  d|      S Nsecuresourcemanager)VERSION_MAPgetr   GetMessagesModulerelease_trackapi_versions     ;lib/googlecloudsdk/api_lib/securesourcemanager/instances.pyr   r      $    .+			 5{	CC    c                 X    t         j                  |       }t        j                  d|      S r   )r   r   r   GetClientInstancer   s     r   r   r   $   r   r   c                   \    e Zd ZdZd Zd Zd Zd Zd ej                  d      fd	Z
d
 Zy)InstancesClientz+Client for Secure Source Manager instances.c                 D   t        t        j                  j                        | _        t        t        j                  j                        | _        | j                  j                  | _        t        j                         | _        | j                  j                  dd       y )Nr   r
   )r   r   ReleaseTrackALPHAclientr   messagesprojects_locations_instances_servicer	   Registry_resource_parserRegisterApiByName)selfs    r   __init__zInstancesClient.__init__,   sk    #D$5$5$;$;<DK%d&7&7&=&=>DMKK<<DM%..0D++,A4Hr   c                    d}|r| j                   j                  |||      }d}|r| j                   j                  |      }| j                   j                  |||      }	| j                   j	                  |	|j
                  |j                         j                               }
| j                  j                  |
      S )aX  Create a new Secure Source Manager instance.

    Args:
      instance_ref: a resource reference to
        securesourcemanager.projects.locations.instances.
      kms_key: customer managed encrypted key to create instance.
      is_private:  boolean indicator for private instance.
      ca_pool: path of ca pool for private instance.
      enable_workforce_identity_federation: boolean indicator for workforce
        identity federation.
      psc_allowed_projects: list of projects allowed to connect to the instance
        via Private Service Connect.

    Returns:
      Created instance.
    N)	isPrivatecaPoolpscAllowedProjects)enabled)kmsKeyprivateConfig!workforceIdentityFederationConfig)instance
instanceIdparent)
r   PrivateConfig!WorkforceIdentityFederationConfigInstance:SecuresourcemanagerProjectsLocationsInstancesCreateRequestinstancesIdParentRelativeNamer!   Create)r%   instance_refkms_key
is_privateca_pool$enable_workforce_identity_federationpsc_allowed_projectsprivate_config$workforce_identity_federation_configr/   
create_reqs              r   r9   zInstancesClient.Create3   s    2 N}}221 3 n
 ,0(+
--
9
9: :  +
 }}%%$*N & H YY++""$113 Z J
 ==
++r   c                     | j                   j                  |j                               }| j                  j	                  |      S )zDelete a Secure Source Manager instance.

    Args:
      instance_ref: a resource reference to
        securesourcemanager.projects.locations.instances.

    Returns:
      None
    name)r   :SecuresourcemanagerProjectsLocationsInstancesDeleteRequestr8   r!   Delete)r%   r:   
delete_reqs      r   rG   zInstancesClient.Deleteg   sA     YY&&( Z J ==
++r   c                 N    | j                   j                  |j                  d      S )zKConverts an operation to a resource that can be used with `waiter.WaitFor`.z1securesourcemanager.projects.locations.operations)r#   ParseRelativeNamerE   )r%   	operations     r   GetOperationRefzInstancesClient.GetOperationRefv   s%      22K r   TiX  )secondsc                 "   |r?t        j                  | j                  j                  | j                  j                        }n)t        j
                  | j                  j                        }t        j                  ||||j                  dz        S )a  Waits for a Secure Source Manager operation to complete.

      Polls the Secure Source Manager Operation service until the operation
      completes, fails, or max_wait_seconds elapses.

    Args:
      operation_ref: a resource reference created by GetOperationRef describing
        the operation.
      message: a message to display to the user while they wait.
      has_result: If True, the function will return the target of the operation
        (i.e. the Secure Source Manager instance) when it completes. If False,
        nothing will be returned (useful for Delete operations).
      max_wait: The time to wait for the operation to complete before returning.

    Returns:
      A Secure Source Manager resource or None
    i  )max_wait_ms)r   CloudOperationPollerr   r    projects_locations_operationsCloudOperationPollerNoResourcesWaitForrM   )r%   operation_refmessage
has_resultmax_waitpollers         r   WaitForOperationz InstancesClient.WaitForOperation|   sw    0 **
++
2
2
++
3
3f
 55
++
3
3f >>wH4D4Dt4K r   c                     | j                   j                  dj                  |j                         |            }| j                  j                  |      j                  j                  }dj                  |      S )z(Get the API URL of a Cloud Git instance.z{}/instances/{}rD   zhttps://{}/)r   7SecuresourcemanagerProjectsLocationsInstancesGetRequestformatr8   r!   Get
hostConfigapi)r%   location_refinstance_idget_reqapi_base_urls        r   GetApiBaseUrlzInstancesClient.GetApiBaseUrl   sp     	MM"))))+[ 	N 	
  ==$$W-88<<L--r   N)__name__
__module____qualname____doc__r&   r9   rG   rL   datetime	timedeltarY   rd    r   r   r   r   )   s;    3I2,h, !x!!#.$L
.r   r   )rh   
__future__r   r   r   ri   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   googlecloudsdk.corer	   r   r   r   r   r   objectr   rk   r   r   <module>rq      st    9 &  '  , . ( )  &&- %)$5$5$;$; D
 %)$5$5$;$; D
C.f C.r   