diaspora-event-sdk 0.1.6__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,81 +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)
144
-
145
- @requires_login
146
- def register_topic_for_user(self, topic, user):
147
- """
148
- Registers a new topic under the user's OpenID.
149
- """
150
- return self.web_client.register_topic_for_user(self.subject_openid, topic, user)
133
+ return self.web_client.register_topic(self.subject_openid, topic, "unregister")
151
134
 
152
135
  @requires_login
153
- def unregister_topic_for_user(self, topic, user):
136
+ def get_topic_configs(self, topic):
154
137
  """
155
- Unregisters a topic from the user's OpenID.
138
+ Get topic configurations.
156
139
  """
157
- return self.web_client.unregister_topic_for_user(self.subject_openid, topic, user)
140
+ return self.web_client.get_topic_configs(self.subject_openid, topic)
158
141
 
159
142
  @requires_login
160
- def list_functions(self):
143
+ def update_topic_configs(self, topic, configs):
161
144
  """
162
- Retrieves the list of functions associated with the user's OpenID.
145
+ Set topic configurations.
163
146
  """
164
- return self.web_client.list_functions(self.subject_openid)
147
+ return self.web_client.update_topic_configs(self.subject_openid, topic, configs)
165
148
 
166
149
  @requires_login
167
- def register_function(self, topic, function, function_configs):
150
+ def update_topic_partitions(self, topic, new_partitions):
168
151
  """
169
- Registers a new functions under the user's OpenID.
152
+ Adjust topic number of partitions
170
153
  """
171
- return self.web_client.register_function(self.subject_openid, topic, function, function_configs)
154
+ return self.web_client.update_topic_partitions(self.subject_openid, topic, new_partitions)
172
155
 
173
156
  @requires_login
174
- def unregister_function(self, topic, function):
157
+ def grant_user_access(self, topic, user):
175
158
  """
176
- Unregisters a functions from the user's OpenID.
159
+ Registers a new topic under the user's OpenID.
177
160
  """
178
- return self.web_client.unregister_function(self.subject_openid, topic, function)
161
+ return self.web_client.grant_user_access(self.subject_openid, topic, user, "grant")
179
162
 
180
163
  @requires_login
181
- def update_trigger_config(self, trigger_uuid, trigger_configs):
164
+ def revoke_user_access(self, topic, user):
182
165
  """
183
- Update a functions's trigger'.
166
+ Unregisters a topic from the user's OpenID.
184
167
  """
185
- return self.web_client.update_function_trigger(self.subject_openid, trigger_uuid, trigger_configs)
168
+ return self.web_client.grant_user_access(self.subject_openid, topic, user, "revoke")
186
169
 
187
170
  @requires_login
188
- def get_identities(self):
171
+ def list_triggers(self):
189
172
  """
190
- Get the user identities.
173
+ Retrieves the list of functions associated with the user's OpenID.
191
174
  """
192
- return self.web_client.get_identities(self.subject_openid)
175
+ return self.web_client.list_triggers(self.subject_openid)
193
176
 
194
177
  @requires_login
195
- def get_topic_configs(self, topic, configs):
178
+ def create_trigger(self, topic, function, function_configs):
196
179
  """
197
- Get topic configurations.
180
+ Registers a new functions under the user's OpenID.
198
181
  """
199
- return self.web_client.get_topic_configs(self.subject_openid, topic, configs)
182
+ return self.web_client.create_trigger(self.subject_openid, topic, function, "create", function_configs)
200
183
 
201
184
  @requires_login
202
- def set_topic_configs(self, topic, configs):
185
+ def delete_trigger(self, topic, function):
203
186
  """
204
- Set topic configurations.
187
+ Unregisters a functions from the user's OpenID.
205
188
  """
206
- return self.web_client.set_topic_configs(self.subject_openid, topic, configs)
189
+ return self.web_client.create_trigger(self.subject_openid, topic, function, "delete", {})
207
190
 
208
191
  @requires_login
209
- def create_partitions(self, topic, new_partitions):
192
+ def update_trigger(self, trigger_uuid, trigger_configs):
210
193
  """
211
- Set topic configurations.
194
+ Update a functions's trigger'.
212
195
  """
213
- return self.web_client.create_partitions(self.subject_openid, topic, new_partitions)
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,104 +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}
44
- )
45
-
46
- def register_topic_for_user(
47
- self, subject: UUID_LIKE_T, topic: str, user: UUID_LIKE_T
48
- ) -> globus_sdk.GlobusHTTPResponse:
49
- return self.post(
50
- "/v1/register_topic_for_user",
51
- headers={"Subject": str(
52
- subject), "Topic": topic, "User": str(user)}
53
- )
54
-
55
- def unregister_topic_for_user(
56
- self, subject: UUID_LIKE_T, topic: str, user: UUID_LIKE_T
57
- ) -> globus_sdk.GlobusHTTPResponse:
58
- return self.post(
59
- "/v1/unregister_topic_for_user",
60
- headers={"Subject": str(
61
- subject), "Topic": topic, "User": str(user)}
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")
62
46
  )
