diaspora-event-sdk 0.2.0__py3-none-any.whl → 0.2.2__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.
@@ -37,7 +37,7 @@ class Client:
37
37
  @requires_login
38
38
  def create_key(self):
39
39
  """
40
- Invalidate previous keys (if any) and generate a new one
40
+ Revokes existing keys, generates a new key, and updates the token storage with the newly created key and the Diaspora endpoint.
41
41
  """
42
42
  resp = self.web_client.create_key(self.subject_openid)
43
43
  if resp["status"] == "error":
@@ -70,7 +70,7 @@ class Client:
70
70
  @requires_login
71
71
  def retrieve_key(self):
72
72
  """
73
- Attempt to retrieve the key from local token storage, and call create_key if local key is not found
73
+ Retrieves the key from local token storage, and calls create_key() if the local key is not found.
74
74
  """
75
75
  tokens = self.login_manager._token_storage.get_token_data(
76
76
  DIASPORA_RESOURCE_SERVER
@@ -114,83 +114,85 @@ class Client:
114
114
  @requires_login
115
115
  def list_topics(self):
116
116
  """
117
- Retrieves the list of topics associated with the user's OpenID.
117
+ Returns a list of topics currently registered under the user's account.
118
118
  """
119
119
  return self.web_client.list_topics(self.subject_openid)
120
120
 
121
121
  @requires_login
122
122
  def register_topic(self, topic):
123
123
  """
124
- Registers a new topic under the user's OpenID.
124
+ Registers a new topic the user's account with permissions to read, write, and describe the topic.
125
125
  """
126
126
  return self.web_client.register_topic(self.subject_openid, topic, "register")
127
127
 
128
128
  @requires_login
129
129
  def unregister_topic(self, topic):
130
130
  """
131
- Unregisters a topic from the user's OpenID.
131
+ Unregisters a topic from a user's account, but all existing events within the topic are unaffected.
132
132
  """
133
133
  return self.web_client.register_topic(self.subject_openid, topic, "unregister")
134
134
 
135
135
  @requires_login
136
136
  def get_topic_configs(self, topic):
137
137
  """
138
- Get topic configurations.
138
+ Retrieves the current configurations for a registered topic.
139
139
  """
140
140
  return self.web_client.get_topic_configs(self.subject_openid, topic)
141
141
 
142
142
  @requires_login
143
143
  def update_topic_configs(self, topic, configs):
144
144
  """
145
- Set topic configurations.
145
+ Updates the configurations for a registered topic.
146
146
  """
147
147
  return self.web_client.update_topic_configs(self.subject_openid, topic, configs)
148
148
 
149
149
  @requires_login
150
150
  def update_topic_partitions(self, topic, new_partitions):
151
151
  """
152
- Adjust topic number of partitions
152
+ Increases the number of partitions for a given topic to the specified new partition count.
153
153
  """
154
154
  return self.web_client.update_topic_partitions(self.subject_openid, topic, new_partitions)
155
155
 
156
156
  @requires_login
157
157
  def grant_user_access(self, topic, user):
158
158
  """
159
- Registers a new topic under the user's OpenID.
159
+ Authorizes another user to access a registered topic under the invoker's account.
160
160
  """
161
161
  return self.web_client.grant_user_access(self.subject_openid, topic, user, "grant")
162
162
 
163
163
  @requires_login
164
164
  def revoke_user_access(self, topic, user):
165
165
  """
166
- Unregisters a topic from the user's OpenID.
166
+ Removes access permissions for another user from a registered topic under the invoker's account.
167
167
  """
168
168
  return self.web_client.grant_user_access(self.subject_openid, topic, user, "revoke")
169
169
 
170
170
  @requires_login
171
171
  def list_triggers(self):
172
172
  """
173
- Retrieves the list of functions associated with the user's OpenID.
173
+ Retrieves a list of triggers associated created under the user's account, showing each trigger's configurations and UUID.
174
174
  """
175
175
  return self.web_client.list_triggers(self.subject_openid)
176
176
 
177
177
  @requires_login
178
- def create_trigger(self, topic, function, function_configs):
178
+ def create_trigger(self, topic, function, function_configs, trigger_configs):
179
179
  """
180
- Registers a new functions under the user's OpenID.
180
+ Creates a new trigger under the user's account with specific function and invocation configurations.
181
181
  """
182
- return self.web_client.create_trigger(self.subject_openid, topic, function, "create", function_configs)
182
+ return self.web_client.create_trigger(
183
+ self.subject_openid, topic, function, "create", function_configs, trigger_configs)
183
184
 
184
185
  @requires_login
185
186
  def delete_trigger(self, topic, function):
186
187
  """
187
- Unregisters a functions from the user's OpenID.
188
+ Deletes a trigger and related AWS resources, while the associated topic remains unaffected.
188
189
  """
189
- return self.web_client.create_trigger(self.subject_openid, topic, function, "delete", {})
190
+ return self.web_client.create_trigger(
191
+ self.subject_openid, topic, function, "delete", {}, {})
190
192
 
191
193
  @requires_login
192
194
  def update_trigger(self, trigger_uuid, trigger_configs):
193
195
  """
194
- Update a functions's trigger'.
196
+ Updates invocation configurations of an existing trigger, identified by its unique trigger UUID.
195
197
  """
196
198
  return self.web_client.update_trigger(self.subject_openid, trigger_uuid, trigger_configs)
@@ -1,7 +1,7 @@
1
1
  """
2
- Logic for using client identities with the Diaspora Event SDK
2
+ Logic for using client identities with the Diaspora SDK
3
3
 
4
- This is based on the Globus CLI client login:
4
+ The design is based on the Globus CLI client login:
5
5
  https://github.com/globus/globus-cli/blob/main/src/globus_cli/login_manager/client_login.py
6
6
  """
7
7
  from __future__ import annotations
@@ -9,13 +9,14 @@ from __future__ import annotations
9
9
  import logging
10
10
  import os
11
11
  import uuid
12
+ from typing import Union
12
13
 
13
14
  import globus_sdk
14
15
 
15
16
  log = logging.getLogger(__name__)
16
17
 
17
18
 
18
- def _get_client_creds_from_env() -> tuple[str | None, str | None]:
19
+ def _get_client_creds_from_env() -> tuple[Union[str, None], Union[str, None]]:
19
20
  client_id = os.getenv("DIASPORA_SDK_CLIENT_ID")
20
21
  client_secret = os.getenv("DIASPORA_SDK_CLIENT_SECRET")
21
22
  return client_id, client_secret
@@ -3,14 +3,14 @@ import os
3
3
  import globus_sdk
4
4
 
5
5
 
6
- def internal_auth_client():
6
+ def internal_auth_client() -> globus_sdk.NativeAppAuthClient:
7
7
  """
8
- This is the client that represents the Diaspora Event Fabric application itself
8
+ This is the client that represents the Diaspora Event Fabric application itself.
9
9
  """
10
10
 
11
- client_id = os.environ.get(
11
+ client_id: str = os.environ.get(
12
12
  "DIASPORA_SDK_CLIENT_ID", "c5d4fab4-7f0d-422e-b0c8-5c74329b52fe"
13
13
  )
14
14
  return globus_sdk.NativeAppAuthClient(
15
15
  client_id, app_name="Diaspora Event Fabric (internal client)"
16
- )
16
+ )
@@ -1,11 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import platform
4
+ from typing import List
4
5
 
5
6
  from .globus_auth import internal_auth_client
6
7
 
7
8
 
8
- def do_link_auth_flow(scopes: list[str]):
9
+ def do_link_auth_flow(scopes: List[str]):
9
10
  auth_client = internal_auth_client()
10
11
 
11
12
  # start the Confidential App Grant flow
@@ -31,4 +32,4 @@ def do_link_auth_flow(scopes: list[str]):
31
32
  auth_code = input("Enter the resulting Authorization Code here: ").strip()
32
33
 
33
34
  # finish auth flow
34
- return auth_client.oauth2_exchange_code_for_tokens(auth_code)
35
+ return auth_client.oauth2_exchange_code_for_tokens(auth_code)
@@ -33,7 +33,8 @@ class WebClient(globus_sdk.BaseClient):
33
33
  self, subject: UUID_LIKE_T, topic: str, action: str
34
34
  ) -> globus_sdk.GlobusHTTPResponse:
