diff --git a/src/main/python/get_ip_ranges/source.py b/src/main/python/get_ip_ranges/source.py index ddcb684..993ba0b 100644 --- a/src/main/python/get_ip_ranges/source.py +++ b/src/main/python/get_ip_ranges/source.py @@ -55,6 +55,7 @@ def do_get_ip_ranges(self, auth_credentials, cert): password = auth_credentials["privateKey"] hostname = self.inputs["endpoint"]["endpointProperties"]["hostName"] apiAppId = self.inputs["endpoint"]["endpointProperties"]["apiAppId"] + filterPool = self.inputs["endpoint"]["endpointProperties"]["filterPool"] uri = f'https://{hostname}/api/{apiAppId}/' auth = (username, password) @@ -63,8 +64,12 @@ def do_get_ip_ranges(self, auth_credentials, cert): # Request list of subnets subnet_uri = f'{uri}/subnets/' + if filterPool == "true": + queryFilter = 'filter_by=isPool&filter_value=1' + else: + queryFilter = '' 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'] for subnet in subnets: ipRange = {} diff --git a/src/main/resources/endpoint-schema.json b/src/main/resources/endpoint-schema.json index b76c6ba..8ca5a2d 100644 --- a/src/main/resources/endpoint-schema.json +++ b/src/main/resources/endpoint-schema.json @@ -23,6 +23,10 @@ { "id":"hostName", "display":"textField" + }, + { + "id":"filterPool", + "display": "checkbox" } ] } @@ -66,6 +70,14 @@ "constraints":{ "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":{