Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

tdstein
Copy link
Collaborator

@tdstein tdstein commented Feb 5, 2024

No description provided.

@tdstein
Copy link
Collaborator Author

tdstein commented Feb 5, 2024

CI is failing due to a lack of tests. Waiting on feedback on the general idea before implementing it further.

Comment on lines +1 to +9
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"}))
Copy link
Collaborator Author

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.

Copy link
Collaborator

@nealrichardson nealrichardson left a 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(
Copy link
Collaborator

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()?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@nealrichardson nealrichardson Feb 11, 2024

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.

What libraries are you thinking of where this is common?

Copy link
Collaborator Author

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")
Copy link
Collaborator

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.

@tdstein
Copy link
Collaborator Author

tdstein commented Feb 14, 2024

Closing since this is stale.

@tdstein tdstein closed this Feb 14, 2024
@nealrichardson nealrichardson deleted the tdstein/9-1 branch February 14, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants