Skip to content

Commit 0627c10

Browse files
committed
models - use serialize_by_alias
1 parent 971f053 commit 0627c10

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

src/vaultwarden/models/bitwarden.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Attachment(BitwardenBaseModel):
245245

246246
def download(self):
247247
v = self._bitwarden_client._http_client.get(self.url)
248-
return BinarySymmetricCipher.decode(v.content, self.key)
248+
return BinarySymmetricCipher.decode(v.content, self.Key)
249249

250250

251251
class _CipherBase(BitwardenBaseModel):
@@ -624,9 +624,7 @@ def set_users(
624624
if isinstance(users[0], CollectionUser):
625625
users = cast("list[CollectionUser]", users)
626626
users_payload = [
627-
user.model_dump(
628-
exclude={"CollectionId"}, by_alias=True, mode="json"
629-
)
627+
user.model_dump(exclude={"CollectionId"}, mode="json")
630628
for user in users
631629
]
632630
else:
@@ -739,7 +737,6 @@ def add_collections(self, collections: list[UUID]):
739737
exclude={
740738
"Permissions": self.Permissions is None,
741739
},
742-
by_alias=True,
743740
mode="json",
744741
)
745742
return (
@@ -774,7 +771,6 @@ def remove_collections(self, collections: list[UUID]):
774771
exclude={
775772
"Permissions": self.Permissions is None,
776773
},
777-
by_alias=True,
778774
mode="json",
779775
)
780776
return self.api_client.api_request(
@@ -812,7 +808,6 @@ def update_collection(self, collections: list[UUID]):
812808
exclude={
813809
"Permissions": self.Permissions is None,
814810
},
815-
by_alias=True,
816811
mode="json",
817812
),
818813
)
@@ -895,7 +890,6 @@ def invite(
895890
ex: dict[str, Literal[True]] = {"UserId": True}
896891
collections_payload.append(
897892
coll.model_dump(
898-
by_alias=True,
899893
mode="json",
900894
exclude=ex,
901895
)
@@ -943,7 +937,6 @@ def confirm(self, user: OrganizationUserDetails):
943937
confirm = ConfirmData.model_construct(Key=self.key())
944938
payload = confirm.model_dump(
945939
mode="json",
946-
by_alias=True,
947940
context=CryptoContext(client=self.api_client, stack=[publicKey]),
948941
)
949942
resp = self.api_client.api_request(

src/vaultwarden/models/permissive_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ class PermissiveBaseModel(
99
alias_generator=pascal_case_to_camel_case,
1010
populate_by_name=True,
1111
arbitrary_types_allowed=True,
12+
serialize_by_alias=True,
1213
):
1314
pass

0 commit comments

Comments
 (0)