-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adds partial users implementation based on lists #14
Conversation
CI is failing due to a lack of tests. Waiting on feedback on the general idea before implementing it further. |
from posit.connect import make_client | ||
|
||
client = Client() | ||
res = client.users.get_current_user() | ||
print(res.json()) | ||
client = make_client() | ||
for user in client.users.find({"username": "aaron"}): | ||
print(user) | ||
|
||
print(client.users.find_one()) | ||
|
||
print(client.users.find_one({"guid": "f155520a-ca2e-4084-b0a0-12120b7d1add"})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nealrichardson - let me know your thoughts on this. It's similar to the PyMongo style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally makes sense to me
from .client import Client | ||
|
||
|
||
def make_client( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this for? how is make_client()
different from Client()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Methods are slightly more "pythonic"/"idiomatic." And this is what boto3 does, so hopefully, it is more familiar to the average user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing this.
- boto3 doesn't seem to have (or promote at least) a connection/client object, it picks up AWS config from the environment: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#using-boto3
- databricks instantiates WorkspaceClient: https://github.com/databricks/databricks-sdk-py?tab=readme-ov-file#getting-started
What libraries are you thinking of where this is common?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boto3.client('s3')
and boto3.resource('s3')
is what I'm referring to. https://github.com/boto/boto3/blob/develop/boto3/__init__.py#L86-L101
Both are factory methods which return a new instance based on the provided service_name.
`self` | ||
""" | ||
self.clear() | ||
endpoint = os.path.join(self._endpoint, "__api__/v1/users") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this pattern in a few places, might want to make some URL constructor method for Client or something, which handles the __api__
prepending etc.
Closing since this is stale. |
No description provided.