netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
577 stars 172 forks source link

Custom Choices tries wrong URL. #487

Open jkugler opened 2 years ago

jkugler commented 2 years ago

I am using version 6.6.2 of pynetbox against version 3.2.7 of NetBox. I'm getting errors trying these api calls:

api = pynetbox.api(self.url)
api.create_token(self.user, self.password)
list(api.dcim.custom_choices())
pynetbox.core.query.RequestError: The requested url: http://192.168.108.56/api/dcim/_custom_field_choices/ could not be found.

likewise:

list(api.extras.custom_choices())
pynetbox.core.query.RequestError: The requested url: http://192.168.108.56/api/extras/_custom_field_choices/ could not be found.

BUT! This url works on my server: http://192.168.108.56/api/extras/custom-fields/ So, as a work-around, I can hit that URL with my token and Requests, but I'd like to be able to get that information from within pynetbox.

jkugler commented 2 years ago

I found the note in the method's doc strings about api.extras.custom_fields, but this command: api.extras.custom_fields.choices() doesn't return /api/extras/custom-fields/. It does not return any of my custom fields, and it does not return the field types.

jkugler commented 2 years ago

api.extras.custom_fields.all() just returns the field names of the custom fields, and nothing about them. I still haven't found a way to get the information contained in /api/extras/custom-fields/

jkugler commented 2 years ago

Finally figured out api.extras.custom_fields.all() is return object for each field. Didn't initially click when I saw:

>>> list(api.extras.custom_fields.all())
[irm_set_BIOS_biosbootsettings_biosbootmode, irm_set_BIOS_procsettings_x2apic_onoff, irm_set_BIOS_slotbibur_dellauto_discovery_onoff, irm_set_BIOS_sysprofile_settings_cstates_onoff, irm_set_BIOS_sysprofile_settings_custom_onoff, irm_set_BIOS_sysprofile_settings_proc1e_onoff, irm_set_BIOS_sysprofile_settings_procpwrperf_onoff, irm_set_BIOS_sysprofile_settings_uncorefreq, irm_set_BIOS_syssecurity_tpm2_hierarchy_onoff, irm_set_BIOS_syssecurity_tpm_onoff, irm_set_BIOS_Version, irm_set_iDRAC_IPV6_address, irm_set_IDRAC_IPV6_gateway, irm_set_IDRAC_IPV6_prefix_64, irm_set_iDRAC_name, irm_set_iDRAC_version, irm_set_power_supply_hs_spare_onoff, irm_set_power_supply_redundant_pol_onoff]

Leaving open for now as a "doc bug" since this is not doc'ed at https://pynetbox.readthedocs.io/en/latest/ which has a copyright of 2017.