35
35
  return self.put(
36
- f"/api/v2/topic/{topic}", headers={"Subject": str(subject), "Action": action}
36
+ f"/api/v2/topic/{topic}",
37
+ headers={"Subject": str(subject), "Action": action}
37
38
  )
38
39
 
39
40
  def get_topic_configs(
@@ -41,8 +42,7 @@ class WebClient(globus_sdk.BaseClient):
41
42
  ) -> globus_sdk.GlobusHTTPResponse:
42
43
  return self.get(
43
44
  f"/api/v2/topic/{topic}",
44
- headers={"Subject": str(subject), "Topic": topic},
45
- # data=json.dumps(configs).encode("utf-8")
45
+ headers={"Subject": str(subject), "Topic": topic}
46
46
  )
47
47
 
48
48
  def update_topic_configs(
@@ -61,7 +61,7 @@ class WebClient(globus_sdk.BaseClient):
61
61
  return self.post(
62
62
  f"/api/v2/topic/{topic}/partitions",
63
63
  headers={"Subject": str(subject), "Topic": topic,
64
- "NewPartitions": str(new_partitions)},
64
+ "NewPartitions": str(new_partitions)}
65
65
  )
66
66
 
67
67
  def grant_user_access(
@@ -78,14 +78,15 @@ class WebClient(globus_sdk.BaseClient):
78
78
 
79
79
  def create_trigger(
80
80
  self, subject: UUID_LIKE_T, topic: str, function: str, action: str,
81
- function_configs: dict
81
+ function_configs: dict, trigger_configs: dict
82
82
  ) -> globus_sdk.GlobusHTTPResponse:
83
83
  return self.put(
84
84
  "/api/v2/trigger",
85
85
  headers={"Subject": str(subject), "Topic": topic,
86
86
  "Trigger": function, "Action": action,
87
87
  "Content-Type": "text/plain"},
88
- data=json.dumps(function_configs).encode("utf-8")
88
+ data=json.dumps({"function": function_configs,
89
+ "trigger": trigger_configs}).encode("utf-8")
89
90
  )
90
91
 
91
92
  def update_trigger(
@@ -1 +1 @@
1
- __version__ = "0.2.0"
1
+ __version__ = "0.2.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diaspora-event-sdk
3
- Version: 0.2.0
3
+ Version: 0.2.2
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
@@ -1,25 +1,25 @@
1
1
  diaspora_event_sdk/__init__.py,sha256=v8IN3-WFpliakQKru8TAcmQ4IRdvRe_m9-abSDnGIFM,457
2
- diaspora_event_sdk/version.py,sha256=Zn1KFblwuFHiDRdRAiRnDBRkbPttWh44jKa5zG2ov0E,22
2
+ diaspora_event_sdk/version.py,sha256=m6kyaNpwBcP1XYcqrelX2oS3PJuOnElOcRdBa9pEb8c,22
3
3
  diaspora_event_sdk/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  diaspora_event_sdk/sdk/_environments.py,sha256=QyQA7dV4goUKUoxAoaes8OGv0xKxz2qiFBHNGr-vQNA,204
5
- diaspora_event_sdk/sdk/client.py,sha256=kEgcxdi2bwHXD1sVFZUZflPf9RD6FRhXteoe5A20n9s,6834
5
+ diaspora_event_sdk/sdk/client.py,sha256=hsnlG8dheTSLhWgfrsvnw3xw8QQKQXuqnBoTEXOm218,7503
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=6hijsiTF23miM3u2n6MRS4mQANi09M-5IKtlaTZjDqA,3630
8
+ diaspora_event_sdk/sdk/web_client.py,sha256=5GWp9vjM79MJdfeP-JnMGgIJfQEalDN2J4qEK4LIkJg,3679
9
9
  diaspora_event_sdk/sdk/login_manager/__init__.py,sha256=yeqVgjeHLMX0WZJu2feJmq-fbeXvSxWghVV81ygfY-w,239
10
- diaspora_event_sdk/sdk/login_manager/client_login.py,sha256=gvR4PkIqQpIywNieJQ_u11PHUmdLxQ0Ho-QgPSfu8bw,1798
10
+ diaspora_event_sdk/sdk/login_manager/client_login.py,sha256=8ild28_cgPSrLtg3Jhmzpg3EymAvH2UdAhKY52oOB_c,1835
11
11
  diaspora_event_sdk/sdk/login_manager/decorators.py,sha256=EFEp71d0oJ7vo2H8W7DJ2gPrDfGzeNXUNxri1C0l8h0,1047
12
- diaspora_event_sdk/sdk/login_manager/globus_auth.py,sha256=9Hymp0tv91OI5dBMUgh4rGv_5xLVLhFEK7Hu0t8CJFQ,389
13
- diaspora_event_sdk/sdk/login_manager/login_flow.py,sha256=2TodgsvlEYPoZPQPkp6FHOC9IkSM07pS7MIVGS4MZNE,954
12
+ diaspora_event_sdk/sdk/login_manager/globus_auth.py,sha256=pbDy67Mdf4SKFf0IlXD3ZFGj4lG-xpzFTD1ygW-0H1k,430
13
+ diaspora_event_sdk/sdk/login_manager/login_flow.py,sha256=6Vi_e3rACYdv4TRXPAvUv5xivCRkCo4DS841Ixu_r24,977
14
14
  diaspora_event_sdk/sdk/login_manager/manager.py,sha256=AD3f8rx154oesgkpqG0K-eZsEGjntr08Vgrxr1m6uao,7040
15
15
  diaspora_event_sdk/sdk/login_manager/protocol.py,sha256=RCuo2jy_XkpZvbxnKlDfTKs-L6b9_8_JR-Kq9wHwhoM,710
16
16
  diaspora_event_sdk/sdk/login_manager/tokenstore.py,sha256=Kq0IZGf9G9dE44yoyUZInod5xL_8caN9OugeTK6GBGg,2094
17
17
  diaspora_event_sdk/sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  diaspora_event_sdk/sdk/utils/uuid_like.py,sha256=xbxf0YXpDhdii16lwPLWRN21qFekHrNrqODSToMPtCg,470
19
19
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- tests/unit/test_client.py,sha256=alUC-XTRQn_Oz0RvmzXTal-ciSVtCpx5jm3NuStkt1E,2995
21
- diaspora_event_sdk-0.2.0.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
- diaspora_event_sdk-0.2.0.dist-info/METADATA,sha256=FeRpsTvBPF-kkWAXLGiHj8PeWNKLEE8PV_nbotQPXzg,2505
23
- diaspora_event_sdk-0.2.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
- diaspora_event_sdk-0.2.0.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
- diaspora_event_sdk-0.2.0.dist-info/RECORD,,
20
+ tests/unit/test_client.py,sha256=sJUtPmnNGnohnP38RQrwcJ4D5j3-g1WFQ6gaKf520AQ,3019
21
+ diaspora_event_sdk-0.2.2.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
+ diaspora_event_sdk-0.2.2.dist-info/METADATA,sha256=OkO4eq9tmvIM_0W0sqG7zrL-lpRlrrkON6brr2D4LCc,2505
23
+ diaspora_event_sdk-0.2.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
+ diaspora_event_sdk-0.2.2.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
+ diaspora_event_sdk-0.2.2.dist-info/RECORD,,
tests/unit/test_client.py CHANGED
@@ -91,10 +91,10 @@ def test_list_topics(client):
91
91
  def test_register_topic(client):
92
92
  topic = "test_topic"
93
93
  client.register_topic(topic)
94
- client.web_client.register_topic.assert_called_with("test_sub", topic)
94
+ client.web_client.register_topic.assert_called_with("test_sub", topic, "register")
95
95
 
96
96
 
97
97
  def test_unregister_topic(client):
98
98
  topic = "test_topic"
99
99
  client.unregister_topic(topic)
100
- client.web_client.unregister_topic.assert_called_with("test_sub", topic)
100
+ client.web_client.register_topic.assert_called_with("test_sub", topic, "unregister")