Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def all(self):
"""
Gets all saved queries for a project from the Keen IO API.
Master key must be set.
"""
response = self._get_json(HTTPMethods.GET, self.saved_query_url, self._get_master_key())
return response
def all(self):
""" Fetch all Cached Datasets for a Project. Read key must be set.
"""
return self._get_json(HTTPMethods.GET,
self._cached_datasets_url,
self._get_master_key())
def results(self, query_name):
"""
Gets a single saved query with a 'result' object for a project from the
Keen IO API given a query name.
Read or Master key must be set.
"""
url = "{0}/{1}/result".format(self.saved_query_url, query_name)
response = self._get_json(HTTPMethods.GET, url, self._get_read_key())
return response
def get_access_key(self, access_key_id):
"""
Returns details on a particular access key. A master key must be set first.
:param access_key_id: the 'key' value of the access key to retreive data from
"""
url = "{0}/{1}/projects/{2}/keys/{3}".format(self.base_url, self.api_version, self.project_id,
access_key_id)
headers = utilities.headers(self.master_key)
response = self.fulfill(HTTPMethods.GET, url, headers=headers, timeout=self.get_timeout)
self._error_handling(response)
return response.json()
def get_all_collections(self):
"""
Extracts schema for all collections using the Keen IO API. A read key must be set first.
"""
url = "{0}/{1}/projects/{2}/events".format(self.base_url, self.api_version, self.project_id)
headers = utilities.headers(self.read_key)
response = self.fulfill(HTTPMethods.GET, url, headers=headers, timeout=self.get_timeout)
self._error_handling(response)
return response.json()
def results(self, dataset_name, index_by, timeframe):
""" Retrieve results from a Cached Dataset. Read key must be set.
"""
url = "{0}/{1}/results".format(self._cached_datasets_url, dataset_name)
index_by = index_by if isinstance(index_by, str) else json.dumps(index_by)
timeframe = timeframe if isinstance(timeframe, str) else json.dumps(timeframe)
query_params = {
"index_by": index_by,
"timeframe": timeframe
}
return self._get_json(
HTTPMethods.GET, url, self._get_read_key(), params=query_params
)