diaspora-event-sdk 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl

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
  import os
2
2
 
3
3
 
4
- TOKEN_EXCHANGE = "http://3.220.110.101"
4
+ TOKEN_EXCHANGE = "http://3.220.110.101/"
5
5
  DIASPORA_RESOURCE_SERVER = "2b9d2f5c-fa32-45b5-875b-b24cd343b917"
6
6
 
7
7
 
@@ -89,16 +89,6 @@ class Client:
89
89
  "endpoint": tokens["endpoint"],
90
90
  }
91
91
 
92
- # @requires_login # TODO
93
- # def get_secret_key(self):
94
- # tokens = self.login_manager._token_storage.get_token_data(
95
- # DIASPORA_RESOURCE_SERVER
96
- # )
97
- # if tokens is None or "secret_key" not in tokens:
98
- # return None
99
- # else:
100
- # return tokens["secret_key"]
101
-
102
92
  @requires_login
103
93
  def put_secret_key(self, access_key, secret_key, endpoint):
104
94
  tokens = self.login_manager._token_storage.get_token_data(
@@ -133,54 +123,74 @@ class Client:
133
123
  """
134
124
  Registers a new topic under the user's OpenID.
135
125
  """
136
- return self.web_client.register_topic(self.subject_openid, topic)
126
+ return self.web_client.register_topic(self.subject_openid, topic, "register")
137
127
 
138
128
  @requires_login
139
129
  def unregister_topic(self, topic):
140
130
  """
141
131
  Unregisters a topic from the user's OpenID.
142
132
  """
143
- return self.web_client.unregister_topic(self.subject_openid, topic)
133
+ return self.web_client.register_topic(self.subject_openid, topic, "unregister")
134
+
135
+ @requires_login
136
+ def get_topic_configs(self, topic):
137
+ """
138
+ Get topic configurations.
139
+ """
140
+ return self.web_client.get_topic_configs(self.subject_openid, topic)
144
141
 
145
142
  @requires_login
146
- def register_topic_for_user(self, topic, user):
143
+ def update_topic_configs(self, topic, configs):
144
+ """
145
+ Set topic configurations.
146
+ """
147
+ return self.web_client.update_topic_configs(self.subject_openid, topic, configs)
148
+
149
+ @requires_login
150
+ def update_topic_partitions(self, topic, new_partitions):
151
+ """
152
+ Adjust topic number of partitions
153
+ """
154
+ return self.web_client.update_topic_partitions(self.subject_openid, topic, new_partitions)
155
+
156
+ @requires_login
157
+ def grant_user_access(self, topic, user):
147
158
  """
148
159
  Registers a new topic under the user's OpenID.
149
160
  """
150
- return self.web_client.register_topic_for_user(self.subject_openid, topic, user)
161
+ return self.web_client.grant_user_access(self.subject_openid, topic, user, "grant")
151
162
 
152
163
  @requires_login
153
- def unregister_topic_for_user(self, topic, user):
164
+ def revoke_user_access(self, topic, user):
154
165
  """
155
166
  Unregisters a topic from the user's OpenID.
156
167
  """
157
- return self.web_client.unregister_topic_for_user(self.subject_openid, topic, user)
158
-
168
+ return self.web_client.grant_user_access(self.subject_openid, topic, user, "revoke")
159
169
 
160
170
  @requires_login
161
- def list_functions(self):
171
+ def list_triggers(self):
162
172
  """
163
173
  Retrieves the list of functions associated with the user's OpenID.
164
174
  """
165
- return self.web_client.list_functions(self.subject_openid)
175
+ return self.web_client.list_triggers(self.subject_openid)
166
176
 
167
177
  @requires_login
168
- def register_function(self, topic, function, function_configs):
178
+ def create_trigger(self, topic, function, function_configs):
169
179
  """
170
180
  Registers a new functions under the user's OpenID.
171
181
  """
172
- return self.web_client.register_function(self.subject_openid, topic, function, function_configs)
182
+ return self.web_client.create_trigger(self.subject_openid, topic, function, "create", function_configs)
173
183
 
174
184
  @requires_login
175
- def unregister_function(self, topic, function):
185
+ def delete_trigger(self, topic, function):
176
186
  """
177
187
  Unregisters a functions from the user's OpenID.
178
188
  """
179
- return self.web_client.unregister_function(self.subject_openid, topic, function)
180
-
189
+ return self.web_client.create_trigger(self.subject_openid, topic, function, "delete", {})
190
+
181
191
  @requires_login
182
- def update_trigger_config(self, trigger_uuid, trigger_configs):
192
+ def update_trigger(self, trigger_uuid, trigger_configs):
183
193
  """
184
194
  Update a functions's trigger'.
185
195
  """
186
- return self.web_client.update_function_trigger(self.subject_openid, trigger_uuid, trigger_configs)
196
+ return self.web_client.update_trigger(self.subject_openid, trigger_uuid, trigger_configs)
@@ -1,5 +1,5 @@
1
1
  from typing import Optional
2
-
2
+ import json
3
3
  import globus_sdk
4
4
  from diaspora_event_sdk.sdk.utils.uuid_like import UUID_LIKE_T
5
5
 
@@ -24,69 +24,76 @@ class WebClient(globus_sdk.BaseClient):
24
24
  self.user_app_name = app_name
25
25
 
26
26
  def create_key(self, subject: UUID_LIKE_T) -> globus_sdk.GlobusHTTPResponse:
27
- return self.post("/v1/create_key", headers={"Subject": str(subject)})
27
+ return self.get("/api/v2/create_key", headers={"Subject": str(subject)})
28
28
 
29
29
  def list_topics(self, subject: UUID_LIKE_T) -> globus_sdk.GlobusHTTPResponse:
30
- return self.get("/v1/list_topics", headers={"Subject": str(subject)})
30
+ return self.get("/api/v2/topics", headers={"Subject": str(subject)})
31
31
 
32
32
  def register_topic(
33
- self, subject: UUID_LIKE_T, topic: str
33
+ self, subject: UUID_LIKE_T, topic: str, action: str
34
34
  ) -> globus_sdk.GlobusHTTPResponse:
35
- return self.post(
36
- "/v1/register_topic", headers={"Subject": str(subject), "Topic": topic}
35
+ return self.put(
36
+ f"/api/v2/topic/{topic}", headers={"Subject": str(subject), "Action": action}
37
37
  )
38
38
 
39
- def unregister_topic(
39
+ def get_topic_configs(
40
40
  self, subject: UUID_LIKE_T, topic: str
41
41
  ) -> globus_sdk.GlobusHTTPResponse:
42
- return self.post(
43
- "/v1/unregister_topic", headers={"Subject": str(subject), "Topic": topic}
42
+ return self.get(
43
+ f"/api/v2/topic/{topic}",
44
+ headers={"Subject": str(subject), "Topic": topic},
45
+ # data=json.dumps(configs).encode("utf-8")
44
46
  )
45
47
 
46
- def register_topic_for_user(
47
- self, subject: UUID_LIKE_T, topic: str, user: UUID_LIKE_T
48
+ def update_topic_configs(
49
+ self, subject: UUID_LIKE_T, topic: str, configs: dict
48
50
  ) -> globus_sdk.GlobusHTTPResponse:
49
51
  return self.post(
50
- "/v1/register_topic_for_user",
51
- headers={"Subject": str(
52
- subject), "Topic": topic, "User": str(user)}
52
+ f"/api/v2/topic/{topic}",
53
+ headers={"Subject": str(subject), "Topic": topic,
54
+ "Content-Type": "text/plain"},
55
+ data=json.dumps(configs).encode("utf-8")
53
56
  )
54
57
 
55
- def unregister_topic_for_user(
56
- self, subject: UUID_LIKE_T, topic: str, user: UUID_LIKE_T
58
+ def update_topic_partitions(
59
+ self, subject: UUID_LIKE_T, topic: str, new_partitions: int
57
60
  ) -> globus_sdk.GlobusHTTPResponse:
58
61
  return self.post(
59
- "/v1/unregister_topic_for_user",
60
- headers={"Subject": str(
61
- subject), "Topic": topic, "User": str(user)}
62
+ f"/api/v2/topic/{topic}/partitions",
63
+ headers={"Subject": str(subject), "Topic": topic,
64
+ "NewPartitions": str(new_partitions)},
62
65
  )
63
66
 
64
- def list_functions(self, subject: UUID_LIKE_T) -> globus_sdk.GlobusHTTPResponse:
65
- return self.get("/v1/list_functions", headers={"Subject": str(subject)})
66
-
67
- def register_function(
68
- self, subject: UUID_LIKE_T, topic: str, function: str,
69
- function_configs: dict
67
+ def grant_user_access(
68
+ self, subject: UUID_LIKE_T, topic: str, user: UUID_LIKE_T, action: str
70
69
  ) -> globus_sdk.GlobusHTTPResponse:
71
70
  return self.post(
72
- "/v1/register_function",
73
- headers={"Subject": str(subject), "Topic": topic,
74
- "Function": function},
75
- data=function_configs
71
+ f"/api/v2/topic/{topic}/user",
72
+ headers={"Subject": str(subject), "Action": action,
73
+ "Topic": topic, "User": str(user)}
76
74
  )
77
75
 
78
- def unregister_function(
79
- self, subject: UUID_LIKE_T, topic: str, function: str
76
+ def list_triggers(self, subject: UUID_LIKE_T) -> globus_sdk.GlobusHTTPResponse:
77
+ return self.get("/api/v2/triggers", headers={"Subject": str(subject)})
78
+
79
+ def create_trigger(
80
+ self, subject: UUID_LIKE_T, topic: str, function: str, action: str,
81
+ function_configs: dict
80
82
  ) -> globus_sdk.GlobusHTTPResponse:
81
- return self.post(
82
- "/v1/unregister_function", headers={"Subject": str(subject), "Topic": topic, "Function": function}
83
+ return self.put(
84
+ "/api/v2/trigger",
85
+ headers={"Subject": str(subject), "Topic": topic,
86
+ "Trigger": function, "Action": action,
87
+ "Content-Type": "text/plain"},
88
+ data=json.dumps(function_configs).encode("utf-8")
83
89
  )
84
90
 
85
- def update_function_trigger(
91
+ def update_trigger(
86
92
  self, subject: UUID_LIKE_T, trigger_uuid: UUID_LIKE_T, trigger_configs: dict
87
93
  ) -> globus_sdk.GlobusHTTPResponse:
88
94
  return self.post(
89
- "/v1/update_function_trigger",
90
- headers={"Subject": str(subject), "Trigger": str(trigger_uuid)},
91
- data=trigger_configs
95
+ f"/api/v2/triggers/{trigger_uuid}",
96
+ headers={"Subject": str(subject), "Trigger_id": str(trigger_uuid),
97
+ "Content-Type": "text/plain"},
98
+ data=json.dumps(trigger_configs).encode("utf-8")
92
99
  )
@@ -1 +1 @@
1
- __version__ = "0.1.5"
1
+ __version__ = "0.1.7"
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diaspora-event-sdk
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: SDK of Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge
5
5
  Home-page: https://github.com/globus-labs/diaspora-event-sdk
6
6
  License: LICENSE
7
+ Platform: UNKNOWN
7
8
  Description-Content-Type: text/markdown
8
9
  License-File: LICENSE
9
10
  Requires-Dist: globus-sdk <4,>=3.20.1
@@ -47,3 +48,4 @@ Note: This method does not include dependencies for `KafkaProducer` and `KafkaCo
47
48
  **Advanced Consumers with Faust**: Explore the [Faust Streaming Guide](docs/faust_weather_app.md) for advanced event streaming with Faust.
48
49
 
49
50
  **Advanced Consumer Functions**: See our [Colab example](https://colab.research.google.com/drive/1tPKfxU2qPsLvNTreF6nKINU62k7pQWxa?usp=sharing) for demonstration.
51
+
@@ -1,11 +1,11 @@
1
1
  diaspora_event_sdk/__init__.py,sha256=v8IN3-WFpliakQKru8TAcmQ4IRdvRe_m9-abSDnGIFM,457
2
- diaspora_event_sdk/version.py,sha256=rPSfWgIeq2YWVPyESOAwCBt8vftsTpIkuLAGDEzyRQc,22
2
+ diaspora_event_sdk/version.py,sha256=YpKDcdV7CqL8n45u267wKtyloM13FSVbOdrqgNZnSLM,22
3
3
  diaspora_event_sdk/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- diaspora_event_sdk/sdk/_environments.py,sha256=Xeuzqnx1aGou01vsXgGwQkWhgIe3-PRgbOr1o5mZ3Mk,203
5
- diaspora_event_sdk/sdk/client.py,sha256=BbYxhGftUIgIXpHMeTxi-WMMY4LpXi7KN3HsVcQb6xk,6495
4
+ diaspora_event_sdk/sdk/_environments.py,sha256=QyQA7dV4goUKUoxAoaes8OGv0xKxz2qiFBHNGr-vQNA,204
5
+ diaspora_event_sdk/sdk/client.py,sha256=kEgcxdi2bwHXD1sVFZUZflPf9RD6FRhXteoe5A20n9s,6834
6
6
  diaspora_event_sdk/sdk/decorators.py,sha256=Gel8AyhIjbf4-FNintTNcOqvC9hHH_YwbOH257Nfmf0,884
7
7
  diaspora_event_sdk/sdk/kafka_client.py,sha256=G1kQQz2TWlahdd2TDdpvaQW7HD7gsuQCnr0tks54ISw,4361
8
- diaspora_event_sdk/sdk/web_client.py,sha256=uhxOE6LJp_MvWNwhgN9qJFBhG8e87I7yc2kRfxjZAz0,3203
8
+ diaspora_event_sdk/sdk/web_client.py,sha256=6hijsiTF23miM3u2n6MRS4mQANi09M-5IKtlaTZjDqA,3630
9
9
  diaspora_event_sdk/sdk/login_manager/__init__.py,sha256=yeqVgjeHLMX0WZJu2feJmq-fbeXvSxWghVV81ygfY-w,239
10
10
  diaspora_event_sdk/sdk/login_manager/client_login.py,sha256=gvR4PkIqQpIywNieJQ_u11PHUmdLxQ0Ho-QgPSfu8bw,1798
11
11
  diaspora_event_sdk/sdk/login_manager/decorators.py,sha256=EFEp71d0oJ7vo2H8W7DJ2gPrDfGzeNXUNxri1C0l8h0,1047
@@ -18,8 +18,8 @@ diaspora_event_sdk/sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
18
18
  diaspora_event_sdk/sdk/utils/uuid_like.py,sha256=xbxf0YXpDhdii16lwPLWRN21qFekHrNrqODSToMPtCg,470
19
19
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  tests/unit/test_client.py,sha256=alUC-XTRQn_Oz0RvmzXTal-ciSVtCpx5jm3NuStkt1E,2995
21
- diaspora_event_sdk-0.1.5.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
- diaspora_event_sdk-0.1.5.dist-info/METADATA,sha256=82vxqmUKxxb-6CmhdGQne6TwVlZ0NLI4_ZBWfS0guGY,2486
23
- diaspora_event_sdk-0.1.5.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
24
- diaspora_event_sdk-0.1.5.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
- diaspora_event_sdk-0.1.5.dist-info/RECORD,,
21
+ diaspora_event_sdk-0.1.7.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
+ diaspora_event_sdk-0.1.7.dist-info/METADATA,sha256=FzdEwxOwp7qNG5hCokv4N803ritlaZt0bRy4j3rJmhU,2505
23
+ diaspora_event_sdk-0.1.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
+ diaspora_event_sdk-0.1.7.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
+ diaspora_event_sdk-0.1.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5