
    E                        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	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#S r$S  r%S! r&S" r'S# r(S$ r)S% r*g&))zUtilities for the Config API.    )encoding)apis)waiter)base)
properties)	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   7   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"   I   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   UpdateDeploymentr1   s   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.
r6   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.rA   rH   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_operationsrA   r@   r	   ProgressTrackerWaitFor_MAX_WAIT_TIME_MS_WAIT_CEILING_MS
	operationprogress_messager    operation_refrI   rO   rV   rX   rD   rH   s
            @r   WaitForApplyDeploymentOperationrh      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   ImportStateFilern      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   ExportDeploymentStateFilert      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_revisionsrq   =ConfigProjectsLocationsDeploymentsRevisionsExportStateRequest)"export_revision_state_file_requestr)   r    r!   s       r   ExportRevisionStateFilerz     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r0   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_requestr0   r    r!   s       r   LockDeploymentr   5  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_requestr0   r    r!   s       r   UnlockDeploymentr   O  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   rw   List6ConfigProjectsLocationsDeploymentsRevisionsListRequestr~   s      r   ListRevisionsr   i  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.
r3   r4   r6   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r8   )r   r   r9   r:   r;   r<   previewMetadatar>   r?   r@   rA   rB   )	rC   rD   rE   r!   rF   preview_metadatar>   r?   rH   s	           r   rI   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                   $ rL   rM   rN   s   r   rO   <WaitForCreatePreviewOperation.<locals>.DetailMessageCallback  rQ   r   rR   rS   rW   )r   r   r\   r]   r   r   r^   r   r_   rA   r@   r	   r`   ra   rb   rc   rd   s
            @r   WaitForCreatePreviewOperationr     s     &$$66nn!G 7 - &&((**&
 &>#
 9??N/#333%. >>#+#&& 
-r   c                     U R                   =(       d2    [        R                  R                  R                   R	                  5       $ )zGets location resource from either argument flag or attribute.

Args:
  args: The command-line arguments.

Returns:
  The location string.
)r*   r   VALUESinframanager	GetOrFailargss    r   GetLocationr      s.     
	M*++88AAKKMMr   c                     U R                   =(       d2    [        R                  R                  R                   R	                  5       $ )zGets project resource from either argument flag or attribute.

Args:
  args: The command-line arguments.

Returns:
  The project string.
)projectr   r   corer   r   s    r   
GetProjectr     s.     
	C**//77AACCr   c                     SU  SU S3$ )z.Returns the name of the auto migration config.z	projects/z/locations/z/autoMigrationConfig )r   r*   s     r   GetAutoMigrationConfigNamer     s    WI[
2F	GGr   c                     A [        5       n[        U5      n[        U5      n[        XE5      nXbl        UR                  USS9Ul        SUl        U$ )zASets fields in AutoMigrationConfig request to disable the config.Fr   autoMigrationEnabledauto_migration_enabledr   r   r   r   r   AutoMigrationConfigautoMigrationConfigr-   refr   reqr!   r   r*   config_names          r    SetDisableAutoMigrationInRequestr     s[    	 (t'(*7=+($88U 9 # ,#.	*r   c                 T    A [        U5      n[        U5      n[        X45      Ul        U$ )z=Sets fields in AutoMigrationConfig request to get the config.)r   r   r   r   )r   r   r   r   r*   s        r   SetGetAutoMigrationInRequestr   ,  s*    	t'(':#(	*r   c                     A [        5       n[        U5      n[        U5      n[        XE5      nXbl        UR                  USS9Ul        SUl        U$ )z@Sets fields in AutoMigrationConfig request to enable the config.Tr   r   r   r   s          r   SetEnableAutoMigrationInRequestr   5  s[    	 (t'(*7=+($88T 9 # ,#.	*r   c                 ~    [        5       nUR                  nUR                  R                  UR	                  U S95      $ )a  Calls into the GetTerraformVersion API.

Args:
  name: the fully qualified name of the terraform version, e.g.
    "projects/p/locations/l/terraformVersions/1.2.3".

Returns:
  A messages.TerraformVersion.

Raises:
  HttpNotFoundError: if the terraform version doesn't exist.
r   )r   r   $projects_locations_terraformVersionsr   2ConfigProjectsLocationsTerraformVersionsGetRequestr   s      r   GetTfVersionr   D  sA     &##(		4	4	8	8AAtAL
 r   N)zApplying the deployment)zCreating the preview)+__doc__apitools.base.pyr   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   googlecloudsdk.corer   r   googlecloudsdk.core.consoler	   r   rc   rb   ReleaseTrackALPHAGAr   r   r   r"   r+   r1   rh   rn   rt   rz   r|   r   r   r   r   r   r   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b	N	DH
r   