
                         2   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SKJr  SSKJr  \R,                  " \R.                  R0                  \R.                  R2                  5       " S S\R4                  5      5       rg)z?Command to deauthorize a service agent from managing resources.    )absolute_import)division)unicode_literals)projects_api)lake)storage_util)apis)
exceptions)base)resource_args)utilc                   `    \ rS rSrSrSS0r\S 5       r\R                  " S5      S 5       r
Srg	)
DeauthorizeLake   zDeauthorize a service agent from managing resources.

The service agent for the primary project will have its IAM role revoked from
a secondary project, a Cloud Storage bucket, or a BigQuery dataset.
EXAMPLESa            To deauthorize the service agent in project `test-project` from
          managing resources in the project `test-project2`, run:

            $ {command} --project=test-project --project-resource=test-project2

          To deauthorize the service agent in project `test-project` from
          managing the Cloud Storage bucket `dataplex-storage-bucket`, run:

            $ {command} --project=test-project --storage-bucket-resource=dataplex-storage-bucket

          To deauthorize the service agent in project `test-project` from
          managing the BigQuery dataset `test-dataset` in project
          `test-project2`, run:

            $ {command} --project=test-project --bigquery-dataset-resource=test-dataset --secondary-project=test-project2
          c                     [         R                  " U S5        U R                  SSSS9nUR                  SSS9  UR                  SS	S9  UR                  S
S9nUR                  SSSS9  UR                  SSSS9  g )Nz+to revoke a role from the service agent in.Tz@The resource for which the service agent's role will be revoked.)mutexrequiredhelpz--storage-bucket-resourcezXThe identifier of the Cloud Storage bucket that the service agent will no longer manage.)r   z--project-resourcezVThe identifier of the project whose resources the service agent will no longer manage.z(Fields to identify the BigQuery dataset.z--bigquery-dataset-resourcezTThe identifier of the BigQuery dataset that the service agent will no longer manage.)r   r   z--secondary-projectzDThe identifier of the project where the BigQuery dataset is located.)r   AddProjectArg	add_groupadd_argument)parser
data_groupdataset_groups      )lib/surface/dataplex/lakes/deauthorize.pyArgsDeauthorizeLake.Args:   s    5 !!O " J
 #k   &   ((7 ) M %g  
 	      z-Status code: {status_code}. {status_message}.c                    UR                   R                  R                  5       nS[        [        R
                  " UR                  5      5      -   S-   nUR                  S5      (       a9  [        R                  " [        R                  " UR                  5      SU-   S5      $ UR                  S5      (       a  [        R                  " SS5      R                  UR                   UR"                  S	9n[        R$                  " SS5      R&                  R)                  US
9n[        R*                  " XSS5        [        R$                  " SS5      R&                  R-                  [        R                  " SS5      R/                  UR                   UR"                  US95      $ UR                  S5      (       a9  [0        R2                  " [        R4                  " UR6                  5      SU-   S5      $ g )Nzservice-z(@gcp-sa-dataplex.iam.gserviceaccount.comstorage_bucket_resourcezserviceAccount:zroles/dataplex.serviceAgentbigquery_dataset_resourcebigqueryv2)	datasetId	projectId)request)r%   r&   datasetproject_resource)CONCEPTSprojectParsestrproject_utilGetProjectNumber
projectsIdIsSpecifiedr   $RemoveServiceAccountFromBucketPolicyr   BucketReferencer!   r	   GetMessagesModuleBigqueryDatasetsGetRequestr"   secondary_projectGetClientInstancedatasetsGet%RemoveServiceAccountFromDatasetPolicyPatchBigqueryDatasetsPatchRequestr   RemoveIamPolicyBindingParseProjectr)   )selfargslake_refservice_accountget_dataset_requestr(   s         r   RunDeauthorizeLake.Runa   s    }}$$**,H 3%%	!$" "$NOO 12266

&
&t'C'C
D
o
-/LN N 344 22
d6666.. 7 0  &&
d$HSS1DS%E 
001NP##J5>>DD

 
 T
2
O
O66.. P    
 *++00

#
#D$9$9
:
o
-/LN N ,r    N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrD   __static_attributes__rF   r   r   r   r      sQ      -( $ $L 4457N7Nr   r   N)rK   
__future__r   r   r   +googlecloudsdk.api_lib.cloudresourcemanagerr   googlecloudsdk.api_lib.dataplexr   googlecloudsdk.api_lib.storager   googlecloudsdk.api_lib.utilr	   r
   rN   googlecloudsdk.callioper   #googlecloudsdk.command_lib.dataplexr   #googlecloudsdk.command_lib.projectsr   r.   ReleaseTracksReleaseTrackALPHAGACommandr   rF   r   r   <module>r^      sw    F &  ' D 0 7 , F ( = D D%%++T->->-A-AB]Ndll ]N C]Nr   