|
|
@@ -0,0 +1,30 @@
|
|
|
+import sys
|
|
|
+import typing
|
|
|
+
|
|
|
+import httpx
|
|
|
+
|
|
|
+def main():
|
|
|
+ jwt,= sys.argv[1:]
|
|
|
+
|
|
|
+ client = httpx.Client(headers={'Authorization': 'Bearer ' + jwt})
|
|
|
+ plans: typing.Sequence[Plan] = client.get('https://api.prunplanner.org/baseplanner/').raise_for_status().json()
|
|
|
+ shared: typing.Mapping[str, str] = {s['plan_uuid']: s['shared_uuid']
|
|
|
+ for s in client.get('https://api.prunplanner.org/shared/list').raise_for_status().json()}
|
|
|
+ for plan in plans:
|
|
|
+ if plan['uuid'] not in shared:
|
|
|
+ print('sharing', plan['uuid'], plan['name'])
|
|
|
+ client.put('https://api.prunplanner.org/shared/baseplanner/' + plan['uuid']).raise_for_status()
|
|
|
+ # refresh shared UUIDs
|
|
|
+ shared: typing.Mapping[str, str] = {s['plan_uuid']: s['shared_uuid']
|
|
|
+ for s in client.get('https://api.prunplanner.org/shared/list').raise_for_status().json()}
|
|
|
+
|
|
|
+ for plan in plans:
|
|
|
+ shared_uuid = shared[plan['uuid']]
|
|
|
+ print(plan['name'], 'https://prunplanner.org/shared/' + shared_uuid)
|
|
|
+
|
|
|
+class Plan(typing.TypedDict):
|
|
|
+ uuid: str
|
|
|
+ name: str
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ main()
|