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

Integrate Resources API #2068

Merged
merged 2 commits into from
Feb 15, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGES/18825.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Integrate gateway resources api
31 changes: 31 additions & 0 deletions galaxy_ng/app/api/resource_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from ansible_base.resource_registry.registry import (
ResourceConfig,
ServiceAPIConfig,
SharedResource,
)
from ansible_base.resource_registry.shared_types import UserType, TeamType
from galaxy_ng.app import models


class APIConfig(ServiceAPIConfig):
service_type = "galaxy"


RESOURCE_LIST = (
ResourceConfig(
models.auth.User,
shared_resource=SharedResource(
serializer=UserType,
is_provider=False
),
name_field="username"
),
ResourceConfig(
models.auth.Group,
shared_resource=SharedResource(
serializer=TeamType,
is_provider=True
),
name_field="name"
),
)
4 changes: 4 additions & 0 deletions galaxy_ng/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

INSTALLED_APPS = [
'rest_framework.authtoken',
'ansible_base.resource_registry',
'dynaconf_merge',
]

Expand Down Expand Up @@ -295,3 +296,6 @@
# When set to True will enable the DYNAMIC settungs feature
# Individual allowed dynamic keys are set on ./dynamic_settings.py
GALAXY_DYNAMIC_SETTINGS = False

# DJANGO ANSIBLE BASE RESOURCES REGISTRY SETTINGS
ANSIBLE_BASE_RESOURCE_CONFIG_MODULE = "galaxy_ng.app.api.resource_api"
5 changes: 5 additions & 0 deletions galaxy_ng/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from galaxy_ng.app.api import urls as api_urls
from galaxy_ng.ui import urls as ui_urls

from ansible_base.resource_registry.urls import (
urlpatterns as resource_api_urls,
)

from drf_spectacular.views import (
SpectacularJSONAPIView,
SpectacularYAMLAPIView,
Expand Down Expand Up @@ -45,6 +49,7 @@
name="swagger-ui",
),
path("healthz", views.health_view),
path(f"{API_PATH_PREFIX}", include(resource_api_urls))
]

if settings.get("API_ROOT") != "/pulp/":
Expand Down
Loading