Skip to content

Commit

Permalink
[AAP-18826] Integrate Resources API (#652)
Browse files Browse the repository at this point in the history
* implement resource_registry app from django-ansible-base
  • Loading branch information
Dostonbek1 authored Feb 13, 2024
1 parent a968972 commit c97a431
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/aap_eda/api/resource_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ansible_base.resource_registry.registry import (
ResourceConfig,
ServiceAPIConfig,
SharedResource,
)
from ansible_base.resource_registry.shared_types import UserType

from aap_eda.core import models


class APIConfig(ServiceAPIConfig):
service_type = "eda"


RESOURCE_LIST = (
ResourceConfig(
models.User,
shared_resource=SharedResource(serializer=UserType, is_provider=False),
name_field="username",
),
)
4 changes: 4 additions & 0 deletions src/aap_eda/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from ansible_base.lib.dynamic_config.dynamic_urls import api_version_urls
from ansible_base.resource_registry.urls import (
urlpatterns as resource_api_urls,
)
from django.urls import include, path
from drf_spectacular.views import (
SpectacularJSONAPIView,
Expand Down Expand Up @@ -71,6 +74,7 @@
# <- Experimental LDAP Auth https://issues.redhat.com/browse/AAP-16938
path("", include(api_version_urls)),
# ->
path("", include(resource_api_urls)),
path("", include(openapi_urls)),
path("auth/session/login/", views.SessionLoginView.as_view()),
path("auth/session/logout/", views.SessionLogoutView.as_view()),
Expand Down
6 changes: 6 additions & 0 deletions src/aap_eda/settings/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def _get_secret_key() -> str:
"django_filters",
# Experimental LDAP Auth https://issues.redhat.com/browse/AAP-16938
"ansible_base.authentication",
"ansible_base.resource_registry",
# Local apps
"aap_eda.api",
"aap_eda.core",
Expand Down Expand Up @@ -479,6 +480,11 @@ def _get_secret_key() -> str:
"ANSIBLE_BASE_JWT_KEY", "https://localhost"
)

# ---------------------------------------------------------
# DJANGO ANSIBLE BASE RESOURCES REGISTRY SETTINGS
# ---------------------------------------------------------
ANSIBLE_BASE_RESOURCE_CONFIG_MODULE = "aap_eda.api.resource_api"

ACTIVATION_DB_HOST = settings.get(
"ACTIVATION_DB_HOST", "host.containers.internal"
)
Expand Down

0 comments on commit c97a431

Please sign in to comment.