diff --git a/awxkit/awxkit/api/pages/role_assignments.py b/awxkit/awxkit/api/pages/role_assignments.py new file mode 100644 index 000000000000..024c6725006d --- /dev/null +++ b/awxkit/awxkit/api/pages/role_assignments.py @@ -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 +) + + +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 +) + + +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) diff --git a/awxkit/awxkit/api/pages/role_definitions.py b/awxkit/awxkit/api/pages/role_definitions.py new file mode 100644 index 000000000000..9e64839a01b7 --- /dev/null +++ b/awxkit/awxkit/api/pages/role_definitions.py @@ -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) diff --git a/awxkit/awxkit/api/resources.py b/awxkit/awxkit/api/resources.py index 4ffb70a9b563..a567c37ebb47 100644 --- a/awxkit/awxkit/api/resources.py +++ b/awxkit/awxkit/api/resources.py @@ -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+/'