bitwarden-sdk 0.1.0__cp37-none-win_amd64.whl → 1.0.0__cp37-none-win_amd64.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.
- bitwarden_py/bitwarden_py.pyd +0 -0
- bitwarden_sdk/__init__.py +1 -1
- bitwarden_sdk/bitwarden_client.py +70 -25
- bitwarden_sdk/schemas.py +437 -267
- {bitwarden_sdk-0.1.0.dist-info → bitwarden_sdk-1.0.0.dist-info}/METADATA +32 -3
- bitwarden_sdk-1.0.0.dist-info/RECORD +9 -0
- {bitwarden_sdk-0.1.0.dist-info → bitwarden_sdk-1.0.0.dist-info}/WHEEL +1 -1
- bitwarden_sdk-1.0.0.dist-info/licenses/LICENSE +295 -0
- bitwarden_sdk-0.1.0.dist-info/RECORD +0 -11
bitwarden_py/bitwarden_py.pyd
CHANGED
|
Binary file
|
bitwarden_sdk/__init__.py
CHANGED
|
@@ -2,7 +2,16 @@ import json
|
|
|
2
2
|
from typing import Any, List, Optional
|
|
3
3
|
from uuid import UUID
|
|
4
4
|
import bitwarden_py
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
from .schemas import (ClientSettings, Command, ResponseForSecretIdentifiersResponse, ResponseForSecretResponse,
|
|
7
|
+
ResponseForSecretsResponse, ResponseForSecretsDeleteResponse, SecretCreateRequest,
|
|
8
|
+
SecretGetRequest, SecretsGetRequest, SecretIdentifiersRequest, SecretPutRequest,
|
|
9
|
+
SecretsCommand, SecretsDeleteRequest, SecretsSyncRequest, AccessTokenLoginRequest,
|
|
10
|
+
ResponseForSecretsSyncResponse, ResponseForAccessTokenLoginResponse,
|
|
11
|
+
ResponseForProjectResponse, ProjectsCommand, ProjectCreateRequest, ProjectGetRequest,
|
|
12
|
+
ProjectPutRequest, ProjectsListRequest, ResponseForProjectsResponse,
|
|
13
|
+
ResponseForProjectsDeleteResponse, ProjectsDeleteRequest)
|
|
14
|
+
|
|
6
15
|
|
|
7
16
|
class BitwardenClient:
|
|
8
17
|
def __init__(self, settings: ClientSettings = None):
|
|
@@ -12,11 +21,8 @@ class BitwardenClient:
|
|
|
12
21
|
settings_json = json.dumps(settings.to_dict())
|
|
13
22
|
self.inner = bitwarden_py.BitwardenClient(settings_json)
|
|
14
23
|
|
|
15
|
-
def
|
|
16
|
-
|
|
17
|
-
self._run_command(
|
|
18
|
-
Command(access_token_login=AccessTokenLoginRequest(access_token, state_file_path))
|
|
19
|
-
)
|
|
24
|
+
def auth(self):
|
|
25
|
+
return AuthClient(self)
|
|
20
26
|
|
|
21
27
|
def secrets(self):
|
|
22
28
|
return SecretsClient(self)
|
|
@@ -30,9 +36,22 @@ class BitwardenClient:
|
|
|
30
36
|
|
|
31
37
|
if response["success"] == False:
|
|
32
38
|
raise Exception(response["errorMessage"])
|
|
33
|
-
|
|
39
|
+
|
|
34
40
|
return response
|
|
35
41
|
|
|
42
|
+
|
|
43
|
+
class AuthClient:
|
|
44
|
+
def __init__(self, client: BitwardenClient):
|
|
45
|
+
self.client = client
|
|
46
|
+
|
|
47
|
+
def login_access_token(self, access_token: str,
|
|
48
|
+
state_file: str = None) -> ResponseForAccessTokenLoginResponse:
|
|
49
|
+
result = self.client._run_command(
|
|
50
|
+
Command(login_access_token=AccessTokenLoginRequest(access_token, state_file))
|
|
51
|
+
)
|
|
52
|
+
return ResponseForAccessTokenLoginResponse.from_dict(result)
|
|
53
|
+
|
|
54
|
+
|
|
36
55
|
class SecretsClient:
|
|
37
56
|
def __init__(self, client: BitwardenClient):
|
|
38
57
|
self.client = client
|
|
@@ -43,12 +62,24 @@ class SecretsClient:
|
|
|
43
62
|
)
|
|
44
63
|
return ResponseForSecretResponse.from_dict(result)
|
|
45
64
|
|
|
46
|
-
def
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
65
|
+
def get_by_ids(self, ids: List[UUID]) -> ResponseForSecretsResponse:
|
|
66
|
+
result = self.client._run_command(
|
|
67
|
+
Command(secrets=SecretsCommand(
|
|
68
|
+
get_by_ids=SecretsGetRequest(ids))
|
|
69
|
+
))
|
|
70
|
+
return ResponseForSecretsResponse.from_dict(result)
|
|
71
|
+
|
|
72
|
+
def create(
|
|
73
|
+
self,
|
|
74
|
+
organization_id: UUID,
|
|
75
|
+
key: str,
|
|
76
|
+
value: str,
|
|
77
|
+
note: Optional[str],
|
|
78
|
+
project_ids: Optional[List[UUID]] = None,
|
|
79
|
+
) -> ResponseForSecretResponse:
|
|
80
|
+
if note is None:
|
|
81
|
+
# secrets api does not accept empty notes
|
|
82
|
+
note = ""
|
|
52
83
|
result = self.client._run_command(
|
|
53
84
|
Command(secrets=SecretsCommand(
|
|
54
85
|
create=SecretCreateRequest(key, note, organization_id, value, project_ids)))
|
|
@@ -62,13 +93,18 @@ class SecretsClient:
|
|
|
62
93
|
)
|
|
63
94
|
return ResponseForSecretIdentifiersResponse.from_dict(result)
|
|
64
95
|
|
|
65
|
-
def update(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
96
|
+
def update(
|
|
97
|
+
self,
|
|
98
|
+
organization_id: str,
|
|
99
|
+
id: str,
|
|
100
|
+
key: str,
|
|
101
|
+
value: str,
|
|
102
|
+
note: Optional[str],
|
|
103
|
+
project_ids: Optional[List[UUID]] = None,
|
|
104
|
+
) -> ResponseForSecretResponse:
|
|
105
|
+
if note is None:
|
|
106
|
+
# secrets api does not accept empty notes
|
|
107
|
+
note = ""
|
|
72
108
|
result = self.client._run_command(
|
|
73
109
|
Command(secrets=SecretsCommand(update=SecretPutRequest(
|
|
74
110
|
id, key, note, organization_id, value, project_ids)))
|
|
@@ -81,6 +117,13 @@ class SecretsClient:
|
|
|
81
117
|
)
|
|
82
118
|
return ResponseForSecretsDeleteResponse.from_dict(result)
|
|
83
119
|
|
|
120
|
+
def sync(self, organization_id: str, last_synced_date: Optional[str]) -> ResponseForSecretsSyncResponse:
|
|
121
|
+
result = self.client._run_command(
|
|
122
|
+
Command(secrets=SecretsCommand(sync=SecretsSyncRequest(organization_id, last_synced_date)))
|
|
123
|
+
)
|
|
124
|
+
return ResponseForSecretsSyncResponse.from_dict(result)
|
|
125
|
+
|
|
126
|
+
|
|
84
127
|
class ProjectsClient:
|
|
85
128
|
def __init__(self, client: BitwardenClient):
|
|
86
129
|
self.client = client
|
|
@@ -92,8 +135,8 @@ class ProjectsClient:
|
|
|
92
135
|
return ResponseForProjectResponse.from_dict(result)
|
|
93
136
|
|
|
94
137
|
def create(self,
|
|
95
|
-
name: str,
|
|
96
138
|
organization_id: str,
|
|
139
|
+
name: str,
|
|
97
140
|
) -> ResponseForProjectResponse:
|
|
98
141
|
result = self.client._run_command(
|
|
99
142
|
Command(projects=ProjectsCommand(
|
|
@@ -108,10 +151,12 @@ class ProjectsClient:
|
|
|
108
151
|
)
|
|
109
152
|
return ResponseForProjectsResponse.from_dict(result)
|
|
110
153
|
|
|
111
|
-
def update(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
154
|
+
def update(
|
|
155
|
+
self,
|
|
156
|
+
organization_id: str,
|
|
157
|
+
id: str,
|
|
158
|
+
name: str,
|
|
159
|
+
) -> ResponseForProjectResponse:
|
|
115
160
|
result = self.client._run_command(
|
|
116
161
|
Command(projects=ProjectsCommand(update=ProjectPutRequest(
|
|
117
162
|
id, name, organization_id)))
|