Skip to content

Commit 2ba4916

Browse files
committed
Fixes ns1#92 ns1#93 & ns1#94
Fix loadScope so it accepts only the required scope id Fix rest.ipam.xyz classes so they accept the fields listed on the current API docs Fix rest.ipam.addresses.search so it works pr API docs Add expand method to rest.ipam.scopegroups Running tests in 3.9 fails helpers::test_singleton_mixin_with_concurrency but I doubt this is my doing..
1 parent c365c02 commit 2ba4916

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

ns1/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,13 @@ def createScope(
566566
return scope.create(callback=callback, errback=errback, **kwargs)
567567

568568
def loadScope(
569-
self, scopegroup_id, address_id, callback=None, errback=None
570-
):
569+
self,
570+
id,
571+
callback=None,
572+
errback=None):
571573
import ns1.ipam
572-
573-
scope = ns1.ipam.Scope(self.config, scopegroup_id, address_id)
574+
# pass dummy values for scope group and address id, as these are not used here anyways
575+
scope = ns1.ipam.Scope(self.config, None, None, id)
574576

575577
return scope.load(callback=callback, errback=errback)
576578

ns1/ipam.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ def load(self, callback=None, errback=None, reload=False):
907907

908908
def success(result, *args):
909909
self.data = result
910+
self.scopegroup_id = result["scope_group_id"]
910911
self.address_id = result["address_id"]
911912
self.options = result["options"]
912913

ns1/rest/ipam.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ class Addresses(resource.BaseResource):
1111
ROOT = "ipam/address"
1212
INT_FIELDS = [
1313
"network_id",
14-
"address_id",
15-
"root_address_id",
16-
" merged_address_id",
14+
"parent_id",
1715
"scope_group_id",
1816
]
19-
PASSTHRU_FIELDS = ["prefix", "status", "desc", "tags", "reserve"]
17+
PASSTHRU_FIELDS = ["name", "prefix", "status", "desc", "tags", "reserve", "hostname", "forward_zone_handle",
18+
"reverse_zone_handle", ]
2019
BOOL_FIELDS = ["parent"]
2120

2221
def _buildBody(self, **kwargs):
@@ -137,12 +136,15 @@ def retrieve_dhcp_option(self, address_id, callback=None, errback=None):
137136
# callback=callback,
138137
# errback=errback)
139138

140-
def search(self, network_id, prefix, callback=None, errback=None):
139+
def search(self, callback=None, errback=None, **kwargs):
140+
params = {k: v for k, v in kwargs if
141+
k in ['network_id', 'asc_desc', 'mask', 'max', 'name', 'order_by', 'prefix', 'tag', 'status']}
141142
return self._make_request(
142143
"GET",
143-
"%s/search/%s/%s" % (self.ROOT, network_id, prefix),
144+
"%s/search" % (self.ROOT),
144145
callback=callback,
145146
errback=errback,
147+
params=params,
146148
)
147149

148150

@@ -218,7 +220,7 @@ def report(self, network_id, callback=None, errback=None):
218220
class Scopegroups(resource.BaseResource):
219221
ROOT = "dhcp/scopegroup"
220222
INT_FIELDS = ["id", "dhcp_service_id", "valid_lifetime_secs"]
221-
PASSTHRU_FIELDS = ["dhcpv4", "dhcpv6", "name", "tags"]
223+
PASSTHRU_FIELDS = ["dhcpv4", "dhcpv6", "name", "tags", "template", "options", ]
222224
BOOL_FIELDS = ["enabled", "echo_client_id"]
223225

224226
def _buildBody(self, **kwargs):
@@ -269,6 +271,15 @@ def retrieve(self, scope_group_id, callback=None, errback=None):
269271
errback=errback,
270272
)
271273

274+
def expand(self, scope_group_id, callback=None, errback=None):
275+
return self._make_request(
276+
"GET",
277+
"%s/%s" % (self.ROOT, scope_group_id),
278+
callback=callback,
279+
errback=errback,
280+
params={'expand': True}
281+
)
282+
272283

273284
class Scopes(resource.BaseResource):
274285
ROOT = "dhcp/scope"

0 commit comments

Comments
 (0)