|
406 | 406 | from ansible.module_utils.urls import open_url
|
407 | 407 | from ansible.module_utils.six.moves.urllib import error as urllib_error
|
408 | 408 | from ansible.module_utils.six.moves.urllib.parse import urlencode
|
| 409 | +from ansible.module_utils.six.moves.urllib.parse import urlparse |
| 410 | + |
409 | 411 | from ansible.module_utils.six import raise_from
|
410 | 412 |
|
411 | 413 | try:
|
@@ -1629,26 +1631,32 @@ def fetch_api_docs(self):
|
1629 | 1631 | self.api_version = version.parse(netbox_api_version)
|
1630 | 1632 |
|
1631 | 1633 | if self.api_version >= version.parse("3.5.0"):
|
| 1634 | + parsed_endpoint_url = urlparse(self.api_endpoint) |
| 1635 | + base_path = parsed_endpoint_url.path |
1632 | 1636 | self.allowed_device_query_parameters = [
|
1633 | 1637 | p["name"]
|
1634 |
| - for p in openapi["paths"]["/api/dcim/devices/"]["get"]["parameters"] |
| 1638 | + for p in openapi["paths"][base_path + "/api/dcim/devices/"]["get"][ |
| 1639 | + "parameters" |
| 1640 | + ] |
1635 | 1641 | ]
|
1636 | 1642 | self.allowed_vm_query_parameters = [
|
1637 | 1643 | p["name"]
|
1638 |
| - for p in openapi["paths"]["/api/virtualization/virtual-machines/"][ |
1639 |
| - "get" |
1640 |
| - ]["parameters"] |
| 1644 | + for p in openapi["paths"][ |
| 1645 | + base_path + "/api/virtualization/virtual-machines/" |
| 1646 | + ]["get"]["parameters"] |
1641 | 1647 | ]
|
1642 | 1648 | else:
|
1643 | 1649 | self.allowed_device_query_parameters = [
|
1644 | 1650 | p["name"]
|
1645 |
| - for p in openapi["paths"]["/dcim/devices/"]["get"]["parameters"] |
| 1651 | + for p in openapi["paths"][base_path + "/dcim/devices/"]["get"][ |
| 1652 | + "parameters" |
| 1653 | + ] |
1646 | 1654 | ]
|
1647 | 1655 | self.allowed_vm_query_parameters = [
|
1648 | 1656 | p["name"]
|
1649 |
| - for p in openapi["paths"]["/virtualization/virtual-machines/"]["get"][ |
1650 |
| - "parameters" |
1651 |
| - ] |
| 1657 | + for p in openapi["paths"][ |
| 1658 | + base_path + "/virtualization/virtual-machines/" |
| 1659 | + ]["get"]["parameters"] |
1652 | 1660 | ]
|
1653 | 1661 |
|
1654 | 1662 | def validate_query_parameter(self, parameter, allowed_query_parameters):
|
|
0 commit comments