Skip to content

Commit 8d96925

Browse files
committed
Merge branch 'release-v5.9.4'
2 parents 1c04f42 + aa68458 commit 8d96925

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

netfoundry/ctl.py

+2-2
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

+1-2
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/network_group.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self, Organization: object, network_group_id: str = None, network_g
1414
"""Initialize the network group class with a group name or ID."""
1515
self.logger = Organization.logger
1616
self.Networks = Networks(Organization)
17-
self.network_groups = Organization.get_network_groups_by_organization()
17+
self.network_groups = Organization.find_network_groups_by_organization()
1818
if (not network_group_id and not network_group_name) and group:
1919
if is_uuidv4(group):
2020
network_group_id = group

netfoundry/utility.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def find_generic_resources(url: str, headers: dict, embedded: str = None, proxie
396396
if get_all_pages: # this is False if param 'page' or 'size' to stop recursion or get a single page
397397
if resource_type.name == 'network-groups':
398398
params['page'] = 1 # workaround API bug https://netfoundry.atlassian.net/browse/MOP-17890
399-
next_range_lower, next_range_upper = params['page'] + 2, total_pages + 1
399+
next_range_lower, next_range_upper = params['page'], total_pages + 1
400400
else:
401401
next_range_lower, next_range_upper = params['page'] + 1, total_pages
402402
for next_page in range(next_range_lower, next_range_upper): # first page is 0 unless network-groups which are 1-based
@@ -436,6 +436,7 @@ def camel(self, snake_str):
436436

437437

438438
NET_RESOURCES = dict() # resources in network domain
439+
ZITI_NET_RESOURCES = dict() # network resources that are backed 1:1 by a zitiId
439440
MUTABLE_NET_RESOURCES = dict() # network resources that can be updated
440441
MUTABLE_RESOURCE_ABBREV = dict() # unique abbreviations for ^
441442
EMBED_NET_RESOURCES = dict() # network resources that may be fetched as embedded collections
@@ -484,9 +485,8 @@ def __post_init__(self):
484485
class ResourceType(ResourceTypeParent):
485486
"""Typed resource type spec.
486487
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).
488+
This helps the CLI to suggest possible operations such as all resource
489+
types in the network domain that can be mutated (C_UD).
490490
"""
491491

492492
name: str # plural form as kebab-case e.g. edge-routers
@@ -509,6 +509,7 @@ class ResourceType(ResourceTypeParent):
509509
abbreviation: str = field(default='default')
510510
status_symbols: dict = field(default_factory=lambda: RESOURCE_STATUS_SYMBOLS) # dictionary with three predictable keys: complete, progress, error, each a tuple associating status symbols with a state
511511
host: bool = field(default=False) # may have a managed host in NF cloud
512+
ziti: bool = field(default=False)
512513

513514
def __post_init__(self):
514515
"""Compute and assign _embedded if not supplied and then check types in parent class."""
@@ -534,6 +535,8 @@ def __post_init__(self):
534535
if self.host:
535536
HOSTABLE_NET_RESOURCES[self.name] = self
536537
HOSTABLE_RESOURCE_ABBREV[self.abbreviation] = self
538+
if self.ziti:
539+
ZITI_NET_RESOURCES[self.name] = self
537540
return super().__post_init__()
538541

539542

@@ -650,7 +653,9 @@ def __post_init__(self):
650653
"attributes": [],
651654
"enrollmentMethod": {"ott": True},
652655
"name": "Name"
653-
}),
656+
},
657+
ziti=True,
658+
),
654659
'edge-routers': ResourceType(
655660
name='edge-routers',
656661
domain='network',
@@ -659,6 +664,7 @@ def __post_init__(self):
659664
no_update_props=['registration'],
660665
create_responses=["ACCEPTED"],
661666
host=True,
667+
ziti=True,
662668
),
663669
'edge-router-policies': ResourceType(
664670
name='edge-router-policies',
@@ -673,13 +679,15 @@ def __post_init__(self):
673679
mutable=True,
674680
embeddable=True,
675681
create_responses=["ACCEPTED"],
682+
ziti=True,
676683
),
677684
'service-policies': ResourceType(
678685
name='service-policies',
679686
domain='network',
680687
mutable=True,
681688
embeddable=True,
682689
create_responses=["ACCEPTED"],
690+
ziti=True,
683691
),
684692
'app-wans': ResourceType(
685693
name='app-wans',
@@ -695,41 +703,47 @@ def __post_init__(self):
695703
mutable=True,
696704
embeddable=True,
697705
create_responses=["ACCEPTED"],
706+
ziti=True,
698707
),
699708
'posture-checks': ResourceType(
700709
name='posture-checks',
701710
domain='network',
702711
mutable=True,
703712
embeddable=True,
704713
create_responses=["ACCEPTED"],
714+
ziti=True,
705715
),
706716
'certificate-authorities': ResourceType(
707717
name='certificate-authorities',
708718
domain='network',
709719
mutable=True,
710720
embeddable=True,
711721
create_responses=["ACCEPTED"],
722+
ziti=True,
712723
),
713724
'config-types': ResourceType(
714725
name='config-types',
715726
domain='network',
716727
mutable=True,
717728
embeddable=True,
718729
create_responses=["ACCEPTED"],
730+
ziti=True,
719731
),
720732
'configs': ResourceType(
721733
name='configs',
722734
domain='network',
723735
mutable=True,
724736
embeddable=True,
725737
create_responses=["ACCEPTED"],
738+
ziti=True,
726739
),
727740
'terminators': ResourceType(
728741
name='terminators',
729742
domain='network',
730743
mutable=True,
731744
embeddable=True,
732745
create_responses=["ACCEPTED"],
746+
ziti=True,
733747
),
734748
}
735749

0 commit comments

Comments
 (0)