
    
                         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  G d	 d
ej                        Zy)zHCommand to get information about a principal's permissions on a service.    )absolute_import)division)unicode_literals)services_util)base)arg_parsers)common_flagsc                   &    e Zd ZdZed        Zd Zy)CheckIamPolicya  Returns information about a principal's permissions on a service.

  This command lists the permissions that the current authenticated
  gcloud user has for a service. For example, if the authenticated user is
  able to delete the service, `servicemanagement.services.delete` will
  be among the returned permissions.

  ## EXAMPLES

  To check the permissions for the currently authenticated gcloud, run:

    $ {command} my_produced_service_name
  c                 R    t        j                  d      }|j                  |        y)zArgs is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go
          on the command line after this command. Positional arguments are
          allowed.
    z!for which to check the IAM policy)suffixN)r	   producer_service_flagAddToParser)parserservice_flags     2lib/surface/endpoints/services/check_iam_policy.pyArgszCheckIamPolicy.Args+   s%      5524LV$    c                 2   t        j                         }t        j                         }t         j                  }|j                  }t        j                  |j                        } |||j                  |            }|j                  j                  |      S )zRun 'service-management check-access'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      The response from the access API call.
    )permissions)
servicesIdtestIamPermissionsRequest)r   GetMessagesModuleGetClientInstanceALL_IAM_PERMISSIONS2ServicemanagementServicesTestIamPermissionsRequestr   GetServiceNameFromArgserviceTestIamPermissionsRequestservicesTestIamPermissions)selfargsmessagesclientall_iam_permissionsquery_requestr   requests           r   RunzCheckIamPolicy.Run8   s     ..0H,,.F';; OOM//=G"*"D"D+ #E #-.G
 ??--g66r   N)__name__
__module____qualname____doc__staticmethodr   r)    r   r   r   r      s      
% 
%7r   r   N)r-   
__future__r   r   r    googlecloudsdk.api_lib.endpointsr   googlecloudsdk.callioper   $googlecloudsdk.command_lib.endpointsr   r	   Commandr   r/   r   r   <module>r5      s0     O &  ' : ( < =47T\\ 47r   