From 697cd92d762f4573612c1a3b1cb6666cea250d70 Mon Sep 17 00:00:00 2001 From: Beth Nakamura Date: Mon, 30 Sep 2019 09:25:51 -0400 Subject: [PATCH] paginated responses for client.describe_services call to capture all services (#45) * paginated responses for client.describe_services call to capture all services * bump version --- CHANGELOG.md | 3 +++ awspricing/__init__.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ea1a5c..8f1fb72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 2.0.1 + * Use a paginator to retrieve service list from AWS API and fetch all AWS services + ## 2.0.0 * Migrate to use AWS Price List query API instead of offer files diff --git a/awspricing/__init__.py b/awspricing/__init__.py index 99e7d48..4d36ae4 100644 --- a/awspricing/__init__.py +++ b/awspricing/__init__.py @@ -7,7 +7,7 @@ from .cache import maybe_read_from_cache, maybe_write_to_cache -__version__ = "2.0.0" +__version__ = "2.0.1" _SERVICES = {} # type: Dict[str, Type[AWSOffer]] service_list = [] # type: List[str] @@ -60,8 +60,11 @@ def _fetch_offer(offer_name, version=None): def all_services_names(): - resp = client.describe_services() - services = [x['ServiceCode'] for x in resp['Services']] + paginator = client.get_paginator('describe_services') + resp_pages = paginator.paginate() + services = [] + for page in resp_pages: + services.extend([x['ServiceCode'] for x in page['Services']]) return services