micromegas 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: micromegas
3
- Version: 0.1.0
4
- Summary:
3
+ Version: 0.1.1
4
+ Summary: Python analytics client for https://github.com/madesroches/micromegas/
5
5
  Author: Marc-Antoine Desroches
6
6
  Author-email: madesroches@gmail.com
7
7
  Requires-Python: >=3.10,<4.0
@@ -1 +1,2 @@
1
1
  from . import request
2
+ from . import client
@@ -0,0 +1,56 @@
1
+ from . import request
2
+
3
+
4
+ class Client:
5
+ def __init__(self, base_url, headers={}):
6
+ self.analytics_base_url = base_url + "analytics/"
7
+ self.headers = headers
8
+
9
+ def query_processes(self, begin, end, limit):
10
+ return request.request(
11
+ self.analytics_base_url + "query_processes",
12
+ {"begin": begin.isoformat(), "end": end.isoformat(), "limit": limit},
13
+ headers=self.headers,
14
+ )
15
+
16
+ def query_streams(self, begin, end, limit, tag_filter=None):
17
+ args = {
18
+ "begin": begin.isoformat(),
19
+ "end": end.isoformat(),
20
+ "limit": limit,
21
+ }
22
+
23
+ if tag_filter is not None:
24
+ args["tag_filter"] = tag_filter
25
+
26
+ return request.request(
27
+ self.analytics_base_url + "query_streams",
28
+ args,
29
+ headers=self.headers,
30
+ )
31
+
32
+ def query_blocks(self, begin, end, limit, stream_id):
33
+ args = {
34
+ "begin": begin.isoformat(),
35
+ "end": end.isoformat(),
36
+ "limit": limit,
37
+ "stream_id": stream_id,
38
+ }
39
+
40
+ return request.request(
41
+ self.analytics_base_url + "query_blocks",
42
+ args,
43
+ headers=self.headers,
44
+ )
45
+
46
+ def query_spans(self, begin, end, limit, stream_id):
47
+ return request.request(
48
+ self.analytics_base_url + "query_spans",
49
+ {
50
+ "begin": begin.isoformat(),
51
+ "end": end.isoformat(),
52
+ "limit": limit,
53
+ "stream_id": stream_id,
54
+ },
55
+ headers=self.headers,
56
+ )
@@ -3,9 +3,11 @@ import io
3
3
  import pyarrow.parquet as pq
4
4
  import requests
5
5
 
6
- def request(url, args):
6
+
7
+ def request(url, args, headers={}):
7
8
  response = requests.post(
8
9
  url,
10
+ headers=headers,
9
11
  data=cbor2.dumps(args),
10
12
  )
11
13
  if response.status_code != 200:
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "micromegas"
3
- version = "0.1.0"
4
- description = ""
3
+ version = "0.1.1"
4
+ description = "Python analytics client for https://github.com/madesroches/micromegas/"
5
5
  authors = ["Marc-Antoine Desroches <madesroches@gmail.com>"]
6
6
  readme = "README.md"
7
7
 
File without changes