Skip to content

Commit

Permalink
paginated responses for client.describe_services call to capture all …
Browse files Browse the repository at this point in the history
…services (#45)

* paginated responses for client.describe_services call to capture all services

* bump version
  • Loading branch information
bnak authored Sep 30, 2019
1 parent 3041a96 commit 697cd92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions awspricing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 697cd92

Please sign in to comment.