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

filter users.find and users.find_one by fields in dataframe, not prefix #173

Open
kmasiello opened this issue Apr 15, 2024 · 1 comment
Open
Labels
wontfix This will not be worked on
Milestone

Comments

@kmasiello
Copy link

users.find() and users.find_one() appear to take an input of prefix to filter results. Examples:

>>> client.users.find(prefix="publisher1")
[{'email': 'publisher1@example.com',
  'username': 'publisher1',
  'first_name': 'Publisher1',
  'last_name': 'Account',
  'user_role': 'publisher',
  'created_time': '2024-04-02T17:43:54Z',
  'updated_time': '2024-04-02T17:43:54Z',
  'active_time': '2024-04-15T20:45:58Z',
  'confirmed': True,
  'locked': False,
  'guid': '010b18bf-96b9-499f-bb0f-7519a22ca870'}]

However, prefix is not part of the API endpoint schema.

Filtering on username, guid, email, or any other values from the endpoint schema returns all values, not filtered.

>>> client.users.find(username="publisher1")
[{'email': 'admin1@example.com',
  'username': 'admin1',
  'first_name': 'Admin1',
  'last_name': 'Account',
  'user_role': 'administrator',
  'created_time': '2024-04-02T17:43:51Z',
  'updated_time': '2024-04-02T17:43:51Z',
  'active_time': '2024-04-02T17:43:51Z',
  'confirmed': True,
  'locked': False,
  'guid': '55de91a9-88ac-443c-a003-a5150c783bfa'},
 {'email': 'admin2@example.com',
  'username': 'admin2',
  'first_name': 'Admin2',
  'last_name': 'Account',
  'user_role': 'administrator',
  'created_time': '2024-04-02T17:43:52Z',
  'updated_time': '2024-04-02T17:43:52Z',
  'active_time': '2024-04-02T17:43:52Z',
  'confirmed': True,
  'locked': False,
  'guid': '9423a115-dbc4-4b29-b592-5c9c5e3f20d0'},
 {'email': 'admin3@example.com',
  'username': 'admin3',
  'first_name': 'Admin3',
  'last_name': 'Account',
  'user_role': 'administrator',
  'created_time': '2024-04-02T17:43:53Z',
  'updated_time': '2024-04-02T17:43:53Z',
  'active_time': '2024-04-02T17:43:53Z',
  'confirmed': True,
  'locked': False,
  'guid': '3c36fe86-3d9c-4658-9791-b6ae035b682a'},
 {'email': 'publisher1@example.com',
  'username': 'publisher1',
  'first_name': 'Publisher1',
  'last_name': 'Account',
  'user_role': 'publisher',
  'created_time': '2024-04-02T17:43:54Z',
  'updated_time': '2024-04-02T17:43:54Z',
  'active_time': '2024-04-15T20:45:58Z',
  'confirmed': True,
  'locked': False,
  'guid': '010b18bf-96b9-499f-bb0f-7519a22ca870'},
 {'email': 'publisher2@example.com',
  'username': 'publisher2',
  'first_name': 'Publisher2',
  'last_name': 'Account',
  'user_role': 'publisher',
  'created_time': '2024-04-02T17:43:55Z',
  'updated_time': '2024-04-02T17:43:55Z',
  'active_time': '2024-04-02T17:43:55Z',
  'confirmed': True,
  'locked': False,
  'guid': '6701cdc3-1464-4dbc-85a4-ed55a21c0c09'},
 {'email': 'publisher3@example.com',
  'username': 'publisher3',
  'first_name': 'Publisher3',
  'last_name': 'Account',
  'user_role': 'publisher',
  'created_time': '2024-04-02T17:43:56Z',
  'updated_time': '2024-04-02T17:43:56Z',
  'active_time': '2024-04-02T17:43:56Z',
  'confirmed': True,
  'locked': False,
  'guid': '5b056baf-7168-438f-b649-a4f386378cb0'},
 {'email': 'viewer1@example.com',
  'username': 'viewer1',
  'first_name': 'Viewer1',
  'last_name': 'Account',
  'user_role': 'viewer',
  'created_time': '2024-04-02T17:43:57Z',
  'updated_time': '2024-04-02T17:43:57Z',
  'active_time': '2024-04-02T17:43:57Z',
  'confirmed': True,
  'locked': False,
  'guid': '3963f064-47bb-4b21-b490-00fb7efddc21'},
 {'email': 'viewer2@example.com',
  'username': 'viewer2',
  'first_name': 'Viewer2',
  'last_name': 'Account',
  'user_role': 'viewer',
  'created_time': '2024-04-02T17:43:58Z',
  'updated_time': '2024-04-02T17:43:58Z',
  'active_time': '2024-04-02T17:43:58Z',
  'confirmed': True,
  'locked': False,
  'guid': 'daafcdad-dc4c-4b6d-9067-b89f603b7935'},
 {'email': 'viewer3@example.com',
  'username': 'viewer3',
  'first_name': 'Viewer3',
  'last_name': 'Account',
  'user_role': 'viewer',
  'created_time': '2024-04-02T17:43:59Z',
  'updated_time': '2024-04-02T17:43:59Z',
  'active_time': '2024-04-02T17:43:59Z',
  'confirmed': True,
  'locked': False,
  'guid': '0f141b69-b28a-4ddc-86f9-0f2683c0a4eb'}]
@tdstein
Copy link
Collaborator

tdstein commented Apr 18, 2024

Currently, the Connect API only supports filtering on the following fields: https://github.com/posit-dev/posit-sdk-py/blob/main/src/posit/connect/users.py#L161-L165

Filtering on any other fields in the schema must be done client side. We could add this to the SDK, but the logic will be equivalent to filtering on the pandas dataframe directly.

For guid, you can use the users.get method, which accepts the guid as a single parameter.

@tdstein tdstein added the wontfix This will not be worked on label Apr 18, 2024
@tdstein tdstein added this to the 0.3.0 milestone Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants