
    ;                        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Jr  SrSrSr\R&                  R(                  S\R&                  R*                  S0r\R&                  R*                  4S jr\R&                  R*                  S4S jrS rS rS r S"S jrS rS rS rS r S r!S r"S r#S r$S r% S#S  jr&g!)$zUtilities for the Config API.    )absolute_import)division)unicode_literals)encoding)apis)waiter)base)	resources)progress_trackerconfigi'  iˤ v1alpha2v1c                 F    [         R                  " [        [        U    5      $ )zReturns the messages module for Config API.

Args:
  release_track: The desired value of the enum
    googlecloudsdk.calliope.base.ReleaseTrack.

Returns:
  Module containing the definitions of messages for Config API.
)r   GetMessagesModule	_API_NAMERELEASE_TRACK_TO_API_VERSION)release_tracks    >lib/googlecloudsdk/api_lib/infra_manager/configmanager_util.pyr   r   *   s"     
		-m<
     Tc                 N    [         R                  " [        [        U    U(       + S9$ )a  Returns an instance of the Config client.

Args:
  release_track: The desired value of the enum
    googlecloudsdk.calliope.base.ReleaseTrack.
  use_http: bool, True to create an http object for this client.

Returns:
  base_api.BaseApiClient, An instance of the Config client.
)no_http)r   GetClientInstancer   r   )r   use_https     r   r   r   9   s'     
		"=1|
 r   c                 ~    [        5       nUR                  nUR                  R                  UR	                  U S95      $ )zCalls into the GetDeployment API.

Args:
  name: the fully qualified name of the deployment, e.g.
    "projects/p/locations/l/deployments/d".

Returns:
  A messages.Deployment.

Raises:
  HttpNotFoundError: if the deployment doesn't exist.
name)r   MESSAGES_MODULEprojects_locations_deploymentsGet,ConfigProjectsLocationsDeploymentsGetRequest)r   clientmessagess      r   GetDeploymentr#   K   sA     &##(		.	.	2	2;;;F
 r   c                     [        5       nUR                  nUR                  R                  UR	                  X US95      $ )a  Calls into the CreateDeployment API.

Args:
  deployment: a messages.Deployment resource (containing properties like the
    blueprint).
  deployment_id: the ID of the deployment, e.g. "my-deployment" in
    "projects/p/locations/l/deployments/my-deployment".
  location: the location in which to create the deployment.

Returns:
  A messages.OperationMetadata representing a long-running operation.
)parent
deploymentdeploymentId)r   r   r   Create/ConfigProjectsLocationsDeploymentsCreateRequest)r&   deployment_idlocationr!   r"   s        r   CreateDeploymentr,   _   sH     &##(		.	.	5	5>>} ? 
 r   c                     [        5       nUR                  nUR                  R                  UR	                  XSS95      $ )a  Calls into the UpdateDeployment API.

Args:
  deployment: a messages.Deployment resource (containing properties like the
    blueprint).
  deployment_full_name: the fully qualified name of the deployment.

Returns:
  A messages.OperationMetadata representing a long-running operation.
