From 3b88e18cd9abd341b888206ba1d34d65907fc124 Mon Sep 17 00:00:00 2001 From: tdstein Date: Fri, 22 Mar 2024 13:21:35 -0400 Subject: [PATCH] adds update pattern to user --- .coveragerc | 10 ++++++- src/posit/connect/users.py | 55 +++++++++++++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/.coveragerc b/.coveragerc index a86b4247..401dc6fd 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,10 @@ +# This file contains the configuration settings for the coverage report generated. + [report] - fail_under = 80 +# exclude '...' (ellipsis literal). This option uses regex, so an escaped literal is required. +# exclude 'raise NotImplementedError()'. +exclude_also = + \.\.\. + raise NotImplementedError() + +fail_under = 80 diff --git a/src/posit/connect/users.py b/src/posit/connect/users.py index 0f41d23c..4d81de99 100644 --- a/src/posit/connect/users.py +++ b/src/posit/connect/users.py @@ -1,5 +1,5 @@ from __future__ import annotations -from typing import List +from typing import List, overload import requests @@ -91,9 +91,56 @@ def unlock(self): self.session.post(url, json=body) super().update(locked=False) - def _update(self, body): - if len(body) == 0: - return + @overload + def update( + self, + email: str = ..., + username: str = ..., + first_name: str = ..., + last_name: str = ..., + user_role: str = ..., + ) -> None: + """ + Update the user. + + Args: + email (str): The email address for the user. + username (str): The username for the user. + first_name (str): The first name for the user. + last_name (str): The last name for the user. + user_role (str): The role for the user. + + Returns: + None: This method does not return anything. + """ + ... + + @overload + def update(self, *args, **kwargs) -> None: + """ + Update the user. + + Args: + *args + **kwargs + + Returns: + None + """ + ... + + def update(self, *args, **kwargs) -> None: + """ + Update the user. + + Args: + *args + **kwargs + + Returns: + None + """ + body = dict(*args, **kwargs) url = urls.append_path(self.config.url, f"v1/users/{self.guid}") response = self.session.put(url, json=body) super().update(**response.json())