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

Adding rbac sdk path #17

Merged
merged 1 commit into from
Oct 9, 2024
Merged

Adding rbac sdk path #17

merged 1 commit into from
Oct 9, 2024

Conversation

ankush-cohere
Copy link
Contributor

@ankush-cohere ankush-cohere commented Oct 4, 2024

This PR introduces a new file, compass_sdk/root_rbac.py, which defines a CompassRootClient class for managing users, groups, and roles in a Compass system. The class provides methods for fetching, creating, and deleting users, groups, and roles, as well as managing role mappings.

The CompassRootClient class is initialised with a compass_url and a root_user_token, which are used to construct the base URL and authorisation headers for API requests. The class methods use the requests library to interact with the Compass API, performing various operations:

  • fetch_users retrieves a list of users and returns a list of UserFetchResponse objects.
  • create_users creates new users and returns a list of UserCreateResponse objects.
  • delete_users deletes users by their names and returns a list of UserDeleteResponse objects.
  • fetch_groups fetches a list of groups and returns a list of GroupFetchResponse objects.
  • create_groups creates new groups and returns a list of GroupCreateResponse objects.
  • delete_groups deletes groups by their names and returns a list of GroupUserDeleteResponse objects.
  • delete_user_group removes a user from a group and returns a GroupUserDeleteResponse object.
  • fetch_roles retrieves a list of roles and returns a list of RoleFetchResponse objects.
  • insert_roles creates new roles and returns a list of RoleCreateResponse objects.
  • update_role updates a role's policies and returns a RoleCreateResponse object.
  • delete_roles deletes roles by their IDs and returns a list of RoleDeleteResponse objects.
  • insert_role_mappings creates new role mappings and returns a list of RoleMappingResponse objects.
  • fetch_role_mappings fetches a list of role mappings and returns a list of RoleMappingResponse objects.
  • delete_role_mappings deletes role mappings for a specific role and group and returns a list of RoleMappingDeleteResponse objects.
  • create_root_user creates a root user and returns a UserCreateResponse object.

Additionally, the PR adds a new file, compass_sdk/types.py, which defines various Pydantic models for the Compass system, including:

  • UserFetchResponse, UserCreateRequest, UserCreateResponse, and UserDeleteResponse for user-related operations.
  • GroupFetchResponse, GroupCreateRequest, GroupCreateResponse, and GroupUserDeleteResponse for group-related operations.
  • PolicyRequest, PolicyResponse, RoleFetchResponse, RoleCreateRequest, RoleCreateResponse, and RoleDeleteResponse for role-related operations.
  • RoleMappingRequest, RoleMappingResponse, and RoleMappingDeleteResponse for role mapping operations.

@ankush-cohere ankush-cohere requested a review from a team as a code owner October 4, 2024 16:46
@ankush-cohere ankush-cohere force-pushed the SEA-1462/rbac_admin branch 2 times, most recently from 56dd8fc to a3b5932 Compare October 4, 2024 17:30
compass_sdk/root_rbac.py Outdated Show resolved Hide resolved
Copy link
Contributor

@benrules3 benrules3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was able to get it running locally and verified, but the url needed an extra /api/ added -see comment along those lines... Once updated this is good to go 👍

compass_sdk/compass.py Outdated Show resolved Hide resolved
compass_sdk/rbac.py Outdated Show resolved Hide resolved
compass_sdk/compass.py Show resolved Hide resolved
compass_sdk/compass.py Outdated Show resolved Hide resolved
@ankush-cohere ankush-cohere merged commit ea312b3 into main Oct 9, 2024
4 checks passed
@ankush-cohere ankush-cohere deleted the SEA-1462/rbac_admin branch October 9, 2024 14:35
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