Skip to content

Commit 0b94994

Browse files
authored
Merge pull request #52 from netfoundry/bump-requests
Bump requests
2 parents 25e1ada + 0d3916e commit 0b94994

File tree

7 files changed

+15
-7
lines changed

7 files changed

+15
-7
lines changed

netfoundry/ctl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,8 @@ def demo(cli):
934934
name=network_name,
935935
size=cli.config.demo.size,
936936
version=cli.config.demo.product_version,
937+
provider=cli.config.demo.provider,
938+
location=cli.config.demo.regions[0], # Use first region for network location
937939
)
938940
network, network_group = use_network(
939941
cli,

netfoundry/demo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def importlib_load_entry_point(spec, group, name):
2828

2929
globals().setdefault('load_entry_point', importlib_load_entry_point)
3030

31+
3132
def main():
3233
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
3334
_args = [sys.argv[0], 'demo'] + sys.argv[1:]
3435
sys.argv = _args
3536
sys.exit(load_entry_point('netfoundry', 'console_scripts', 'nfctl')())
3637

38+
3739
if __name__ == '__main__':
3840
main()

netfoundry/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66

77
from packaging.version import parse
8-
from requests.exceptions import JSONDecodeError
8+
from json import JSONDecodeError
99

1010
from netfoundry.exceptions import NetworkBoundaryViolation, UnknownResourceType
1111

netfoundry/network_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def create_network(self, name: str, network_group_id: str = None, location: str
173173
elif param == 'productVersion':
174174
if version:
175175
self.logger.debug("clobbering param 'version' with kwarg 'productVersion'")
176-
version == value
176+
version = value
177177
else:
178178
self.logger.warn(f"ignoring unexpected keyword argument '{param}'")
179179

netfoundry/organization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def __init__(self,
386386
if self.organizations_by_label.get(organization_label):
387387
self.describe = self.get_organization(id=self.organizations_by_label[organization_label])
388388
else:
389-
raise RuntimeError(f"failed to find org label {organization_label} in the list of orgs {', '.join(self.organizations_by_label.keys())}")
389+
raise RuntimeError(f"failed to find org label {organization_label} in the list of {len(self.organizations_by_label)} available organizations")
390390
else:
391391
self.describe = self.get_organization(id=self.caller['organizationId'])
392392

netfoundry/utility.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,12 @@ def find_generic_resources(setup: object, url: str, headers: dict = dict(), embe
485485
)
486486
response.raise_for_status()
487487
resource_page = response.json()
488+
489+
# Handle non-paginated endpoints that return direct lists
490+
if isinstance(resource_page, list):
491+
yield resource_page
492+
return
493+
488494
if isinstance(resource_page, dict) and resource_page.get('page'):
489495
try:
490496
total_pages = resource_page['page']['totalPages']
@@ -515,8 +521,6 @@ def find_generic_resources(setup: object, url: str, headers: dict = dict(), embe
515521
# then yield subsequent pages, if applicable
516522
if get_all_pages and total_pages > 1: # get_all_pages is False if param 'page' or 'size' to stop recursion and get a single page
517523
next_range_lower, next_range_upper = params['page'] + 1, total_pages
518-
if resource_type.name == 'network-groups':
519-
next_range_upper += 1 # network-groups pages are 1-based and so +1 upper limit
520524
for next_page in range(next_range_lower, next_range_upper):
521525
params['page'] = next_page
522526
try:
@@ -902,7 +906,7 @@ def decorated(ref):
902906
RETRY_STRATEGY = Retry(
903907
total=5,
904908
status_forcelist=[403, 404, 413, 429, 503], # The API responds 403 and 404 for not-yet-existing executions for some async operations
905-
method_whitelist=["HEAD", "GET", "PUT", "DELETE", "OPTIONS", "TRACE"],
909+
allowed_methods=["HEAD", "GET", "PUT", "DELETE", "OPTIONS", "TRACE"],
906910
backoff_factor=1
907911
)
908912
DEFAULT_TIMEOUT = 31 # seconds, Gateway Service waits 30s before responding with an error code e.g. 503 and

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ install_requires =
3030
pygments >= 2.11
3131
pyjwt >= 2.3
3232
pyyaml >= 5.4
33-
requests >= 2.27, < 2.30
33+
requests >= 2.30
3434
tabulate >= 0.8
3535
requests-cache >= 0.9.4
3636
setup_requires =

0 commit comments

Comments
 (0)