diaspora-event-sdk 0.2.0__tar.gz → 0.2.2__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.
- {diaspora-event-sdk-0.2.0/diaspora_event_sdk.egg-info → diaspora-event-sdk-0.2.2}/PKG-INFO +1 -1
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/client.py +19 -17
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/login_manager/client_login.py +4 -3
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/login_manager/globus_auth.py +4 -4
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/login_manager/login_flow.py +3 -2
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/web_client.py +7 -6
- diaspora-event-sdk-0.2.2/diaspora_event_sdk/version.py +1 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2/diaspora_event_sdk.egg-info}/PKG-INFO +1 -1
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/tests/unit/test_client.py +2 -2
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/tox.ini +1 -1
- diaspora-event-sdk-0.2.0/diaspora_event_sdk/version.py +0 -1
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/LICENSE +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/MANIFEST.in +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/README.md +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/__init__.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/__init__.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/_environments.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/decorators.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/kafka_client.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/login_manager/__init__.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/login_manager/decorators.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/login_manager/manager.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/login_manager/protocol.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/login_manager/tokenstore.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/utils/__init__.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/utils/uuid_like.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk.egg-info/SOURCES.txt +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk.egg-info/dependency_links.txt +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk.egg-info/requires.txt +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk.egg-info/top_level.txt +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/setup.cfg +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/setup.py +0 -0
- {diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/tests/__init__.py +0 -0
|
@@ -37,7 +37,7 @@ class Client:
|
|
|
37
37
|
@requires_login
|
|
38
38
|
def create_key(self):
|
|
39
39
|
"""
|
|
40
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
188
|
+
Deletes a trigger and related AWS resources, while the associated topic remains unaffected.
|
|
188
189
|
"""
|
|
189
|
-
return self.web_client.create_trigger(
|
|
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
|
-
|
|
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
|
|
2
|
+
Logic for using client identities with the Diaspora SDK
|
|
3
3
|
|
|
4
|
-
|
|
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
|
|
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:
|
|
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}",
|
|
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(
|
|
88
|
+
data=json.dumps({"function": function_configs,
|
|
89
|
+
"trigger": trigger_configs}).encode("utf-8")
|
|
89
90
|
)
|
|
90
91
|
|
|
91
92
|
def update_trigger(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.2"
|
|
@@ -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.
|
|
100
|
+
client.web_client.register_topic.assert_called_with("test_sub", topic, "unregister")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/_environments.py
RENAMED
|
File without changes
|
|
File without changes
|
{diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/kafka_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/utils/__init__.py
RENAMED
|
File without changes
|
{diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk/sdk/utils/uuid_like.py
RENAMED
|
File without changes
|
{diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk.egg-info/requires.txt
RENAMED
|
File without changes
|
{diaspora-event-sdk-0.2.0 → diaspora-event-sdk-0.2.2}/diaspora_event_sdk.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|