Host Metrics List API

This commit is contained in:
Martin Slemr
2023-02-02 15:17:14 +01:00
committed by John Westcott IV
parent bf98f62654
commit ef4e77d78f
5 changed files with 61 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ from awx.main.models import (
ExecutionEnvironment,
Group,
Host,
HostMetric,
Instance,
InstanceGroup,
InstanceLink,
@@ -5386,6 +5387,14 @@ class InstanceHealthCheckSerializer(BaseSerializer):
fields = read_only_fields
class HostMetricSerializer(BaseSerializer):
show_capabilities = ['delete']
class Meta:
model = HostMetric
fields = ("hostname", "first_automation", "last_automation")
class InstanceGroupSerializer(BaseSerializer):
show_capabilities = ['edit', 'delete']
capacity = serializers.SerializerMethodField()

View File

@@ -0,0 +1,10 @@
# Copyright (c) 2017 Ansible, Inc.
# All Rights Reserved.
from django.urls import re_path
from awx.api.views import HostMetricList
urls = [re_path(r'$^', HostMetricList.as_view(), name='host_metric_list')]
__all__ = ['urls']

View File

@@ -50,6 +50,7 @@ from .inventory import urls as inventory_urls
from .execution_environments import urls as execution_environment_urls
from .team import urls as team_urls
from .host import urls as host_urls
from .host_metric import urls as host_metric_urls
from .group import urls as group_urls
from .inventory_source import urls as inventory_source_urls
from .inventory_update import urls as inventory_update_urls
@@ -118,6 +119,7 @@ v2_urls = [
re_path(r'^teams/', include(team_urls)),
re_path(r'^inventories/', include(inventory_urls)),
re_path(r'^hosts/', include(host_urls)),
re_path(r'^host_metrics/', include(host_metric_urls)),
re_path(r'^groups/', include(group_urls)),
re_path(r'^inventory_sources/', include(inventory_source_urls)),
re_path(r'^inventory_updates/', include(inventory_update_urls)),

View File

@@ -1548,6 +1548,13 @@ class HostRelatedSearchMixin(object):
return ret
class HostMetricList(ListAPIView):
always_allow_superuser = False
name = _("Host Metrics List")
model = models.HostMetric
serializer_class = serializers.HostMetricSerializer
class HostList(HostRelatedSearchMixin, ListCreateAPIView):
always_allow_superuser = False
model = models.Host