63
47
 
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
48
+ def update_topic_configs(
49
+ self, subject: UUID_LIKE_T, topic: str, configs: dict
70
50
  ) -> globus_sdk.GlobusHTTPResponse:
71
51
  return self.post(
72
- "/v1/register_function",
52
+ f"/api/v2/topic/{topic}",
73
53
  headers={"Subject": str(subject), "Topic": topic,
74
- "Function": function},
75
- data=function_configs
76
- )
77
-
78
- def unregister_function(
79
- self, subject: UUID_LIKE_T, topic: str, function: str
80
- ) -> globus_sdk.GlobusHTTPResponse:
81
- return self.post(
82
- "/v1/unregister_function", headers={"Subject": str(subject), "Topic": topic, "Function": function}
54
+ "Content-Type": "text/plain"},
55
+ data=json.dumps(configs).encode("utf-8")
83
56
  )
84
57
 
85
- def update_function_trigger(
86
- self, subject: UUID_LIKE_T, trigger_uuid: UUID_LIKE_T, trigger_configs: dict
58
+ def update_topic_partitions(
59
+ self, subject: UUID_LIKE_T, topic: str, new_partitions: int
87
60
  ) -> globus_sdk.GlobusHTTPResponse:
88
61
  return self.post(
89
- "/v1/update_function_trigger",
90
- headers={"Subject": str(subject), "Trigger": str(trigger_uuid)},
91
- data=trigger_configs
62
+ f"/api/v2/topic/{topic}/partitions",
63
+ headers={"Subject": str(subject), "Topic": topic,
64
+ "NewPartitions": str(new_partitions)},
92
65
  )
93
66
 
94
- def get_identities(
95
- self, subject: UUID_LIKE_T
67
+ def grant_user_access(
68
+ self, subject: UUID_LIKE_T, topic: str, user: UUID_LIKE_T, action: str
96
69
  ) -> globus_sdk.GlobusHTTPResponse:
97
70
  return self.post(
98
- "/v1/get_identities",
99
- headers={"Subject": str(subject)}
71
+ f"/api/v2/topic/{topic}/user",
72
+ headers={"Subject": str(subject), "Action": action,
73
+ "Topic": topic, "User": str(user)}
100
74
  )
101
75
 
102
- def get_topic_configs(
103
- self, subject: UUID_LIKE_T, topic: str, configs: dict
104
- ) -> globus_sdk.GlobusHTTPResponse:
105
- return self.post(
106
- "/v1/get_topic_configs",
107
- headers={"Subject": str(subject), "Topic": topic},
108
- data=configs
109
- )
76
+ def list_triggers(self, subject: UUID_LIKE_T) -> globus_sdk.GlobusHTTPResponse:
77
+ return self.get("/api/v2/triggers", headers={"Subject": str(subject)})
110
78
 
111
- def set_topic_configs(
112
- self, subject: UUID_LIKE_T, topic: str, configs: dict
79
+ def create_trigger(
80
+ self, subject: UUID_LIKE_T, topic: str, function: str, action: str,
81
+ function_configs: dict
113
82
  ) -> globus_sdk.GlobusHTTPResponse:
114
- return self.post(
115
- "/v1/set_topic_configs",
116
- headers={"Subject": str(subject), "Topic": topic},
117
- data=configs
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")
118
89
  )
119
90
 
120
- def create_partitions(
121
- self, subject: UUID_LIKE_T, topic: str, new_partitions: int
91
+ def update_trigger(
92
+ self, subject: UUID_LIKE_T, trigger_uuid: UUID_LIKE_T, trigger_configs: dict
122
93
  ) -> globus_sdk.GlobusHTTPResponse:
123
94
  return self.post(
124
- "/v1/create_partitions",
125
- headers={"Subject": str(subject), "Topic": topic,
126
- "NewPartitions": str(new_partitions)},
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")
127
99
  )
@@ -1 +1 @@
1
- __version__ = "0.1.6"
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.6
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=n3oM6B_EMz93NsTI18NNZd-jKFcUPzUkbIKj5VFK5ok,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=-JnvekXtq0U595Qrs7EmHqSmhjoJ8t3nz3JPwbqmO8c,7321
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=AprVGjWo3Nw8c3-H3qMZxQV9q-cY0n0WoLcvq06kDx4,4332
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.6.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
- diaspora_event_sdk-0.1.6.dist-info/METADATA,sha256=iwcVD2QxphVBCOG5YZLxR-vXabGyu5t1x9ubDMQE8bA,2486
23
- diaspora_event_sdk-0.1.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
- diaspora_event_sdk-0.1.6.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
- diaspora_event_sdk-0.1.6.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,,