예제 #1
0
def make_get_service_account_name_call(rpc):
  """Gets the service account name of the app.

  Args:
    rpc: A UserRPC object.

  Returns:
    Service account name of the app.
  """
  request = app_identity_service_pb.GetServiceAccountNameRequest()
  response = app_identity_service_pb.GetServiceAccountNameResponse()

  def get_service_account_name_result(rpc):
    """Checks success, handles exceptions, and returns the converted RPC result.

    This method waits for the RPC if it has not yet finished and calls the
    post-call hooks on the first invocation.

    Args:
      rpc: A UserRPC object.

    Returns:
      A string of the service account name of the app.
    """
    assert rpc.service == _APP_IDENTITY_SERVICE_NAME, repr(rpc.service)
    assert rpc.method == _GET_SERVICE_ACCOUNT_NAME_METHOD_NAME, repr(rpc.method)
    try:
      rpc.check_success()
    except apiproxy_errors.ApplicationError, err:
      raise _to_app_identity_error(err)

    return response.service_account_name()
예제 #2
0
def make_get_service_account_name_call(rpc):
    """Get service account name of the app.

  Args:
    deadline: Optional deadline in seconds for the operation; the default
      is a system-specific deadline (typically 5 seconds).

  Returns:
    Service account name of the app.
  """
    request = app_identity_service_pb.GetServiceAccountNameRequest()
    response = app_identity_service_pb.GetServiceAccountNameResponse()

    if rpc.deadline is not None:
        request.set_deadline(rpc.deadline)

    def get_service_account_name_result(rpc):
        """Check success, handle exceptions, and return converted RPC result.

    This method waits for the RPC if it has not yet finished, and calls the
    post-call hooks on the first invocation.

    Args:
      rpc: A UserRPC object.

    Returns:
      A string which is service account name of the app.
    """
        assert rpc.service == _APP_IDENTITY_SERVICE_NAME, repr(rpc.service)
        assert rpc.method == _GET_SERVICE_ACCOUNT_NAME_METHOD_NAME, repr(
            rpc.method)
        try:
            rpc.check_success()
        except apiproxy_errors.ApplicationError as err:
            raise _to_app_identity_error(err)

        return response.service_account_name()

    rpc.make_call(_GET_SERVICE_ACCOUNT_NAME_METHOD_NAME, request, response,
                  get_service_account_name_result)