Skip to content

Commit

Permalink
adds update pattern to user
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein committed Mar 22, 2024
1 parent 1b712ba commit 9356687
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 5 deletions.
10 changes: 9 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -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
55 changes: 51 additions & 4 deletions src/posit/connect/users.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from typing import List
from typing import List, overload


import requests
Expand Down Expand Up @@ -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
"""
...

@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())
Expand Down

0 comments on commit 9356687

Please sign in to comment.