
    F                        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 ddl	m
Z
 ddl	mZ dd	lmZ d
ZdddZ ej"                  ej$                  j&                         G d dej(                               Z ej"                  ej$                  j,                         G d de             Z ej"                  ej$                  j0                         G d de             Zy)zICommand to analyze IAM policy asynchronously in the specified root asset.    )absolute_import)division)unicode_literals)client_util)base)flags)utils)logz gcloud asset operations describez      Analyzes IAM policies that match a request asynchronously and writes
      the results to Google Cloud Storage or BigQuery destination.
      a        To find out which users have been granted the
      iam.serviceAccounts.actAs permission on a service account, and write
      analysis results to Google Cloud Storage, run:

        $ {command} --organization=YOUR_ORG_ID --full-resource-name=YOUR_SERVICE_ACCOUNT_FULL_RESOURCE_NAME --permissions='iam.serviceAccounts.actAs' --gcs-output-path='gs://YOUR_BUCKET_NAME/YOUR_OBJECT_NAME'

      To find out which resources a user can access, and write analysis
      results to Google Cloud Storage, run:

        $ {command} --organization=YOUR_ORG_ID --identity='user:u1@foo.com' --gcs-output-path='gs://YOUR_BUCKET_NAME/YOUR_OBJECT_NAME'

      To find out which roles or permissions a user has been granted on a
      project, and write analysis results to BigQuery, run:

        $ {command} --organization=YOUR_ORG_ID --full-resource-name=YOUR_PROJECT_FULL_RESOURCE_NAME --identity='user:u1@foo.com' --bigquery-dataset='projects/YOUR_PROJECT_ID/datasets/YOUR_DATASET_ID' --bigquery-table-prefix='YOUR_BIGQUERY_TABLE_PREFIX'

      To find out which users have been granted the
      iam.serviceAccounts.actAs permission on any applicable resources, and
      write analysis results to BigQuery, run:

        $ {command} --organization=YOUR_ORG_ID --permissions='iam.serviceAccounts.actAs' --bigquery-dataset='projects/YOUR_PROJECT_ID/datasets/YOUR_DATASET_ID' --bigquery-table-prefix='YOUR_BIGQUERY_TABLE_PREFIX'

      )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)AnalyzeIamPolicyLongrunningAnalyzes IAM policies that match a request asynchronously and writes the results to Google Cloud Storage or BigQuery destination.c                     t        j                  |        t        j                  |        t        j                  | d       t        j                  |        t        j
                  |        y )NF)r   AddAnalyzerParentArgsAddAnalyzerSelectorsGroupAddAnalyzerOptionsGroup AddAnalyzerConditionContextGroupAddDestinationGroupparsers    3lib/surface/asset/analyze_iam_policy_longrunning.pyArgsz AnalyzeIamPolicyLongrunning.ArgsD   sJ    	'	##F+	!!&%0	**62	f%    c                 r   t        j                  |j                  |j                  |j                        }t        j                         }|j                  ||      }t        j                  j                  d       t        j                  j                  dj                  t        |j                               y )NzAnalyze IAM Policy in progress.z1Use [{} {}] to check the status of the operation.)asset_utils GetParentNameForAnalyzeIamPolicyorganizationprojectfolderr   "IamPolicyAnalysisLongrunningClientAnalyzer
   statusPrintformatOPERATION_DESCRIBE_COMMANDname)selfargsparentclient	operations        r   RunzAnalyzeIamPolicyLongrunning.RunL   s    994<<6F;;=Fvt,IJJ67JJHOO"INN4 5r   N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr   r-    r   r   r   r   >   s$     J-& &5r   r   c                        e Zd ZdZed        Zy)AnalyzeIamPolicyLongrunningBETAr   c                 .    t         j                  |        y N)r   r   r   s    r   r   z$AnalyzeIamPolicyLongrunningBETA.Args[   s    $$V,r   Nr.   r/   r0   r1   r4   r   r5   r   r   r7   r7   W   s     J- -r   r7   c                        e Zd ZdZed        Zy) AnalyzeIamPolicyLongrunningALPHAr   c                     t         j                  |        t        j                  |       }t        j                  |       y r9   )r7   r   r   GetOrAddOptionGroup(AddAnalyzerIncludeDenyPolicyAnalysisArgs)r   options_groups     r   r   z%AnalyzeIamPolicyLongrunningALPHA.Argsd   s0    #((0 --f5M	22=Ar   Nr:   r5   r   r   r<   r<   `   s     JB Br   r<   N)r1   
__future__r   r   r   googlecloudsdk.api_lib.assetr   googlecloudsdk.callioper    googlecloudsdk.command_lib.assetr   r	   r   googlecloudsdk.corer
   r&   r2   ReleaseTracksReleaseTrackGACommandr   BETAr7   ALPHAr<   r5   r   r   <module>rL      s    P &  ' 4 ( 2 A #? 

@ D%%(()5$,, 5 *50 D%%**+-&A - ,- D%%++,	B'F 	B -	Br   