Пример #1
0
  def Run(self, args):
    """Run 'service-management api-keys create'.

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

    Returns:
      The response from the keys API call.
    """
    messages = services_util.GetApiKeysMessagesModule()
    client = services_util.GetApiKeysClientInstance()

    # Construct the List API Key request object
    request = messages.ApikeysProjectsApiKeysListRequest(
        projectId=properties.VALUES.core.project.Get(required=True),
        pageSize=args.limit)

    return client.projects_apiKeys.List(request)
Пример #2
0
    def Run(self, args):
        """Run 'service-management api-keys create'.

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

    Returns:
      The response from the api-keys API call.
    """
        client = services_util.GetApiKeysClientInstance()

        # Verify Android command-line arguments, if applicable
        if args.type == 'android':
            self._VerifyAndroidPackageArgs(args.allowed_entities)

        # Construct the Create API Key request object
        request = self._ConstructApiKeyRequest(
            properties.VALUES.core.project.Get(required=True), args.type,
            args.allowed_entities, args.display_name)

        return client.projects_apiKeys.Create(request)
Пример #3
0
  def Run(self, args):
    """Run 'service-management api-keys delete'.

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

    Returns:
      The response from the keys API call.
    """
    messages = services_util.GetApiKeysMessagesModule()
    client = services_util.GetApiKeysClientInstance()

    # Construct the Delete API Key request object
    request = messages.ApikeysProjectsApiKeysDeleteRequest(
        projectId=properties.VALUES.core.project.Get(required=True),
        keyId=args.key)

    result = client.projects_apiKeys.Delete(request)

    # Note that we expect an empty proto as a result (google.protobuf.Empty).
    # If that's what we receive, we can assume success.
    return result or {'key': args.key, 'success': True}
Пример #4
0
 def apikeys_client(self):
     return services_util.GetApiKeysClientInstance()