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

Create and register page types for the new RBAC endpoints #15275

Draft
wants to merge 1 commit into
base: devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions awxkit/awxkit/api/pages/role_assignments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import logging

# from awxkit.api.mixins import DSAdapter, HasCreate, HasCopy
# from awxkit.api.pages import (
# Credential,
# Organization,
# )
from awxkit.api.resources import resources

# from awxkit.utils import random_title, PseudoNamespace, filter_by_class

from . import base
from . import page


log = logging.getLogger(__name__)


class RoleTeamAssignment(base.Base):
NATURAL_KEY = ('team', 'content_object', 'role_definition')


page.register_page(
[resources.role_team_assignment, (resources.role_definition_team_assignments, 'post'), (resources.role_team_assignments, 'post')], RoleTeamAssignment
Copy link
Member

Choose a reason for hiding this comment

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

resources.role_definition_team_assignments would be read-only, so it looks like the most correct thing would be to delete it here.

)


class RoleUserAssignment(base.Base):
NATURAL_KEY = ('user', 'content_object', 'role_definition')


page.register_page(
[resources.role_user_assignment, (resources.role_definition_user_assignments, 'post'), (resources.role_user_assignments, 'post')], RoleUserAssignment
Copy link
Member

Choose a reason for hiding this comment

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

The other thing worth noting is that assignments are immutable, meaning the detail endpoint, resources.role_user_assignment, would not allow PATCH/PUT... but it seems that no references to the detail endpoint exist here in the first place, so I guess we're good.

)


class RoleTeamAssignments(page.PageList, RoleTeamAssignment):
pass


page.register_page([resources.role_definition_team_assignments, resources.role_team_assignments], RoleTeamAssignments)


class RoleUserAssignments(page.PageList, RoleUserAssignment):
pass


page.register_page([resources.role_definition_user_assignments, resources.role_user_assignments], RoleUserAssignments)
30 changes: 30 additions & 0 deletions awxkit/awxkit/api/pages/role_definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import logging

# from awxkit.api.mixins import DSAdapter, HasCreate, HasCopy
# from awxkit.api.pages import (
# Credential,
# Organization,
# )
from awxkit.api.resources import resources

# from awxkit.utils import random_title, PseudoNamespace, filter_by_class

from . import base
from . import page


log = logging.getLogger(__name__)


class RoleDefinition(base.Base):
NATURAL_KEY = ('name',)


page.register_page([resources.role_definition, (resources.role_definitions, 'post')], RoleDefinition)


class RoleDefinitions(page.PageList, RoleDefinition):
pass


page.register_page([resources.role_definitions], RoleDefinitions)
8 changes: 8 additions & 0 deletions awxkit/awxkit/api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ class Resources(object):
_related_users = r'\w+/\d+/users/'
_related_workflow_job_templates = r'\w+/\d+/workflow_job_templates/'
_role = r'roles/\d+/'
_role_definition = r'role_definitions/\d+/'
_role_definitions = r'role_definitions/'
_role_definition_team_assignments = r'role_definitions/\d+/team_assignments/'
_role_definition_user_assignments = r'role_definitions/\d+/user_assignments/'
_role_team_assignment = r'role_team_assignments/\d+/'
_role_team_assignments = r'role_team_assignments/'
_role_user_assignment = r'role_user_assignments/\d+/'
_role_user_assignments = r'role_user_assignments/'
_roles = 'roles/'
_roles_related_teams = r'roles/\d+/teams/'
_schedule = r'schedules/\d+/'
Expand Down
Loading