From f4389c471458d8de34c4afa3ac1d8c3d30bfc514 Mon Sep 17 00:00:00 2001 From: guillaume Date: Wed, 25 Sep 2024 15:45:18 -0400 Subject: [PATCH] chore: avoid having to match with all keys Signed-off-by: guillaume --- src/notary.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/notary.py b/src/notary.py index 06d9421..ea57e78 100644 --- a/src/notary.py +++ b/src/notary.py @@ -186,7 +186,9 @@ def login(self, username: str, password: str) -> LoginResponse | None: login_params = LoginParams(username=username, password=password) response = self._make_request("POST", "/login", data=asdict(login_params)) if response and response.result: - return LoginResponse(**response.result) + return LoginResponse( + token=response.result.get("token"), + ) return None def token_is_valid(self, token: str) -> bool: @@ -198,7 +200,10 @@ def get_status(self) -> StatusResponse | None: """Return if the Notary server is initialized.""" response = self._make_request("GET", "/status") if response and response.result: - return StatusResponse(**response.result) + return StatusResponse( + initialized=response.result.get("initialized"), + version=response.result.get("version"), + ) return None def create_first_user(self, username: str, password: str) -> CreateUserResponse | None: @@ -208,7 +213,9 @@ def create_first_user(self, username: str, password: str) -> CreateUserResponse "POST", f"/api/{self.API_VERSION}/accounts", data=asdict(create_user_params) ) if response and response.result: - return CreateUserResponse(**response.result) + return CreateUserResponse( + id=response.result.get("id"), + ) return None def list_certificate_requests(self, token: str) -> List[CertificateRequest]: @@ -239,7 +246,9 @@ def create_certificate_request( data=asdict(create_certificate_request_params), ) if response and response.result: - return CreateCertificateRequestResponse(**response.result) + return CreateCertificateRequestResponse( + id=response.result.get("id"), + ) return None def create_certificate( @@ -262,7 +271,9 @@ def create_certificate( data=asdict(create_certificate_params), ) if response and response.result: - return CreateCertificateResponse(**response.result) + return CreateCertificateResponse( + id=response.result.get("id"), + ) return None