Skip to content

Commit 9c378ac

Browse files
committed
merge params from keyword arg to avoid kwargs collisions
1 parent e8ac67c commit 9c378ac

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

netfoundry/ctl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def get(cli, echo: bool = True, spinner: object = None):
540540
cli.log.warn(f"using 'id' only, ignoring params: '{', '.join(query_keys)}'")
541541
match = network.get_resource_by_id(type=cli.args.resource_type, id=cli.args.query['id'], accept=cli.args.accept)
542542
else:
543-
matches = network.find_resources(type=cli.args.resource_type, accept=cli.args.accept, **cli.args.query)
543+
matches = network.find_resources(type=cli.args.resource_type, accept=cli.args.accept, params=cli.args.query)
544544
if len(matches) == 1:
545545
match = matches[0]
546546

@@ -669,7 +669,7 @@ def list(cli, spinner: object = None):
669669
if cli.args.resource_type == "data-centers":
670670
matches = network.find_edge_router_data_centers(**cli.args.query)
671671
else:
672-
matches = network.find_resources(type=cli.args.resource_type, accept=cli.args.accept, **cli.args.query)
672+
matches = network.find_resources(type=cli.args.resource_type, accept=cli.args.accept, params=cli.args.query)
673673

674674
if len(matches) == 0:
675675
spinner.fail(f"Found no {cli.args.resource_type} by '{', '.join(query_keys)}'")

netfoundry/network.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def get_resource_by_id(self, type: str, id: str, accept: str = None):
383383
return(resource)
384384
get_resource = get_resource_by_id
385385

386-
def find_resources(self, type: str, accept: str = None, deleted: bool = False, **kwargs):
386+
def find_resources(self, type: str, accept: str = None, deleted: bool = False, params: dict = dict(), **kwargs):
387387
"""Find resources by type.
388388
389389
:param str type: plural of an entity type in the network domain e.g. networks, endpoints, services, posture-checks, etc...
@@ -399,7 +399,6 @@ def find_resources(self, type: str, accept: str = None, deleted: bool = False, *
399399
if type == "data-centers":
400400
self.logger.warn("don't call network.get_resources() for data centers, always use network.get_edge_router_data_centers() to filter for locations that support this network's version")
401401

402-
params = dict()
403402
for param in kwargs.keys():
404403
params[param] = kwargs[param]
405404
if not plural(type) == 'networks':

netfoundry/utility.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,8 @@ def __post_init__(self):
484484
class ResourceType(ResourceTypeParent):
485485
"""Typed resource type spec.
486486
487-
As close as I could get to a Go struct. This helps us to suggest possible
488-
operations such as all resource types in the network domain that can be
489-
mutated (C_UD).
487+
This helps the CLI to suggest possible operations such as all resource
488+
types in the network domain that can be mutated (C_UD).
490489
"""
491490

492491
name: str # plural form as kebab-case e.g. edge-routers

0 commit comments

Comments
 (0)