N)r&   r   
updateMask)r   r   r   Patch.ConfigProjectsLocationsDeploymentsPatchRequest)r&   deployment_full_namer!   r"   s       r   UpdateDeploymentr2   u   sH     &##(		.	.	4	4==t > 
 r   c           
      z  ^	 [        5       n[        R                  R                  U R                  SS9n[
        R                  " UR                  UR                  5      m	ST	l	        U	4S jnU	4S jnSR                  U5      n[        R                  " UUUS9n[
        R                  " T	UUUU[        [        S9nU$ )	a   Waits for the given "apply deployment" LRO to complete.

Args:
  operation: the operation to poll.
  progress_message: string to display for default progress_tracker.

Raises:
  apitools.base.py.HttpError: if the request returns an HTTP error.

Returns:
  A messages.Deployment resource.
$config.projects.locations.operations
collection c                   > [        5       n[        R                  " UR                  5      n[        R                  " UR
                  U5      R                  nSnSnUb  UR                  nUR                  nUb  Uc  SR                  U5      Tl
        OUb  Ub  SR                  Xg5      Tl
        U R                  5         ga  Updates the progress tracker with the result of the operation.

Args:
  tracker: The ProgressTracker for the operation.
  result: the operation poll result.
  unused_status: map of stages with key as stage key (string) and value is
    the progress_tracker.Stage.
r7   Nz	logs={0} zlogs={0}, step={1} )r   r   MessageToJsonmetadataJsonToMessageOperationMetadatadeploymentMetadatalogsstepformatdetailed_messageTick)	trackerresultunused_statusr"   json_valdeployment_metadatar?   r@   pollers	           r   TrackerUpdateFunc:WaitForApplyDeploymentOperation.<locals>.TrackerUpdateFunc   s     !"H %%foo6H"00""H  DD& %%d %%dDL + 2 24 8f		d. 5 < <T HfLLNr   c                     > T R                   $ zLReturns the detailed progress message to be updated on the progress tracker.rB   rI   s   r   DetailMessageCallback>WaitForApplyDeploymentOperation.<locals>.DetailMessageCallback        """r   !Aborting wait for operation {0}.
messagedetail_message_callbackaborted_messagecustom_trackertracker_update_funcmax_wait_mswait_ceiling_ms)r   r
   REGISTRYParseRelativeNamer   r   CloudOperationPollerr   projects_locations_operationsrB   rA   r   ProgressTrackerWaitFor_MAX_WAIT_TIME_MS_WAIT_CEILING_MS
	operationprogress_messager!   operation_refrJ   rP   rW   rY   rE   rI   s
            @r   WaitForApplyDeploymentOperationri      s     &$$66nn!G 7 - &&++**&
 &>#
 9??N/#333%. >>#+#&& 
-r   c                 ~    [        5       nUR                  nUR                  R                  UR	                  XS95      $ )a  Calls ImportStateFile API.

Args:
  import_state_file_request: a messages.ImportStateFileRequest.
  deployment_id: the ID of the deployment, e.g. "my-deployment" in
    "projects/p/locations/l/deployments/my-deployment".

Returns:
  (Statefile) The response message.
)importStatefileRequestr%   )r   r   r   ImportState4ConfigProjectsLocationsDeploymentsImportStateRequest)import_state_file_requestr*   r!   r"   s       r   ImportStateFilero      sG     &##(		.	.	:	:CC!: D 
 r   c                     [        5       nUR                  nUR                  R                  UR	                  U US95      $ )aO  Calls ExportDeploymentStateFile API.

Args:
  export_deployment_state_file_request: A ExportDeploymentStatefileRequest
    resource to be passed as the request body.
  deployment_id: the ID of the deployment, e.g. "my-deployment" in
    "projects/p/locations/l/deployments/my-deployment".

Returns:
  (Statefile) The response message.
) exportDeploymentStatefileRequestr%   )r   r   r   ExportState4ConfigProjectsLocationsDeploymentsExportStateRequest)$export_deployment_state_file_requestr*   r!   r"   s       r   ExportDeploymentStateFileru      sJ     &##(		.	.	:	:CC+O D 
 r   c                     [        5       nUR                  nUR                  R                  UR	                  U US95      $ )aT  Calls ExportDeploymentRevisionsStateFile API.

Args:
  export_revision_state_file_request: A ExportRevisionStatefileRequest
    resource to be passed as the request body.
  deployment_id: the ID of the deployment, e.g. "my-deployment" in
    "projects/p/locations/l/deployments/my-deployment".

Returns:
  (Statefile) The response message.
)exportRevisionStatefileRequestr%   )r   r   (projects_locations_deployments_revisionsrr   =ConfigProjectsLocationsDeploymentsRevisionsExportStateRequest)"export_revision_state_file_requestr*   r!   r"   s       r   ExportRevisionStateFiler{   	  sJ     &##(		8	8	D	DLL)K M 
 r   c                 ~    [        5       nUR                  nUR                  R                  UR	                  U S95      $ )zCalls ExportLock API.

Args:
  deployment_full_name: string, the fully qualified name of the deployment,
    e.g. "projects/p/locations/l/deployments/d".

Returns:
  A lock info response.
r   )r   r   r   
ExportLock3ConfigProjectsLocationsDeploymentsExportLockRequestr1   r!   r"   s      r   r}   r}   #  sG     &##(		.	.	9	9BB# C 
 r   c                     [        5       nUR                  nUR                  R                  UR	                  U US95      $ )a+  Calls deployment Lock API.

Args:
  lock_deployment_request: A LockDeploymentRequest resource to be passed as
    the request body
  deployment_full_name: the ID of the deployment, e.g. "my-deployment" in
    "projects/p/locations/l/deployments/my-deployment".

Returns:
  A long running operation.
)lockDeploymentRequestr   )r   r   r   Lock-ConfigProjectsLocationsDeploymentsLockRequest)lock_deployment_requestr1   r!   r"   s       r   LockDeploymentr   7  sI     &##(		.	.	3	3<< 7# = 
 r   c                     [        5       nUR                  nUR                  R                  UR	                  U US95      $ )a8  Calls deployment Unlock API.

