diaspora-event-sdk 0.0.18__py3-none-any.whl → 0.0.19__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.
@@ -45,10 +45,7 @@ class Client:
45
45
  tokens = self.login_manager._token_storage.get_token_data(
46
46
  DIASPORA_RESOURCE_SERVER
47
47
  )
48
- tokens["access_key"], tokens["secret_key"] = (
49
- resp["access_key"],
50
- resp["secret_key"],
51
- )
48
+ tokens["secret_key"] = resp["secret_key"]
52
49
  with self.login_manager._access_lock:
53
50
  self.login_manager._token_storage._connection.executemany(
54
51
  "REPLACE INTO token_storage(namespace, resource_server, token_data_json) "
@@ -72,11 +69,41 @@ class Client:
72
69
  tokens = self.login_manager._token_storage.get_token_data(
73
70
  DIASPORA_RESOURCE_SERVER
74
71
  )
75
- if tokens is None or "access_key" not in tokens or "secret_key" not in tokens:
72
+ if tokens is None or "secret_key" not in tokens:
76
73
  return self.create_key()
77
74
  else:
78
75
  return {"username": self.subject_openid, "password": tokens["secret_key"]}
79
76
 
77
+ @requires_login
78
+ def get_secret_key(self):
79
+ tokens = self.login_manager._token_storage.get_token_data(
80
+ DIASPORA_RESOURCE_SERVER
81
+ )
82
+ if tokens is None or "secret_key" not in tokens:
83
+ return None
84
+ else:
85
+ return tokens["secret_key"]
86
+
87
+ @requires_login
88
+ def put_secret_key(self, secret_key):
89
+ tokens = self.login_manager._token_storage.get_token_data(
90
+ DIASPORA_RESOURCE_SERVER
91
+ )
92
+ tokens["secret_key"] = secret_key
93
+ with self.login_manager._access_lock:
94
+ self.login_manager._token_storage._connection.executemany(
95
+ "REPLACE INTO token_storage(namespace, resource_server, token_data_json) "
96
+ "VALUES(?, ?, ?)",
97
+ [
98
+ (
99
+ self.login_manager._token_storage.namespace,
100
+ DIASPORA_RESOURCE_SERVER,
101
+ json.dumps(tokens),
102
+ )
103
+ ],
104
+ )
105
+ self.login_manager._token_storage._connection.commit()
106
+
80
107
  @requires_login
81
108
  def list_topics(self):
82
109
  """
@@ -1 +1 @@
1
- __version__ = "0.0.18"
1
+ __version__ = "0.0.19"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diaspora-event-sdk
3
- Version: 0.0.18
3
+ Version: 0.0.19
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
@@ -72,6 +72,14 @@ c = GlobusClient()
72
72
  topic = "topic-" + c.subject_openid[-12:]
73
73
  print(c.register_topic(topic))
74
74
  print(c.list_topics())
75
+
76
+ # registration_status = c.register_topic(topic)
77
+ # print(registration_status)
78
+ # assert registration_status["status"] in ["no-op", "success"]
79
+
80
+ # registered_topics = c.list_topics()
81
+ # print(registered_topics)
82
+ # assert topic in registered_topics["topics"]
75
83
  ```
76
84
  Register a topic also creates it, if the topic previously does not exist.
77
85
 
@@ -138,6 +146,26 @@ print(c.retrieve_key())
138
146
  ```
139
147
 
140
148
  ### Advanced Usage
149
+ #### Key Migration
150
+ In case you want to use the same credential (OpenID, secret key) on the second macine, but a call to create_key() invalidates all previous keys so you cannot rely on this API for generating a new key for the new machine, while keeping the old key on the old machine valid. Starting at 0.0.19, you can call the following code to retrieve the active secret key on the first machine and store it to the second machine, so that both machines hold valid keys.
151
+
152
+ On the first machine, call:
153
+ ```python
154
+ from diaspora_event_sdk import Client as GlobusClient
155
+ c = GlobusClient()
156
+ print(c.get_secret_key()) # note down the secret key
157
+ ```
158
+
159
+ On the second machine, call:
160
+ ```python
161
+ from diaspora_event_sdk import Client as GlobusClient
162
+ from diaspora_event_sdk import block_until_ready
163
+
164
+ c = GlobusClient()
165
+ c.put_secret_key("<secret-key-from-first-machine>")
166
+ assert block_until_ready() # should unblock immediately
167
+ ```
168
+ Note that a call to create_key() on any machine would invalidate the current key, on both machines.
141
169
 
142
170
  #### Password Refresh
143
171
  In case that you need to invalidate all previously issued passwords and generate a new one, call the `create_key` method from the `Client` class
@@ -1,8 +1,8 @@
1
1
  diaspora_event_sdk/__init__.py,sha256=v8IN3-WFpliakQKru8TAcmQ4IRdvRe_m9-abSDnGIFM,457
2
- diaspora_event_sdk/version.py,sha256=qgKF-lRlzaBqf95e1sodHCZkSUCbz7ECKSeYHwXfAvI,23
2
+ diaspora_event_sdk/version.py,sha256=AixLlU6Em9Z_zs4l1lTxAHg1b8pa8z3BTNKIHDkjBmo,23
3
3
  diaspora_event_sdk/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  diaspora_event_sdk/sdk/_environments.py,sha256=UwzEeBVRuP7ZyqTJagNVA24EiCLuOYiy395q608AwQ0,358
5
- diaspora_event_sdk/sdk/client.py,sha256=2KMUdnOEtSe1uV3rpRZHd5tLOFgC_fztzny1XxL4rh8,3496
5
+ diaspora_event_sdk/sdk/client.py,sha256=w0-cL03vKDXnuHsLDLYMpkwpjKvDy1ku-aVIHcYONjE,4474
6
6
  diaspora_event_sdk/sdk/decorators.py,sha256=Gel8AyhIjbf4-FNintTNcOqvC9hHH_YwbOH257Nfmf0,884
7
7
  diaspora_event_sdk/sdk/kafka_client.py,sha256=e_c9M1L-HAV346iwR7tsH7ZZUON1tgSDCGlOkvNKdWQ,3959
8
8
  diaspora_event_sdk/sdk/web_client.py,sha256=RCXZhMtPBe53c4-MmyBiFIdqsmcTOnV3ashaaQHKMew,1325
@@ -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=KjqXW7Mm3fm17lqhYdixL8s50z83F6g7MGKcOXJIyFc,2635
21
- diaspora_event_sdk-0.0.18.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
- diaspora_event_sdk-0.0.18.dist-info/METADATA,sha256=4YlQ90MxHz4T1ILh2wrj_H97ouosqI_OX1OcRm7SQsI,9542
23
- diaspora_event_sdk-0.0.18.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
24
- diaspora_event_sdk-0.0.18.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
- diaspora_event_sdk-0.0.18.dist-info/RECORD,,
21
+ diaspora_event_sdk-0.0.19.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
22
+ diaspora_event_sdk-0.0.19.dist-info/METADATA,sha256=ZxMWWf2fOCclSN6aZmXtk_CK1sldKadWtv1yK8AY1v4,10813
23
+ diaspora_event_sdk-0.0.19.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
24
+ diaspora_event_sdk-0.0.19.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
25
+ diaspora_event_sdk-0.0.19.dist-info/RECORD,,