@@ -781,14 +781,14 @@ def __init__(self, module, endpoint, nb_client=None):
781781 else :
782782 self .nb = nb_client
783783 try :
784- self .version = self ._version_sanitize (self .nb .version )
784+ self .api_version = self ._version_sanitize (self .nb .version )
785785 try :
786- self .full_version = self ._version_sanitize (
786+ self .netbox_version = self ._version_sanitize (
787787 self .nb .status ().get ("netbox-version" )
788788 )
789789 except Exception :
790790 # For NetBox versions without /api/status endpoint
791- self .full_version = f"{ self .version } .0"
791+ self .netbox_version = f"{ self .api_version } .0"
792792 except AttributeError :
793793 self .module .fail_json (msg = "Must have pynetbox >=4.1.0" )
794794
@@ -850,14 +850,14 @@ def _connect_netbox_api(self, url, token, ssl_verify, cert, headers=None):
850850 nb = pynetbox .api (url , token = token )
851851 nb .http_session = session
852852 try :
853- self .version = self ._version_sanitize (nb .version )
853+ self .api_version = self ._version_sanitize (nb .version )
854854 try :
855- self .full_version = self ._version_sanitize (
855+ self .netbox_version = self ._version_sanitize (
856856 nb .status ().get ("netbox-version" )
857857 )
858858 except Exception :
859859 # For NetBox versions without /api/status endpoint
860- self .full_version = f"{ self .version } .0"
860+ self .netbox_version = f"{ self .api_version } .0"
861861 except AttributeError :
862862 self .module .fail_json (msg = "Must have pynetbox >=4.1.0" )
863863 except Exception :
@@ -941,7 +941,7 @@ def _convert_identical_keys(self, data):
941941 :params data (dict): Data dictionary after _find_ids method ran
942942 """
943943 temp_dict = dict ()
944- if self ._version_check_greater (self .version , "2.7" , greater_or_equal = True ):
944+ if self ._version_check_greater (self .api_version , "2.7" , greater_or_equal = True ):
945945 if data .get ("form_factor" ):
946946 temp_dict ["type" ] = data .pop ("form_factor" )
947947
@@ -950,7 +950,7 @@ def _convert_identical_keys(self, data):
950950 temp_dict [key ] = data [key ]
951951 # TODO: Remove this once the lowest supported Netbox version is 3.6 or greater as we can use default logic of CONVERT_KEYS moving forward.
952952 elif key == "device_role" and not self ._version_check_greater (
953- self .version , "3.6" , greater_or_equal = True
953+ self .api_version , "3.6" , greater_or_equal = True
954954 ):
955955 temp_dict [key ] = data [key ]
956956 elif key in CONVERT_KEYS :
@@ -1043,7 +1043,7 @@ def _build_query_params(
10431043 parent == "interface"
10441044 and "device" in module_data
10451045 and self ._version_check_greater (
1046- self .version , "3.6" , greater_or_equal = True
1046+ self .api_version , "3.6" , greater_or_equal = True
10471047 )
10481048 ):
10491049 query_dict .update (
@@ -1130,7 +1130,7 @@ def _build_query_params(
11301130 elif parent == "rear_port_template" and self .endpoint == "front_port_templates" :
11311131 if isinstance (module_data .get ("rear_port_template" ), str ):
11321132 if self ._version_check_greater (
1133- self .version , "4.0" , greater_or_equal = True
1133+ self .api_version , "4.0" , greater_or_equal = True
11341134 ):
11351135 rear_port_template = {
11361136 "device_type_id" : module_data .get ("device_type" ),
@@ -1157,7 +1157,7 @@ def _build_query_params(
11571157 ):
11581158 if isinstance (module_data .get ("power_port_template" ), str ):
11591159 if self ._version_check_greater (
1160- self .version , "4.0" , greater_or_equal = True
1160+ self .api_version , "4.0" , greater_or_equal = True
11611161 ):
11621162 power_port_template = {
11631163 "device_type_id" : module_data .get ("device_type" ),
@@ -1192,7 +1192,7 @@ def _build_query_params(
11921192 elif "_template" in parent :
11931193 if query_dict .get ("device_type" ):
11941194 if self ._version_check_greater (
1195- self .version , "4.0" , greater_or_equal = True
1195+ self .api_version , "4.0" , greater_or_equal = True
11961196 ):
11971197 query_dict ["device_type_id" ] = query_dict .pop ("device_type" )
11981198 else :
@@ -1202,8 +1202,8 @@ def _build_query_params(
12021202 # Netbox 4.3.0 - 4.4.3 is removed
12031203 elif parent == "services" :
12041204 if self ._version_check_greater (
1205- self .version , "4.3" , greater_or_equal = True
1206- ) and self ._version_check_greater ("4.4.4" , self .full_version ):
1205+ self .api_version , "4.3" , greater_or_equal = True
1206+ ) and self ._version_check_greater ("4.4.4" , self .netbox_version ):
12071207 query_dict .pop ("parent_object_id" , None )
12081208 query_dict .pop ("parent_object_type" , None )
12091209
@@ -1277,13 +1277,15 @@ def _find_app(self, endpoint):
12771277 if endpoint in v .keys ():
12781278 if "introduced" in v [endpoint ]:
12791279 pre_introduction = self ._version_check_greater (
1280- v [endpoint ]["introduced" ], self .version
1280+ v [endpoint ]["introduced" ], self .api_version
12811281 )
12821282 if pre_introduction :
12831283 continue
12841284 if "deprecated" in v [endpoint ]:
12851285 after_deprecation = self ._version_check_greater (
1286- self .version , v [endpoint ]["deprecated" ], greater_or_equal = True
1286+ self .api_version ,
1287+ v [endpoint ]["deprecated" ],
1288+ greater_or_equal = True ,
12871289 )
12881290 if after_deprecation :
12891291 continue
@@ -1303,7 +1305,7 @@ def _find_ids(self, data, user_query_params):
13031305 if k in CONVERT_TO_ID :
13041306 if (
13051307 not self ._version_check_greater (
1306- self .version , "2.9" , greater_or_equal = True
1308+ self .api_version , "2.9" , greater_or_equal = True
13071309 )
13081310 and k == "tags"
13091311 ) or (self .endpoint == "config_contexts" and k == "tags" ):
@@ -1527,7 +1529,7 @@ def _update_netbox_object(self, data):
15271529 updated_obj ["tags" ] = set (data ["tags" ])
15281530
15291531 # Ensure idempotency for site on older netbox versions
1530- version_pre_30 = self ._version_check_greater ("3.0" , self .version )
1532+ version_pre_30 = self ._version_check_greater ("3.0" , self .api_version )
15311533 if (
15321534 serialized_nb_obj .get ("latitude" )
15331535 and data .get ("latitude" )
@@ -1542,15 +1544,15 @@ def _update_netbox_object(self, data):
15421544 updated_obj ["longitude" ] = str (data ["longitude" ])
15431545
15441546 # Ensure idempotency for virtual machine on older netbox versions
1545- version_pre_211 = self ._version_check_greater ("2.11" , self .version )
1547+ version_pre_211 = self ._version_check_greater ("2.11" , self .api_version )
15461548 if serialized_nb_obj .get ("vcpus" ) and data .get ("vcpus" ):
15471549 if version_pre_211 :
15481550 updated_obj ["vcpus" ] = int (data ["vcpus" ])
15491551 else :
15501552 updated_obj ["vcpus" ] = float (data ["vcpus" ])
15511553
15521554 # Ensure idempotency for cable on netbox versions later than 3.3
1553- version_post_33 = self ._version_check_greater (self .version , "3.3" , True )
1555+ version_post_33 = self ._version_check_greater (self .api_version , "3.3" , True )
15541556 if (
15551557 serialized_nb_obj .get ("a_terminations" )
15561558 and serialized_nb_obj .get ("b_terminations" )
0 commit comments