
                         h   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  SSSS.r\R(                  " \R*                  R,                  \R*                  R.                  \R*                  R0                  5       " S S\R2                  5      5       rg)z+Command to simulate the IAM policy changes.    )absolute_import)division)unicode_literals)encoding_helper)
list_pager)assist)
operations)base)iam_util)log)
propertiesz^Determine affected recent access attempts before IAM policy
                change deployment.a[        Replay the most recent 1,000 access logs from the past 90 days using the
      simulated policy. For each log entry, the replay determines if setting the
      provided policy on the given resource would result in a change in the access
      state, e.g. a previously granted access becoming denied. Any differences found
      are returned.z      To simulate a permission change of a member on a resource, run:

        $ {command} projects/project-id path/to/policy_file.json

      See https://cloud.google.com/iam/docs/managing-policies for details of policy
      role and member types.)briefDESCRIPTIONEXAMPLESc                   2    \ rS rSrSr\r\S 5       rS r	Sr
g)ReplayRecentAccessesGA4   zNDetermine affected recent access attempts before IAM policy change deployment.c                 H    U R                  SSSS9  U R                  SSSS9  g )NresourceRESOURCEz
        Full resource name to simulate the IAM policy for.

        See: https://cloud.google.com/apis/design/resource_names#full_resource_name.
        )metavarhelppolicy_filePOLICY_FILEaY  
        Path to a local JSON or YAML formatted file containing a valid policy.

        The output of the `get-iam-policy` command is a valid file, as is any
        JSON or YAML file conforming to the structure of a Policy. See
        [the Policy reference](https://cloud.google.com/iam/reference/rest/v1/Policy)
        for details.
        )add_argument)parsers    1lib/surface/iam/simulator/replay_recent_access.pyArgsReplayRecentAccessesGA.Args<   s@    
     
    c                    Sn[         R                  " U5      u  p4[        R                  " UR                  UR
                  5      n[        R                  Ul        UR                  R                  R                  UR                  US9nSR                  [        R                  R                  R                   R#                  SS95      nUR                  R                  U/S9nUR                  US9n	UR%                  U	S9n
UR'                  U
US	9nUR(                  R+                  UR)                  U5      U5      n[,        R.                  R1                  U5      nUR3                  US
R                  UR4                  5      5      n[6        R8                  " UR$                  [6        R:                  " U5      5      nUR<                  (       a  UR<                  R>                  (       d  [@        RB                  RE                  S5        URG                  UR4                  S9nURI                  U5      n[J        RL                  " UUSSSS9$ )Nv1)keyvaluezprojects/{0}/locations/globalT)required)additionalProperties)policyOverlay)config)"googleCloudPolicysimulatorV1Replayparentz&Waiting for operation [{}] to completez'No access changes found in the replay.
)r*   i  replayResultspageSize)
batch_sizefieldbatch_size_attribute)'r   GetSimulatorClientAndMessagesr   ParsePolicyFiler   GoogleIamV1Policy!MAX_LIBRARY_IAM_SUPPORTED_VERSIONversion(GoogleCloudPolicysimulatorV1ReplayConfigPolicyOverlayValueAdditionalPropertyr   formatr   VALUEScoreprojectGet"GoogleCloudPolicysimulatorV1Replay4PolicysimulatorProjectsLocationsReplaysCreateRequestProjectsLocationsReplaysServiceCreater	   ClientFromApiVersionWaitForOperationnamer   JsonToMessageMessageToJsonresultsSummarydifferenceCountr   errPrint9PolicysimulatorProjectsLocationsReplaysResultsListRequest&ProjectsLocationsReplaysResultsServicer   YieldFromList)selfargsapi_versionclientmessagespolicyadditional_propertycreate_replay_parentoverlayr(   replaycreate_replay_requestcreate_replay_responseoperations_clientoperation_response_rawoperation_responselist_replay_result_requestreplay_result_services                     r   RunReplayRecentAccessesGA.RunR   s2   K;;KHF %%d&6&6&.&@&@BF??FN"KK^^qqMM r ):AA&&**D*9;??RR12 S 4G>> ? F888GF$YY+1# Z % $CCJJ..v68MO #))88E.?? H O O"''!)* )6633%%&<=? ,,4F4U4U4e4e	ggmm>? "*!c!c!&& "d "("II##"') )r     N)__name__
__module____qualname____firstlineno____doc___DETAILED_HELPdetailed_helpstaticmethodr   r_   __static_attributes__ra   r    r   r   r   4   s$     W - *,)r    r   N)rf   
__future__r   r   r   apitools.base.pyr   r   googlecloudsdk.api_lib.iamr   $googlecloudsdk.api_lib.iam.simulatorr	   googlecloudsdk.callioper
   googlecloudsdk.command_lib.iamr   googlecloudsdk.corer   r   rg   ReleaseTracksReleaseTrackALPHABETAGACommandr   ra   r    r   <module>rx      s    2 &  ' , ' - ; ( 3 # *	&		 , T..33T5F5F5I5IG)T\\ G)G)r    