definite-sdk 0.1.3__py3-none-any.whl → 0.1.4__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.
- definite_sdk/client.py +18 -0
- definite_sdk/integration.py +60 -0
- definite_sdk/secret.py +94 -0
- {definite_sdk-0.1.3.dist-info → definite_sdk-0.1.4.dist-info}/METADATA +1 -1
- definite_sdk-0.1.4.dist-info/RECORD +8 -0
- definite_sdk-0.1.3.dist-info/RECORD +0 -6
- {definite_sdk-0.1.3.dist-info → definite_sdk-0.1.4.dist-info}/LICENSE +0 -0
- {definite_sdk-0.1.3.dist-info → definite_sdk-0.1.4.dist-info}/WHEEL +0 -0
definite_sdk/client.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from definite_sdk.integration import DefiniteIntegrationStore
|
|
2
|
+
from definite_sdk.secret import DefiniteSecretStore
|
|
1
3
|
from definite_sdk.store import DefiniteKVStore
|
|
2
4
|
|
|
3
5
|
API_URL = "https://api.definite.app"
|
|
@@ -21,3 +23,19 @@ class DefiniteClient:
|
|
|
21
23
|
"""
|
|
22
24
|
|
|
23
25
|
return DefiniteKVStore(name, self.api_key, self.api_url)
|
|
26
|
+
|
|
27
|
+
def get_secret_store(self) -> DefiniteSecretStore:
|
|
28
|
+
"""Initializes the secret store.
|
|
29
|
+
|
|
30
|
+
See DefiniteSecretStore for more how to interact with the store.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
return DefiniteSecretStore(self.api_key, self.api_url)
|
|
34
|
+
|
|
35
|
+
def get_integration_store(self) -> DefiniteIntegrationStore:
|
|
36
|
+
"""Initializes the integration store.
|
|
37
|
+
|
|
38
|
+
See DefiniteIntegrationStore for more how to interact with the store.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
return DefiniteIntegrationStore(self.api_key, self.api_url)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from typing import Iterator
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
SECRET_STORE_ENDPOINT = "/v1/api/integration"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DefiniteIntegrationStore:
|
|
9
|
+
"""
|
|
10
|
+
Read only access to the integration store on Definite.
|
|
11
|
+
|
|
12
|
+
Initialization:
|
|
13
|
+
>>> client = DefiniteSdkClient("MY_API_KEY")
|
|
14
|
+
>>> integration_store = client.get_integration_store()
|
|
15
|
+
|
|
16
|
+
Accessing values:
|
|
17
|
+
>>> integration_store.list_integrations()
|
|
18
|
+
>>> integration_store.get_integration("name")
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, api_key: str, api_url: str):
|
|
22
|
+
"""
|
|
23
|
+
Initializes the DefiniteSecretStore
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
api_key (str): The API key for authorization.
|
|
27
|
+
"""
|
|
28
|
+
self._api_key = api_key
|
|
29
|
+
self._integration_store_url = api_url + SECRET_STORE_ENDPOINT
|
|
30
|
+
|
|
31
|
+
def list_integrations(self) -> Iterator[dict]:
|
|
32
|
+
"""
|
|
33
|
+
Lists all integrations in the store.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Iterator[str]: An iterator of integrations.
|
|
37
|
+
"""
|
|
38
|
+
response = requests.get(
|
|
39
|
+
self._integration_store_url,
|
|
40
|
+
headers={"Authorization": "Bearer " + self._api_key},
|
|
41
|
+
)
|
|
42
|
+
response.raise_for_status()
|
|
43
|
+
return iter(response.json())
|
|
44
|
+
|
|
45
|
+
def get_integration(self, name: str) -> dict:
|
|
46
|
+
"""
|
|
47
|
+
Retrieves an integration by name.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
name (str): The name of the integration.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
str: The value of the integration.
|
|
54
|
+
"""
|
|
55
|
+
response = requests.get(
|
|
56
|
+
self._integration_store_url + f"/{name}",
|
|
57
|
+
headers={"Authorization": "Bearer " + self._api_key},
|
|
58
|
+
)
|
|
59
|
+
response.raise_for_status()
|
|
60
|
+
return response.json()
|
definite_sdk/secret.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from typing import Iterator
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
SECRET_STORE_ENDPOINT = "/v1/api/secret"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DefiniteSecretStore:
|
|
9
|
+
"""
|
|
10
|
+
A secret store hosted by Definite.
|
|
11
|
+
|
|
12
|
+
Initialization:
|
|
13
|
+
>>> client = DefiniteSdkClient("MY_API_KEY")
|
|
14
|
+
>>> secret_store = client.get_secret_store()
|
|
15
|
+
|
|
16
|
+
Accessing values:
|
|
17
|
+
>>> secret_store.list_secrets()
|
|
18
|
+
>>> secret_store.get_secret("key")
|
|
19
|
+
|
|
20
|
+
Setting values:
|
|
21
|
+
>>> secret_store.set_secret("key", "value")
|
|
22
|
+
|
|
23
|
+
To permanently delete a secret:
|
|
24
|
+
>>> secret_store.delete_secret("key")
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, api_key: str, api_url: str):
|
|
28
|
+
"""
|
|
29
|
+
Initializes the DefiniteSecretStore
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
api_key (str): The API key for authorization.
|
|
33
|
+
"""
|
|
34
|
+
self._api_key = api_key
|
|
35
|
+
self._secret_store_url = api_url + SECRET_STORE_ENDPOINT
|
|
36
|
+
|
|
37
|
+
def list_secrets(self) -> Iterator[str]:
|
|
38
|
+
"""
|
|
39
|
+
Lists all secrets in the store.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
Iterator[str]: An iterator of secret keys.
|
|
43
|
+
"""
|
|
44
|
+
response = requests.get(
|
|
45
|
+
self._secret_store_url,
|
|
46
|
+
headers={"Authorization": "Bearer " + self._api_key},
|
|
47
|
+
)
|
|
48
|
+
response.raise_for_status()
|
|
49
|
+
return iter(response.json()["secrets"])
|
|
50
|
+
|
|
51
|
+
def get_secret(self, key: str) -> str:
|
|
52
|
+
"""
|
|
53
|
+
Retrieves the value of a secret.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
key (str): The key of the secret.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
str: The value of the secret.
|
|
60
|
+
"""
|
|
61
|
+
response = requests.get(
|
|
62
|
+
self._secret_store_url + f"/{key}",
|
|
63
|
+
headers={"Authorization": "Bearer " + self._api_key},
|
|
64
|
+
)
|
|
65
|
+
response.raise_for_status()
|
|
66
|
+
return response.json()["value"]
|
|
67
|
+
|
|
68
|
+
def set_secret(self, key: str, value: str):
|
|
69
|
+
"""
|
|
70
|
+
Sets the value of a secret.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
key (str): The key of the secret.
|
|
74
|
+
value (str): The value of the secret.
|
|
75
|
+
"""
|
|
76
|
+
response = requests.post(
|
|
77
|
+
self._secret_store_url + f"/{key}",
|
|
78
|
+
json={"value": value},
|
|
79
|
+
headers={"Authorization": "Bearer " + self._api_key},
|
|
80
|
+
)
|
|
81
|
+
response.raise_for_status()
|
|
82
|
+
|
|
83
|
+
def delete_secret(self, key: str):
|
|
84
|
+
"""
|
|
85
|
+
Deletes a secret.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
key (str): The key of the secret.
|
|
89
|
+
"""
|
|
90
|
+
response = requests.delete(
|
|
91
|
+
self._secret_store_url + f"/{key}",
|
|
92
|
+
headers={"Authorization": "Bearer " + self._api_key},
|
|
93
|
+
)
|
|
94
|
+
response.raise_for_status()
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
definite_sdk/client.py,sha256=DjckW-kZOGSQ5RKwRfpPub_ucxAcUaTLknZz5YKe4nE,1354
|
|
2
|
+
definite_sdk/integration.py,sha256=z7i_q9m5dMNJPG3_J29aH1jov0b5u6rhO3IZj1V9KVg,1647
|
|
3
|
+
definite_sdk/secret.py,sha256=pgRzY40MwOaZBVEw-yQPWX3ag1B7AMoCJKJjzcLQnTs,2506
|
|
4
|
+
definite_sdk/store.py,sha256=FimC3RqLtiJc3PlOSORCIiMFaUcNtc-r45c54j3l92g,5034
|
|
5
|
+
definite_sdk-0.1.4.dist-info/LICENSE,sha256=jMd7PtwNWiMoGIDgFutC1v4taO69W9SRZLKe9o470Vk,1064
|
|
6
|
+
definite_sdk-0.1.4.dist-info/METADATA,sha256=PWkSNNRsjSKb1oU0a32FPUtqnP010jriQfRlI67p0i4,702
|
|
7
|
+
definite_sdk-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
8
|
+
definite_sdk-0.1.4.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
definite_sdk/client.py,sha256=JspvS2qPNDqtxaamzTNW_0--mmGkIxSGck2I6SjWjbQ,721
|
|
2
|
-
definite_sdk/store.py,sha256=FimC3RqLtiJc3PlOSORCIiMFaUcNtc-r45c54j3l92g,5034
|
|
3
|
-
definite_sdk-0.1.3.dist-info/LICENSE,sha256=jMd7PtwNWiMoGIDgFutC1v4taO69W9SRZLKe9o470Vk,1064
|
|
4
|
-
definite_sdk-0.1.3.dist-info/METADATA,sha256=mZ5BzEqNTFEJscvAEonb9PshsvO1CgMBn-CR4PW03WU,702
|
|
5
|
-
definite_sdk-0.1.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
-
definite_sdk-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|