Skip to content

Commit

Permalink
Revert "[COST-5711] Provide endpoint of all regions for integrations …
Browse files Browse the repository at this point in the history
…team (#5…" (#5399)

This reverts commit b61c403.
  • Loading branch information
lcouzens authored Nov 26, 2024
1 parent 2758a31 commit b8af477
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 43 deletions.
37 changes: 0 additions & 37 deletions koku/api/resource_types/aws_regions/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
# SPDX-License-Identifier: Apache-2.0
#
"""View for AWS by regions."""
import boto3
from django.conf import settings
from django.db.models import F
from django.utils.decorators import method_decorator
from django.views.decorators.vary import vary_on_headers
from rest_framework import filters
from rest_framework import generics
from rest_framework import status
from rest_framework import views
from rest_framework.permissions import AllowAny
from rest_framework.response import Response

from api.common import CACHE_RH_IDENTITY_HEADER
Expand Down Expand Up @@ -58,37 +55,3 @@ def list(self, request):
return super().list(request)
self.queryset = self.queryset.filter(usage_account_id__in=user_access)
return super().list(request)


class AWSAllRegionView(views.APIView):
"""API GET list view for AWS of all regions"""

permission_classes = [AllowAny]

@method_decorator(vary_on_headers(CACHE_RH_IDENTITY_HEADER))
def get(self, request):
supported_query_params = ["limit", "offset", "search"]
error_message = {}
search_values = []
# Test for only supported query_params
if self.request.query_params:
for key in self.request.query_params:
if key not in supported_query_params:
error_message[key] = [{"Unsupported parameter"}]
return Response(error_message, status=status.HTTP_400_BAD_REQUEST)
search_value_str = self.request.query_params.get("search")
if search_value_str:
search_values = search_value_str.split(",")
regions = boto3.Session().get_available_regions("s3")
filtered_regions = []
for region in regions:
if any(value in region for value in search_values):
filtered_regions.append(region)
if not filtered_regions:
filtered_regions = regions
filtered_regions = list(set(filtered_regions))
queryset = [{"value": region} for region in filtered_regions]
paginator = ResourceTypeViewPaginator()
paginated_queryset = paginator.paginate_queryset(queryset, request)
serializer = ResourceTypeSerializer(paginated_queryset, many=True)
return paginator.get_paginated_response(serializer.data)
3 changes: 0 additions & 3 deletions koku/api/resource_types/test/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class ResourceTypesViewTest(IamTestCase):
ENDPOINTS_AWS = [
"aws-accounts",
"aws-regions",
"aws-all-regions",
"aws-services",
"aws-organizational-units",
"aws-categories",
Expand Down Expand Up @@ -250,8 +249,6 @@ def test_rbacpermissions_aws_account_data_returns_null(self):
"""Test that Aws endpoints accept valid Aws permissions."""
for endpoint in self.ENDPOINTS_AWS:
with self.subTest(endpoint=endpoint):
if endpoint == "aws-all-regions":
continue
url = reverse(endpoint)
response = self.client.get(url, **self.headers)
self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand Down
2 changes: 0 additions & 2 deletions koku/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from api.views import AccountSettings
from api.views import AWSAccountRegionView
from api.views import AWSAccountView
from api.views import AWSAllRegionView
from api.views import AWSCategoryView
from api.views import AWSCostForecastView
from api.views import AWSCostView
Expand Down Expand Up @@ -444,7 +443,6 @@
path("resource-types/azure-services/", AzureServiceView.as_view(), name="azure-services"),
path("resource-types/aws-services/", AWSServiceView.as_view(), name="aws-services"),
path("resource-types/aws-regions/", AWSAccountRegionView.as_view(), name="aws-regions"),
path("resource-types/aws-all-regions/", AWSAllRegionView.as_view(), name="aws-all-regions"),
path(
"resource-types/azure-subscription-guids/",
AzureSubscriptionGuidView.as_view(),
Expand Down
1 change: 0 additions & 1 deletion koku/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
from api.resource_types.aws_ec2_compute_os.view import AWSEC2ComputeOperatingSystemView
from api.resource_types.aws_org_unit.view import AWSOrganizationalUnitView
from api.resource_types.aws_regions.view import AWSAccountRegionView
from api.resource_types.aws_regions.view import AWSAllRegionView
from api.resource_types.aws_services.view import AWSServiceView
from api.resource_types.azure_regions.view import AzureRegionView
from api.resource_types.azure_services.view import AzureServiceView
Expand Down

0 comments on commit b8af477

Please sign in to comment.