@@ -664,6 +664,68 @@ def get_discovered_device(self, discovered_device_id: str) -> DiscoveredInventor
664664 response .data ["status" ]["devman" ]["discoveredDevices" ]["_items" ][0 ]
665665 )
666666
667+ # --- Global Configuration Helpers ---
668+ def get_global_snmp_config_id_by_label (self , label : str ) -> Optional [str ]:
669+ """Method to get the global SNMP configuration id by label.
670+ Note: If multiple SNMP configurations with the same label exist, the first one is returned.
671+
672+ Args:
673+ label (str): Label of the SNMP configuration
674+
675+ Returns:
676+ Optional[str]: SNMP configuration id, None if not found
677+ """
678+ if not label :
679+ raise ValueError ("Label must not be empty." )
680+
681+ escaped_label = urllib .parse .quote (label , safe = "" )
682+ url = f"/rest/v2/data/config/system/snmp/*/* where descriptor.label='{ escaped_label } ' /*"
683+ response = self .vip_connector .rest .get (url )
684+ if response .data and response .data ["config" ]["system" ]["snmp" ]["session" ]:
685+ matches = response .data ["config" ]["system" ]["snmp" ]["session" ]
686+ if len (matches ) == 1 :
687+ return list (matches .keys ())[0 ]
688+ elif len (matches ) > 1 :
689+ self ._logger .warning (
690+ f"Multiple SNMP configurations found with label '{ label } '. Returning the first one."
691+ )
692+ return list (matches .keys ())[0 ]
693+ return None
694+
695+ def get_global_snmp_config_label_by_id (self , snmp_config_id : str ) -> Optional [str ]:
696+ """Method to get the global SNMP configuration label by id.
697+
698+ Args:
699+ snmp_config_id (str): SNMP configuration id
700+
701+ Returns:
702+ Optional[str]: SNMP configuration label, None if not found
703+ """
704+ if not snmp_config_id :
705+ raise ValueError ("SNMP configuration id must not be empty." )
706+
707+ url = f"/rest/v2/data/config/system/snmp/session/{ snmp_config_id } /descriptor/label"
708+ response = self .vip_connector .rest .get (url )
709+ if response .data and response .data ["config" ]["system" ]["snmp" ]["session" ][snmp_config_id ]:
710+ return response .data ["config" ]["system" ]["snmp" ]["session" ][snmp_config_id ]["descriptor" ]["label" ]
711+ return None
712+
713+ def get_all_global_snmp_config_ids (self ) -> dict [str , str ]:
714+ """Method to list all global SNMP configuration ids with their labels.
715+
716+ Returns:
717+ dict: {snmp_config_id: snmp_config_label}
718+ """
719+ url = "/rest/v2/data/config/system/snmp/*/*/descriptor/label"
720+ response = self .vip_connector .rest .get (url )
721+ if not response .data :
722+ raise ValueError ("Response data is empty." )
723+
724+ snmp_configs = response .data ["config" ]["system" ]["snmp" ]["session" ]
725+ return {
726+ snmp_config_id : snmp_config ["descriptor" ]["label" ] for snmp_config_id , snmp_config in snmp_configs .items ()
727+ }
728+
667729 # --- Deprecated Methods ---
668730 @deprecated (
669731 "The method `fetch_device_ids_list` is deprecated and will be removed in a future release. " ,
0 commit comments