Args:
  unlock_deployment_request: A UnlockDeploymentRequest resource to be passed
    as the request body
  deployment_full_name: the ID of the deployment, e.g. "my-deployment" in
    format "projects/p/locations/l/deployments/my-deployment".

Returns:
  A long running operation.
)unlockDeploymentRequestr   )r   r   r   Unlock/ConfigProjectsLocationsDeploymentsUnlockRequest)unlock_deployment_requestr1   r!   r"   s       r   UnlockDeploymentr   Q  sI     &##(		.	.	5	5>>";# ? 
 r   c                 ~    [        5       nUR                  nUR                  R                  UR	                  U S95      $ )a  Lists all revisions for a deployment.

Args:
  deployment_full_name: the fully qualified name of the deployment, e.g.
    "projects/p/locations/l/deployments/d".

Returns:
  (ListRevisionsResponse) The response message.

Raises:
  HttpNotFoundError: if the deployment doesn't exist.
)r%   )r   r   rx   List6ConfigProjectsLocationsDeploymentsRevisionsListRequestr   s      r   ListRevisionsr   k  sG     &##(		8	8	=	=EE% F 
 r   c                     [        5       nUR                  nUR                  R                  UR	                  U US95      $ )a-  Calls ExportPreviewResult API.

Args:
  export_preview_result_request: A ExportPreviewResultRequest
    resource to be passed as the request body.
  preview_id: the ID of the preview, e.g. "my-preview" in
    "projects/p/locations/l/previews/my-preview".

Returns:
  (Statefile) The response message.
)exportPreviewResultRequestr%   )r   r   projects_locations_previewsExport,ConfigProjectsLocationsPreviewsExportRequest)export_preview_result_request
preview_idr!   r"   s       r   ExportPreviewResultr     sI     &##(		+	+	2	2;;%B < 
 r   c                     [        5       nUR                  nUR                  R                  UR	                  X US95      $ )au  Calls into the CreatePreview API.

Args:
  preview: a messages.Preview resource (containing properties like the
    blueprint).
  preview_id: the ID of the preview, e.g. "my-preview" in
    "projects/p/locations/l/previews/my-preview".
  location: the location in which to create the preview.

Returns:
  A messages.OperationMetadata representing a long-running operation.
)r%   preview	previewId)r   r   r   r(   ,ConfigProjectsLocationsPreviewsCreateRequest)r   r   r+   r!   r"   s        r   CreatePreviewr     sH     &##(		+	+	2	2;;j < 
 r   c           
      z  ^	 [        5       n[        R                  R                  U R                  SS9n[
        R                  " UR                  UR                  5      m	ST	l	        U	4S jnU	4S jnSR                  U5      n[        R                  " UUUS9n[
        R                  " T	UUUU[        [        S9nU$ )	a  Waits for the given "create preview" LRO to complete.

Args:
  operation: the operation to poll.
  progress_message: string to display for default progress_tracker.

Raises:
  apitools.base.py.HttpError: if the request returns an HTTP error.

Returns:
  A messages.Preview resource.
r4   r5   r7   c                   > [        5       n[        R                  " UR                  5      n[        R                  " UR
                  U5      R                  nSnSnUb  UR                  nUR                  nUb  Uc  SR                  U5      Tl
        OUb  Ub  SR                  Xg5      Tl
        U R                  5         gr9   )r   r   r:   r;   r<   r=   previewMetadatar?   r@   rA   rB   rC   )	rD   rE   rF   r"   rG   preview_metadatar?   r@   rI   s	           r   rJ   8WaitForCreatePreviewOperation.<locals>.TrackerUpdateFunc  s     !"H %%foo6H--""Ho  DD#""d""dDL + 2 24 8f		d. 5 < <T HfLLNr   c                     > T R                   $ rM   rN   rO   s   r   rP   <WaitForCreatePreviewOperation.<locals>.DetailMessageCallback  rR   r   rS   rT   rX   )r   r
   r]   r^   r   r   r_   r   r`   rB   rA   r   ra   rb   rc   rd   re   s
            @r   WaitForCreatePreviewOperationr     s     &$$66nn!G 7 - &&((**&
 &>#
 9??N/#333%. >>#+#&& 
-r   N)zApplying the deployment)zCreating the preview)'__doc__
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper	   googlecloudsdk.corer
   googlecloudsdk.core.consoler   r   rd   rc   ReleaseTrackALPHAGAr   r   r   r#   r,   r2   ri   ro   ru   r{   r}   r   r   r   r   r   r    r   r   <module>r      s    $ &  ' % , . ( ) 8	   '  	Z$   %)$5$5$8$8  %)$5$5$8$84 $(,* !:Nb*44(44,4. !7Nr   