Skip to content

Commit c29350b

Browse files
committed
Add back group get function
1 parent 8094a70 commit c29350b

File tree

4 files changed

+125
-44
lines changed

4 files changed

+125
-44
lines changed

src/onepassword/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .secrets import Secrets
88
from .items import Items
99
from .vaults import Vaults
10+
from .groups import Groups
1011

1112

1213
import sys

src/onepassword/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
from .secrets import Secrets
99
from .items import Items
1010
from .vaults import Vaults
11+
from .groups import Groups
1112

1213

1314
class Client:
1415
secrets: Secrets
1516
items: Items
1617
vaults: Vaults
18+
groups: Groups
1719

1820
@classmethod
1921
async def authenticate(
@@ -37,6 +39,7 @@ async def authenticate(
3739
authenticated_client.secrets = Secrets(client_id, core)
3840
authenticated_client.items = Items(client_id, core)
3941
authenticated_client.vaults = Vaults(client_id, core)
42+
authenticated_client.groups = Groups(client_id, core)
4043

4144
authenticated_client._finalizer = weakref.finalize(
4245
cls, core.release_client, client_id

src/onepassword/groups.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Code generated by op-codegen - DO NO EDIT MANUALLY
2+
3+
from .core import Core
4+
from pydantic import TypeAdapter
5+
from .types import Group, GroupGetParams
6+
7+
8+
class Groups:
9+
"""
10+
The Groups API holds all the operations the SDK client can perform on 1Password groups.
11+
"""
12+
13+
def __init__(self, client_id, core: Core):
14+
self.client_id = client_id
15+
self.core = core
16+
17+
async def get(self, group_id: str, group_params: GroupGetParams) -> Group:
18+
response = await self.core.invoke(
19+
{
20+
"invocation": {
21+
"clientId": self.client_id,
22+
"parameters": {
23+
"name": "GroupsGet",
24+
"parameters": {
25+
"group_id": group_id,
26+
"group_params": group_params.model_dump(by_alias=True),
27+
},
28+
},
29+
}
30+
}
31+
)
32+
33+
response = TypeAdapter(Group).validate_json(response)
34+
return response

src/onepassword/types.py

Lines changed: 87 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -140,41 +140,114 @@ class GeneratePasswordResponse(BaseModel):
140140
"""
141141

142142

143-
class GroupAccess(BaseModel):
143+
class GroupType(str, Enum):
144+
OWNERS = "owners"
145+
"""
146+
The owners group, which gives the following permissions:
147+
- Do everything the Admin group can do
148+
- See every vault other than the personal vaults
149+
- Change people's names
150+
- See billing
151+
- Change billing
152+
- Make other people owners
153+
- Delete a person
154+
"""
155+
ADMINISTRATORS = "administrators"
156+
"""
157+
The administrators group, which gives the following permissions:
158+
- Perform recovery
159+
- Create new vaults
160+
- Invite new members
161+
- See vault metadata, including the vault name and who has access.
162+
- Make other people admins
163+
"""
164+
RECOVERY = "recovery"
165+
"""
166+
The recovery group. It contains recovery keysets, and is added to every vault to allow for recovery.
167+
168+
No one is added to this.
169+
"""
170+
EXTERNALACCOUNTMANAGERS = "externalAccountManagers"
171+
"""
172+
The external account managers group or EAM is a mandatory group for managed accounts that has
173+
same permissions as the owners.
174+
"""
175+
TEAMMEMBERS = "teamMembers"
176+
"""
177+
Members of a team that a user is on.
144178
"""
145-
Represents a group's access to a 1Password vault.
146-
This is used for granting permissions
179+
USERDEFINED = "userDefined"
147180
"""
181+
A custom, user defined group.
182+
"""
183+
UNSUPPORTED = "unsupported"
184+
"""
185+
Support for new or renamed group types
186+
"""
187+
148188

149-
group_id: str
189+
class GroupState(str, Enum):
190+
ACTIVE = "active"
150191
"""
151-
The group's ID
192+
This group is active
152193
"""
153-
permissions: int
194+
DELETED = "deleted"
195+
"""
196+
This group has been deleted
197+
"""
198+
UNSUPPORTED = "unsupported"
154199
"""
155-
The group's set of permissions for the vault
200+
This group is in an unknown state
156201
"""
157202

158203

159-
class GroupVaultAccess(BaseModel):
204+
class VaultAccessorType(str, Enum):
205+
USER = "user"
206+
GROUP = "group"
207+
208+
209+
class VaultAccess(BaseModel):
160210
"""
161-
Represents a group's access to a 1Password vault.
211+
Represents the vault access information.
162212
"""
163213

164-
vault_id: str
214+
model_config = ConfigDict(populate_by_name=True)
215+
216+
vault_uuid: str = Field(alias="vaultUuid")
217+
"""
218+
The vault's UUID.
219+
"""
220+
accessor_type: VaultAccessorType = Field(alias="accessorType")
165221
"""
166-
The vault's ID
222+
The vault's accessor type.
167223
"""
168-
group_id: str
224+
accessor_uuid: str = Field(alias="accessorUuid")
169225
"""
170-
The group's ID
226+
The vault's accessor UUID.
171227
"""
172228
permissions: int
173229
"""
174-
The group's set of permissions for the vault
230+
The permissions granted to this vault
175231
"""
176232

177233

234+
class Group(BaseModel):
235+
model_config = ConfigDict(populate_by_name=True)
236+
237+
id: str
238+
title: str
239+
description: str
240+
group_type: GroupType = Field(alias="groupType")
241+
state: GroupState
242+
vault_access: Optional[List[VaultAccess]] = Field(alias="vaultAccess", default=None)
243+
244+
245+
class GroupGetParams(BaseModel):
246+
model_config = ConfigDict(populate_by_name=True)
247+
248+
vault_permissions: Optional[bool] = Field(alias="vaultPermissions", default=None)
249+
250+
178251
class ItemCategory(str, Enum):
179252
LOGIN = "Login"
180253
SECURENOTE = "SecureNote"
@@ -1154,36 +1227,6 @@ class VaultType(str, Enum):
11541227
UNSUPPORTED = "unsupported"
11551228

11561229

1157-
class VaultAccessorType(str, Enum):
1158-
USER = "user"
1159-
GROUP = "group"
1160-
1161-
1162-
class VaultAccess(BaseModel):
1163-
"""
1164-
Represents the vault access information.
1165-
"""
1166-
1167-
model_config = ConfigDict(populate_by_name=True)
1168-
1169-
vault_uuid: str = Field(alias="vaultUuid")
1170-
"""
1171-
The vault's UUID.
1172-
"""
1173-
accessor_type: VaultAccessorType = Field(alias="accessorType")
1174-
"""
1175-
The vault's accessor type.
1176-
"""
1177-
accessor_uuid: str = Field(alias="accessorUuid")
1178-
"""
1179-
The vault's accessor UUID.
1180-
"""
1181-
permissions: int
1182-
"""
1183-
The permissions granted to this vault
1184-
"""
1185-
1186-
11871230
class Vault(BaseModel):
11881231
"""
11891232
Represents regular vault information together with the vault's access information.

0 commit comments

Comments
 (0)