Make 'isPool' filter optional, #3

This commit is contained in:
John Bowdre 2021-12-21 16:56:08 -06:00
parent 8861002c96
commit b1f5dd1aea
2 changed files with 18 additions and 1 deletions

View file

@ -55,6 +55,7 @@ def do_get_ip_ranges(self, auth_credentials, cert):
password = auth_credentials["privateKey"] password = auth_credentials["privateKey"]
hostname = self.inputs["endpoint"]["endpointProperties"]["hostName"] hostname = self.inputs["endpoint"]["endpointProperties"]["hostName"]
apiAppId = self.inputs["endpoint"]["endpointProperties"]["apiAppId"] apiAppId = self.inputs["endpoint"]["endpointProperties"]["apiAppId"]
filterPool = self.inputs["endpoint"]["endpointProperties"]["filterPool"]
uri = f'https://{hostname}/api/{apiAppId}/' uri = f'https://{hostname}/api/{apiAppId}/'
auth = (username, password) auth = (username, password)
@ -63,8 +64,12 @@ def do_get_ip_ranges(self, auth_credentials, cert):
# Request list of subnets # Request list of subnets
subnet_uri = f'{uri}/subnets/' subnet_uri = f'{uri}/subnets/'
if filterPool == "true":
queryFilter = 'filter_by=isPool&filter_value=1'
else:
queryFilter = ''
ipRanges = [] ipRanges = []
subnets = requests.get(f'{subnet_uri}?filter_by=isPool&filter_value=1', headers=token, verify=cert) subnets = requests.get(f'{subnet_uri}?{queryFilter}', headers=token, verify=cert)
subnets = subnets.json()['data'] subnets = subnets.json()['data']
for subnet in subnets: for subnet in subnets:
ipRange = {} ipRange = {}

View file

@ -23,6 +23,10 @@
{ {
"id":"hostName", "id":"hostName",
"display":"textField" "display":"textField"
},
{
"id":"filterPool",
"display": "checkbox"
} }
] ]
} }
@ -66,6 +70,14 @@
"constraints":{ "constraints":{
"required":true "required":true
} }
},
"filterPool":{
"type":{
"dataType":"boolean"
},
"label":"Only find ranges marked as Pools",
"signpost":"If enabled, vRA will only retrieve subnets marked as pools in phpIPAM",
"default":true
} }
}, },
"options":{ "options":{