def __init__(self, global_configs, **kwargs):
        """Initialize.

        Args:
            global_configs (dict): Global configurations.
            **kwargs (dict): The kwargs.
        """
        credentials = api_helpers.get_delegated_credential(
            global_configs.get('domain_super_admin_email'), REQUIRED_SCOPES)

        max_calls, quota_period = api_helpers.get_ratelimiter_config(
            global_configs, API_NAME)

        self.repository = AdminDirectoryRepositoryClient(
            credentials=credentials,
            quota_max_calls=max_calls,
            quota_period=quota_period,
            use_rate_limiter=kwargs.get('use_rate_limiter', True))
    def _get_crm_client(self, user_email):
        """Get a user scoped CloudResourceManagerClient.

        Args:
            user_email (str): The e-mail address of the
                user.

        Returns:
            CloudResourceManagerClient: crm client
        """
        user_scoped_credential = (
            api_helpers.get_delegated_credential(user_email, SCOPES))

        client = CloudResourceManagerClient(
            global_configs=self.inventory_configs.get_api_quota_configs(),
            credentials=user_scoped_credential)

        return client
Exemplo n.º 3
0
    def __init__(self, global_configs, **kwargs):
        """Initialize.

        Args:
            global_configs (dict): Global configurations.
            **kwargs (dict): The kwargs.
        """
        credentials = api_helpers.get_delegated_credential(
            global_configs.get('domain_super_admin_email'), REQUIRED_SCOPES)

        max_calls, quota_period = api_helpers.get_ratelimiter_config(
            global_configs, API_NAME)

        cache_discovery = global_configs[
            'cache_discovery'] if 'cache_discovery' in global_configs else False

        self.repository = GroupsSettingsRepositoryClient(
            credentials=credentials,
            quota_max_calls=max_calls,
            quota_period=quota_period,
            use_rate_limiter=kwargs.get('use_rate_limiter', True),
            cache_discovery=cache_discovery,
            cache=global_configs.get('cache'))
 def test_get_delegated_credential(self, mock_credentials):
     test_delegate = '*****@*****.**'
     credentials = api_helpers.get_delegated_credential(
         test_delegate, FAKE_REQUIRED_SCOPES)
     self.assertEqual(credentials._subject, test_delegate)
     self.assertEqual(credentials._scopes, FAKE_REQUIRED_SCOPES)