Connect to stackdriver to fetch logs of each suite-scheduler run.
BUG=chromium:781379
TEST=Ran
'http://localhost:8080/test/stackdriverLogging?start_time=2017-11-1T17:30:00Z&end_time=2017-11-1T18:00:00Z&resource=/cron/test_push'.
Change-Id: Id84fdf6c79f73b7e04ec375e82cc016288c74b1e
diff --git a/rest_client.py b/rest_client.py
index d8545ac..0f1b20c 100644
--- a/rest_client.py
+++ b/rest_client.py
@@ -154,6 +154,34 @@
body=input_event).execute()
+class StackdriverRestClient(object):
+ """REST client for google storage API."""
+
+ def __init__(self, rest_client):
+ """Initialize a REST client for connecting to Google storage API."""
+ self._rest_client = rest_client
+ self._rest_client.create_service()
+
+ def read_logs(self, request):
+ # project_id, page_size, order_by, query_filter=''):
+ """Read the logs of the project_id based on all filters.
+
+ Args:
+ request: a request dict generated by
+ stackdriver_lib.form_logging_client_request.
+
+ Returns:
+ A json object, can be parsed by
+ stackdriver_lib.parse_logging_client_response.
+
+ Raises:
+ apiclient.errors.HttpError
+ """
+ req = self._rest_client.service.entries().list(
+ fields='entries/protoPayload', body=request)
+ return req.execute()
+
+
class SwarmingRestClient(object):
"""REST client for swarming proxy API."""