Scopes¶
The Scopes module handles hierachical structures such as scopes, sites, collections, and groups.
Device¶
device
¶
Device(device_attributes=None, central_conn=None, serial=None, from_api=False)
¶
Bases: ScopeBase
This class holds device and all of its attributes & related methods.
Constructor for Device object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_attributes
|
dict
|
Attributes of the Device |
None
|
central_conn
|
NewCentralBase
|
Instance of NewCentralBase to establish connection to Central |
None
|
serial
|
str
|
Serial number of the device (required if device_attributes is not provided) |
None
|
from_api
|
bool
|
Boolean indicates if the device_attributes is from the Central API response |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither serial nor device_attributes is provided |
Source code in pycentral/scopes/device.py
get_serial()
¶
Returns the serial number of the device.
Returns:
| Type | Description |
|---|---|
str
|
Value of self.serial |
get()
¶
Fetches the device details from the Central API using the serial number.
Returns:
| Type | Description |
|---|---|
dict
|
Device attributes as a dictionary |
Raises:
| Type | Description |
|---|---|
Exception
|
If central_conn is not set |
Source code in pycentral/scopes/device.py
get_all_devices(central_conn, new_central_provisioned=False)
staticmethod
¶
Fetches all devices from Central, optionally filtering for new Central configured devices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_conn
|
NewCentralBase
|
Instance of NewCentralBase to establish connection to Central |
required |
new_central_provisioned
|
bool
|
If True, only devices that are provisioned via New Central are returned |
False
|
Returns:
| Type | Description |
|---|---|
list
|
List of device dictionaries fetched from Central |
Source code in pycentral/scopes/device.py
__rename_keys(api_dict, api_attribute_mapping)
¶
Renames the keys of the attributes from the API response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_dict
|
dict
|
Dict from Central API Response |
required |
api_attribute_mapping
|
dict
|
Dict mapping API keys to object attributes |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Renamed dictionary of object attributes |
Source code in pycentral/scopes/device.py
ping_test(destination, **kwargs)
¶
Initiates a ping test to the specified destination from the device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination
|
str
|
The IP address or hostname to ping |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments specific to device type. See below for details:
|
{}
|
Returns: (dict): Result of the ping test
Raises:
| Type | Description |
|---|---|
ValueError
|
If device type is unsupported |
Source code in pycentral/scopes/device.py
traceroute_test(destination, **kwargs)
¶
Initiates a traceroute test to the specified destination from the device.
Supported device types: All (aps, cx, aos-s, gateways)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination
|
str
|
The IP address or hostname to traceroute |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments specific to device type. See below for details:
|
{}
|
Returns: (dict): Result of the traceroute test
Raises:
| Type | Description |
|---|---|
ValueError
|
If device type is unsupported |
Source code in pycentral/scopes/device.py
reboot()
¶
Reboots the device.
Supported device types: All (aps, cx, aos-s, gateways)
Returns:
| Type | Description |
|---|---|
dict
|
Result of the reboot operation |
Source code in pycentral/scopes/device.py
locate_test()
¶
Initiates a locate test (LED blinking) on the device.
Supported device types: cx, aps, aos-s (gateways not supported)
Returns:
| Type | Description |
|---|---|
dict
|
Result of the locate test |
Source code in pycentral/scopes/device.py
disconnect_all_clients()
¶
Disconnects all clients from the specified device.
Supported device types: gateways (other devices not supported)
Returns:
| Type | Description |
|---|---|
dict
|
Result of the disconnect all clients operation |
Source code in pycentral/scopes/device.py
disconnect_all_users()
¶
Disconnects all users from the specified device.
Supported device types: aps (other devices not supported)
Returns:
| Type | Description |
|---|---|
dict
|
Result of the disconnect all users operation |
Source code in pycentral/scopes/device.py
disconnect_client_mac_addr(mac_address)
¶
Disconnects client with the specified MAC address on the device.
Supported device types: gateways (other devices not supported)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mac_address
|
str
|
The MAC address from which to disconnect client |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Result of the disconnect client operation |
Source code in pycentral/scopes/device.py
disconnect_user_mac_addr(mac_address)
¶
Disconnects user with the specified MAC address on the device.
Supported device types: aps (other devices not supported)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mac_address
|
str
|
The MAC address from which to disconnect user |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Result of the disconnect user operation |
Source code in pycentral/scopes/device.py
disconnect_all_users_ssid(network)
¶
Disconnects all users from the specified SSID on the device.
Supported device types: aps (other devices not supported)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
str
|
The SSID from which to disconnect users |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Result of the disconnect all users operation |
Source code in pycentral/scopes/device.py
http_test(destination, **kwargs)
¶
Initiates an HTTP test to the specified destination from the device.
Supported device types: cx, aps, gateways
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination
|
str
|
The IP address or hostname to test |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments specific to device type, see Troubleshooting.http_test() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the HTTP test |
Source code in pycentral/scopes/device.py
https_test(destination, **kwargs)
¶
Initiates an HTTPS test to the specified destination from the device.
Supported device types: aps, gateways, cx (uses HTTP endpoint with HTTPS protocol)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination
|
str
|
The IP address or hostname to test |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments specific to device type. See below for details:
|
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the HTTPS test |
Raises:
| Type | Description |
|---|---|
ValueError
|
If device type is unsupported |
Source code in pycentral/scopes/device.py
port_bounce_test(ports, **kwargs)
¶
Initiates a port bounce test on the specified ports.
Supported device types: cx, aos-s, gateways
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ports
|
list
|
List of ports to test |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments for the port bounce test. See Troubleshooting.port_bounce_test() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the port bounce test |
Source code in pycentral/scopes/device.py
poe_bounce_test(ports, **kwargs)
¶
Initiates a PoE bounce test on the specified ports.
Supported device types: cx, aos-s, gateways
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ports
|
list
|
List of ports to test |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments for the PoE bounce test. See Troubleshooting.poe_bounce_test() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the PoE bounce test |
Source code in pycentral/scopes/device.py
arp_test()
¶
Initiates an ARP table retrieval test on the device.
Supported device types: aos-s, aps, gateways
Returns:
| Type | Description |
|---|---|
dict
|
Result of the ARP test |
Source code in pycentral/scopes/device.py
nslookup_test(host, **kwargs)
¶
Initiates an NSLOOKUP test on the device.
Supported device types: aps
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
The hostname or IP address to resolve |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments for the NSLOOKUP test. See Troubleshooting.nslookup_test() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the NSLOOKUP test |
Source code in pycentral/scopes/device.py
speedtest_test(iperf_server_address, **kwargs)
¶
Initiates a speed test using the specified iPerf server address.
Supported device types: aps only
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iperf_server_address
|
str
|
The IP address or hostname of the iPerf server |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments for the speed test. See Troubleshooting.speedtest_test() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the speed test |
Source code in pycentral/scopes/device.py
tcp_test(host, port, **kwargs)
¶
Initiates a TCP test to the specified host and port from the device.
Supported device types: aps only
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
The IP address or hostname to test |
required |
port
|
int
|
The port number to test |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments for the TCP test. See Troubleshooting.tcp_test() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the TCP test |
Source code in pycentral/scopes/device.py
aaa_test(radius_server_ip, username, password, **kwargs)
¶
Initiates an AAA test with the specified parameters.
CX devices require auth_method_type as a parameter. Supported device types: aps and cx only
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius_server_ip
|
str
|
RADIUS server IP address, hostname is valid for APs only |
required |
username
|
str
|
Username for authentication |
required |
password
|
str
|
Password for authentication |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments specific to device type. See below for details:
|
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the AAA test |
Raises:
| Type | Description |
|---|---|
ValueError
|
If device type is unsupported |
Source code in pycentral/scopes/device.py
cable_test(ports, **kwargs)
¶
Initiates a Cable test on the specified ports.
Supported device types: cx, aos-s
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ports
|
list
|
List of ports to test |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments for the cable test. See Troubleshooting.cable_test() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the Cable test |
Source code in pycentral/scopes/device.py
iperf_test(server_address, **kwargs)
¶
Initiates an iPerf test using the specified server address.
Supported device types: gateways only
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_address
|
str
|
The IP address or hostname of the iPerf server |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments for the iPerf test. See Troubleshooting.iperf_test() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Result of the iPerf test |
Source code in pycentral/scopes/device.py
list_show_commands()
¶
Returns most used/top 'show' commands supported on this device.
Supported device types: aps, gateways, cx, aos-s
Returns:
| Type | Description |
|---|---|
list or dict
|
List of show commands organized by category if successful, otherwise full response dict |
Source code in pycentral/scopes/device.py
run_show_commands(commands, **kwargs)
¶
Runs 'show' command(s) on the device and polls for test result.
All commands must start with 'show '.
Supported device types: aps, gateways, cx, aos-s
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commands
|
str or list
|
Single show command as string (e.g., "show version") or list of show commands (e.g., ["show version", "show ip route"]). Max 20 commands. All commands must start with 'show '. |
required |
**kwargs
|
(dict, Optional)
|
Optional arguments for the show command test. See Troubleshooting.run_show_command() for detailed parameter information. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Response from the test results API |
Source code in pycentral/scopes/device.py
list_active_tasks()
¶
Retrieves a list of all active or recently completed asynchronous operations for this device, grouped by test name.
Results are sorted by startTime in descending order (most recently started first).
Supported device types: aps, gateways, cx, aos-s
Returns:
| Type | Description |
|---|---|
dict
|
Response containing list of active tasks grouped by test name |
Source code in pycentral/scopes/device.py
list_events(**kwargs)
¶
Retrieves a list of Network Events for this device based on the query parameters provided.
Supported device types: All (aps, cx, aos-s, gateways)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
(dict, Optional)
|
Arguments for event listing. See Troubleshooting.list_events() for all parameters. Required parameters: site_id and either duration or both start_at and end_at |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Response containing events list, count, total, and pagination cursor |
Source code in pycentral/scopes/device.py
list_event_filters(**kwargs)
¶
Retrieves available event filter options for this device.
Supported device types: All (aps, cx, aos-s, gateways)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
(dict, Optional)
|
Arguments for event filter listing. See Troubleshooting.list_event_filters() for all parameters. Required parameters: site_id and either duration or both start_at and end_at |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
Response containing available event filter options |
Source code in pycentral/scopes/device.py
Device Group¶
device_group
¶
Device_Group(device_group_attributes=None, central_conn=None, from_api=False)
¶
Bases: ScopeBase
This class holds device groups and all of its attributes & related methods.
Constructor for Device Group object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_group_attributes
|
dict
|
Attributes of the Device Group |
None
|
central_conn
|
NewCentralBase
|
Instance of NewCentralBase to establish connection to Central |
None
|
from_api
|
bool
|
Boolean indicates if the device_group_attributes is from the Central API response |
False
|
Raises:
| Type | Description |
|---|---|
Exception
|
If from_api is False (currently not supported) |
Source code in pycentral/scopes/device_group.py
__rename_keys(api_dict, api_attribute_mapping)
¶
Renames the keys of the attributes from the API response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_dict
|
dict
|
Dict from Central API Response |
required |
api_attribute_mapping
|
dict
|
Dict mapping API keys to object attributes |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Renamed dictionary of object attributes |
Source code in pycentral/scopes/device_group.py
Scope Base¶
scope_base
¶
ScopeBase
¶
Base class for all scope elements, such as Site, Site_Collection, and Device.
Provides common functionality like
- Returning the object's ID or name.
- Assigning and unassigning profiles.
get_id()
¶
get_name()
¶
Fetches the name of the scope element.
Returns:
| Type | Description |
|---|---|
str
|
Name of the scope element |
get_type()
¶
Fetches the type of the scope element.
Returns:
| Type | Description |
|---|---|
str
|
Type of the scope element (e.g., 'site', 'site_collection', 'device') |
assign_profile(profile_name, profile_persona=None)
¶
Assigns a profile with the provided name and persona to the scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_name
|
str
|
Name of the profile to assign |
required |
profile_persona
|
str
|
Device Persona of the profile to assign. Optional if assigning a profile to a device |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the profile assignment was successful, False otherwise |
Source code in pycentral/scopes/scope_base.py
unassign_profile(profile_name, profile_persona=None)
¶
Unassigns a profile with the provided name and persona from the scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_name
|
str
|
Name of the profile to unassign |
required |
profile_persona
|
str
|
Persona of the profile to unassign. Optional if unassigning a profile from a device |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the profile unassignment was successful, False otherwise |
Source code in pycentral/scopes/scope_base.py
add_profile(name, persona)
¶
Helper function that adds a profile to the assigned profiles of the scope in the SDK.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the profile to add |
required |
persona
|
str
|
Device Persona of the profile to add |
required |
Source code in pycentral/scopes/scope_base.py
remove_profile(name, persona)
¶
Helper function that removes a profile from the assigned profiles of the scope in the SDK.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the profile to remove |
required |
persona
|
str
|
Device Persona of the profile to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the profile was successfully removed, False otherwise |
Source code in pycentral/scopes/scope_base.py
Scope Maps¶
scope_maps
¶
ScopeMaps()
¶
get(central_conn)
¶
Perform a GET call to retrieve data for the Global Scope Map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_conn
|
NewCentralBase
|
Established Central connection object |
required |
Returns:
| Type | Description |
|---|---|
list
|
List of scope map dictionaries if success, empty list otherwise |
Source code in pycentral/scopes/scope_maps.py
get_scope_assigned_profiles(central_conn, scope_id)
¶
Performs a GET call to retrieve Global Scope Map then finds matching scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_conn
|
NewCentralBase
|
Established Central connection object |
required |
scope_id
|
int
|
ID of the scope to be matched on |
required |
Returns:
| Type | Description |
|---|---|
list
|
List of assigned profile dictionaries for the scope |
Source code in pycentral/scopes/scope_maps.py
associate_profile_to_scope(central_conn, scope_id, profile_name, persona)
¶
Performs a POST call to associate a profile with device persona to the provided scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_conn
|
NewCentralBase
|
Established Central connection object |
required |
scope_id
|
int or str
|
ID of the scope to associate the profile |
required |
profile_name
|
str
|
Name of the profile to be assigned |
required |
persona
|
str or list
|
Device persona(s) to be associated with the profile. Valid values: SERVICE_PERSONA, HYBRID_NAC, CORE_SWITCH, BRIDGE, CAMPUS_AP, IOT, MOBILITY_GW, AGG_SWITCH, BRANCH_GW, VPNC, ACCESS_SWITCH, MICROBRANCH_AP, or "ALL" |
required |
Returns:
| Type | Description |
|---|---|
dict
|
JSON Data of returned response from POST call |
Source code in pycentral/scopes/scope_maps.py
unassociate_profile_from_scope(central_conn, scope_id, profile_name, persona)
¶
Performs a DELETE call to unassign a profile with device persona from the provided scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_conn
|
NewCentralBase
|
Established Central connection object |
required |
scope_id
|
int or str
|
ID of the scope to unassociate the profile from |
required |
profile_name
|
str
|
Name of the profile to be unassigned |
required |
persona
|
str or list
|
Device persona(s) to be unassociated from the profile. Valid values: SERVICE_PERSONA, HYBRID_NAC, CORE_SWITCH, BRIDGE, CAMPUS_AP, IOT, MOBILITY_GW, AGG_SWITCH, BRANCH_GW, VPNC, ACCESS_SWITCH, MICROBRANCH_AP, or "ALL" |
required |
Returns:
| Type | Description |
|---|---|
dict
|
JSON Data of returned response from DELETE call |
Source code in pycentral/scopes/scope_maps.py
Scopes¶
scopes
¶
Scopes(central_conn)
¶
Bases: ScopeBase
This class holds the Scopes (Global hierarchy) class & methods for managing sites & site collections.
Constructor for Scopes object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
central_conn
|
NewCentralBase
|
Instance of NewCentralBase to establish connection to Central. |
required |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If central_conn is None |
Source code in pycentral/scopes/scopes.py
get()
¶
Performs GET calls to Central to retrieve latest data of all scope elements.
Fetches Global, Site Collections, Sites, Devices, & Device Groups from Central.
Returns:
| Type | Description |
|---|---|
bool
|
True if all scope elements are successfully fetched, False otherwise |
Source code in pycentral/scopes/scopes.py
get_all_sites()
¶
Performs GET calls to retrieve all the sites from Central.
Returns:
| Type | Description |
|---|---|
list
|
List of Site objects |
Raises:
| Type | Description |
|---|---|
Exception
|
If sites cannot be fetched from Central |
Source code in pycentral/scopes/scopes.py
get_all_site_collections()
¶
Performs GET calls to retrieve all the site collections from Central.
Returns:
| Type | Description |
|---|---|
list
|
List of Site_Collection objects |
Source code in pycentral/scopes/scopes.py
get_all_devices()
¶
Performs GET calls to retrieve all the devices from Central.
Returns:
| Type | Description |
|---|---|
list
|
List of Device objects |
Source code in pycentral/scopes/scopes.py
get_all_device_groups()
¶
Performs GET calls to retrieve all the device groups from Central.
Returns:
| Type | Description |
|---|---|
list
|
List of device group dictionaries |
Source code in pycentral/scopes/scopes.py
get_id()
¶
Returns the ID of the Global scope.
If the ID hasn't been set, the function will fetch the ID from Central.
Returns:
| Type | Description |
|---|---|
int or None
|
ID of global scope, or None if unable to fetch |
Source code in pycentral/scopes/scopes.py
get_sites(limit=DEFAULT_LIMIT, offset=0, filter_field='', sort='')
¶
Fetches the list of sites from Central based on the provided attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
Number of sites to be fetched, defaults to 100 |
DEFAULT_LIMIT
|
offset
|
int
|
Pagination start index, defaults to 0 |
0
|
filter_field
|
str
|
Field for sorting. Accepted values: scopeName, address, city, state, country, zipcode, collectionName |
''
|
sort
|
str
|
Direction of sorting. Accepted values: scopeName, address, state, country, city, deviceCount, collectionName, zipcode, timezone, longitude, latitude |
''
|
Returns:
| Type | Description |
|---|---|
list or None
|
List of sites based on the provided arguments, None if errors occur |
Source code in pycentral/scopes/scopes.py
get_site_collections(limit=DEFAULT_LIMIT, offset=0, filter_field='', sort='')
¶
Fetches the list of site collections from Central based on the provided attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int
|
Number of site collections to be fetched, defaults to 100 |
DEFAULT_LIMIT
|
offset
|
int
|
Pagination start index, defaults to 0 |
0
|
filter_field
|
str
|
Field for sorting. Accepted values: scopeName, description |
''
|
sort
|
str
|
Direction of sorting. Accepted values: scopeName, description, deviceCount, siteCount |
''
|
Returns:
| Type | Description |
|---|---|
list or None
|
List of site collections based on the provided arguments, None if errors occur |
Source code in pycentral/scopes/scopes.py
find_site_collection(site_collection_ids=None, site_collection_names=None)
¶
Returns the site collection based on the provided parameters.
Only one of site_collection_ids or site_collection_names is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_collection_ids
|
int or list
|
ID(s) of site collections to find |
None
|
site_collection_names
|
str or list
|
Name(s) of site collections to find |
None
|
Returns:
| Type | Description |
|---|---|
Site_Collection or list or None
|
Found site collection(s) or None if not found |
Source code in pycentral/scopes/scopes.py
find_site(site_ids=None, site_names=None)
¶
Returns the site based on the provided parameters.
Only one of site_ids or site_names is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_ids
|
int or list
|
ID(s) of site to find |
None
|
site_names
|
str or list
|
Name(s) of site to find |
None
|
Returns:
| Type | Description |
|---|---|
Site or list or None
|
Found site(s) or None if not found |
Source code in pycentral/scopes/scopes.py
find_device(device_ids=None, device_names=None, device_serials=None)
¶
Returns the device based on the provided parameters.
Only one of device_ids, device_names, or device_serials is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_ids
|
int or list
|
ID(s) of devices to find |
None
|
device_names
|
str or list
|
Name(s) of devices to find |
None
|
device_serials
|
str or list
|
Serial number(s) of devices to find |
None
|
Returns:
| Type | Description |
|---|---|
Device or list or None
|
Found device(s) or None if not found |
Source code in pycentral/scopes/scopes.py
find_device_group(device_group_ids=None, device_group_names=None)
¶
Returns the device group based on the provided parameters.
Only one of device_group_ids or device_group_names is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_group_ids
|
int or list
|
ID(s) of device groups to find |
None
|
device_group_names
|
str or list
|
Name(s) of device groups to find |
None
|
Returns:
| Type | Description |
|---|---|
Device_Group or list or None
|
Found device group(s) or None if not found |
Source code in pycentral/scopes/scopes.py
add_sites_to_site_collection(site_collection_id=None, site_collection_name=None, site_ids=None, site_names=None)
¶
Adds site(s) to a site collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_collection_id
|
int
|
ID of the site collection. Either site_collection_name or site_collection_id is required. |
None
|
site_collection_name
|
str
|
Name of the site collection. Either site_collection_name or site_collection_id is required. |
None
|
site_ids
|
int or list
|
ID(s) of the site(s) to associate. Either site_ids or site_names is required. |
None
|
site_names
|
str or list
|
Name(s) of the site(s) to associate. Either site_ids or site_names is required. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
remove_sites_from_site_collection(site_ids=None, site_names=None)
¶
Removes site(s) from a site collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_ids
|
int or list
|
ID(s) of the site(s) to unassociate. Either site_ids or site_names is required. |
None
|
site_names
|
str or list
|
Name(s) of the site(s) to unassociate. Either site_ids or site_names is required. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
create_site(site_attributes, site_collection_id=None, site_collection_name=None)
¶
Creates a new site in Central and optionally associates it with a site collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_attributes
|
dict
|
Attributes of the site to create |
required |
site_collection_id
|
int
|
ID of the site collection. Either site_collection_name or site_collection_id is required if associating. |
None
|
site_collection_name
|
str
|
Name of the site collection. Either site_collection_name or site_collection_id is required if associating. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
delete_site(site_id=None, site_name=None)
¶
Deletes a site in Central.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
int
|
ID of the site to delete. Either site_id or site_name is required. |
None
|
site_name
|
str
|
Name of the site to delete. Either site_id or site_name is required. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
create_site_collection(collection_attributes, site_ids=None, site_names=None)
¶
Creates a new site collection in Central and optionally associates sites with it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection_attributes
|
dict
|
Attributes of the site collection to create |
required |
site_ids
|
int or list
|
ID(s) of the site(s) to associate. Either site_ids or site_names is required if associating. |
None
|
site_names
|
str or list
|
Name(s) of the site(s) to associate. Either site_ids or site_names is required if associating. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
delete_site_collection(site_collection_id=None, site_collection_name=None, remove_sites=False)
¶
Deletes a site collection in Central.
Optionally removes associated sites first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_collection_id
|
int
|
ID of the site collection to delete. Either site_collection_id or site_collection_name is required. |
None
|
site_collection_name
|
str
|
Name of the site collection to delete. Either site_collection_id or site_collection_name is required. |
None
|
remove_sites
|
bool
|
If True, removes sites associated with the site collection before deleting it. If False and sites are associated, deletion will fail. |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
get_hierarchy(scope, id=None, name=None)
¶
Fetches the hierarchy of the specified scope element in the global hierarchy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
str
|
Type of the element (e.g., site, site_collection, device, device_group) |
required |
id
|
int
|
ID of the element |
None
|
name
|
str
|
Name of the element |
None
|
Returns:
| Type | Description |
|---|---|
dict or None
|
Hierarchy of the specified element, None if unable to fetch |
Source code in pycentral/scopes/scopes.py
__str__()
¶
Returns a string representation of the Global scope.
Returns:
| Type | Description |
|---|---|
str
|
String representation of the Global scope |
get_scope_profiles()
¶
Fetches all configuration profiles associated with different scope elements.
Source code in pycentral/scopes/scopes.py
assign_profile_to_scope(profile_name, profile_persona=None, scope=None, scope_name=None, scope_id=None)
¶
Assigns a configuration profile to the specified scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_name
|
str
|
Name of the configuration profile |
required |
profile_persona
|
str
|
Device Persona of the profile. Optional if assigning to a device. |
None
|
scope
|
str
|
Type of the scope (e.g., global, site, site_collection, device) |
None
|
scope_name
|
str
|
Name of the scope element. Either scope_name or scope_id is required. |
None
|
scope_id
|
int
|
ID of the scope element. Either scope_name or scope_id is required. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
unassign_profile_to_scope(profile_name, profile_persona=None, scope=None, scope_name=None, scope_id=None)
¶
Unassigns a configuration profile from the specified scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_name
|
str
|
Name of the configuration profile |
required |
profile_persona
|
str
|
Device Persona of the profile. Optional if unassigning from a device. |
None
|
scope
|
str
|
Type of the scope (e.g., global, site, site_collection, device) |
None
|
scope_name
|
str
|
Name of the scope element. Either scope_name or scope_id is required. |
None
|
scope_id
|
int
|
ID of the scope element. Either scope_name or scope_id is required. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
move_devices_between_sites(current_site, new_site, device_serial, device_type=None, device_identifier=None, deployment_mode=None)
¶
Moves devices between sites.
Note: Moving devices between sites via NBAPI is not currently supported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_site
|
int or str or Site
|
ID, name, or Site instance of the current site |
required |
new_site
|
int or str or Site
|
ID, name, or Site instance of the destination site |
required |
device_serial
|
str
|
Serial number of device to move |
required |
device_type
|
str
|
Type of device. For example: AP, SWITCH, GATEWAY |
None
|
device_identifier
|
str
|
Additional device identifier |
None
|
deployment_mode
|
str
|
Deployment type. For example: Standalone, Virtual Controller |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in pycentral/scopes/scopes.py
Site¶
site
¶
Site(site_attributes, central_conn=None, from_api=False)
¶
Bases: ScopeBase
This class holds site and all of its attributes & related methods.
Constructor for Site object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_attributes
|
dict
|
Attributes of the site collection |
required |
central_conn
|
NewCentralBase
|
Instance of NewCentralBase to establish connection to Central. |
None
|
from_api
|
bool
|
Boolean indicates if the site_attributes is from the Central API response. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If unexpected or missing attributes are provided |
Source code in pycentral/scopes/site.py
create()
¶
Perform a POST call to create a site on Central.
Returns:
| Type | Description |
|---|---|
bool
|
True if site was created, False otherwise |
Raises:
| Type | Description |
|---|---|
Exception
|
If site already exists or central connection is missing |
Source code in pycentral/scopes/site.py
get()
¶
Performs a GET call to retrieve data of a site then sets attributes of self.
Returns:
| Type | Description |
|---|---|
dict
|
JSON Data of GET call if success, None otherwise |
Raises:
| Type | Description |
|---|---|
Exception
|
If site doesn't exist or central connection is missing |
Source code in pycentral/scopes/site.py
update()
¶
Performs a PUT call to update attributes of site on Central if changes are detected.
The source of truth is self.
Returns:
| Type | Description |
|---|---|
bool
|
True if modifications were made, False otherwise |
Raises:
| Type | Description |
|---|---|
Exception
|
If site doesn't exist on Central or central connection is missing |
Source code in pycentral/scopes/site.py
delete()
¶
Performs DELETE call to delete Site.
Returns:
| Type | Description |
|---|---|
bool
|
True if DELETE was successful, False otherwise |
Raises:
| Type | Description |
|---|---|
Exception
|
If site doesn't exist on Central or central connection is missing |
Source code in pycentral/scopes/site.py
get_site_collection_attributes()
¶
Returns dictionary of site collection attributes of the site.
Returns:
| Type | Description |
|---|---|
dict or None
|
Dictionary of site collection attributes with 'id' and 'name' keys, or None if site collection id is not defined |
Source code in pycentral/scopes/site.py
add_site_collection(site_collection_id, site_collection_name)
¶
Sets the attributes site collection id and name of this site object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_collection_id
|
int or str
|
Site collection id |
required |
site_collection_name
|
str
|
Site collection name |
required |
Source code in pycentral/scopes/site.py
remove_site_collection()
¶
Sets the attributes of site collection id and name to None.
Source code in pycentral/scopes/site.py
__str__()
¶
Returns string containing the Site id and name.
Returns:
| Type | Description |
|---|---|
str
|
String representation of this class |
__generate_api_body()
¶
Returns the dictionary of site attributes needed for making API calls.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary of site attributes needed for making API calls to Central |
Source code in pycentral/scopes/site.py
__get_timezone_attributes()
¶
Returns the dictionary of timezone attributes needed for making API calls.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary of timezone attributes with 'rawOffset', 'timezoneId', and 'timezoneName' keys needed for site management API calls to Central |
Source code in pycentral/scopes/site.py
Site Collection¶
site_collection
¶
Site_Collection(collection_attributes, central_conn=None, from_api=False)
¶
Bases: ScopeBase
This class holds site collection and all of its attributes & related methods.
Constructor for Site Collection object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection_attributes
|
dict
|
Attributes of the site collection |
required |
central_conn
|
NewCentralBase
|
Instance of NewCentralBase to establish connection to Central. |
None
|
from_api
|
bool
|
Boolean indicates if the collection_attributes is from the Central API response. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If unexpected or missing attributes are provided |
Source code in pycentral/scopes/site_collection.py
create()
¶
Perform a POST call to create a site collection on Central.
Returns:
| Type | Description |
|---|---|
bool
|
True if site collection was created, False otherwise |
Raises:
| Type | Description |
|---|---|
Exception
|
If site collection already exists or central connection is missing |
Source code in pycentral/scopes/site_collection.py
get()
¶
Performs a GET call to retrieve data of a site collection then sets attributes.
Returns:
| Type | Description |
|---|---|
dict
|
JSON Data of GET call if success, None otherwise |
Raises:
| Type | Description |
|---|---|
Exception
|
If site collection doesn't exist or central connection is missing |
Source code in pycentral/scopes/site_collection.py
update()
¶
Performs a PUT call to update attributes of site collection on Central if changes are detected.
The source of truth is self.
Returns:
| Type | Description |
|---|---|
bool
|
True if modifications were made, False otherwise |
Raises:
| Type | Description |
|---|---|
Exception
|
If site collection doesn't exist on Central or central connection is missing |
Source code in pycentral/scopes/site_collection.py
delete()
¶
Performs DELETE call to delete Site Collection.
Returns:
| Type | Description |
|---|---|
bool
|
True if DELETE was successful, False otherwise |
Raises:
| Type | Description |
|---|---|
Exception
|
If site collection doesn't exist on Central or central connection is missing |
Source code in pycentral/scopes/site_collection.py
associate_site(sites)
¶
Performs POST call to associate sites with a site collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sites
|
list
|
List of Site objects or list of site IDs (int) to associate with this site collection |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if site association was successful, False otherwise |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If sites parameter is not a list of Site or int types |
Source code in pycentral/scopes/site_collection.py
unassociate_site(sites)
¶
Performs DELETE call to unassociate sites with a site collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sites
|
list
|
List of Site objects or list of site IDs (int) to unassociate from this site collection |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if site unassociation was successful, False otherwise |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If sites parameter is not a list of Site or int types |
Source code in pycentral/scopes/site_collection.py
add_site(site_id)
¶
Adds the site details (site ID) to the site collection attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
int or str
|
Site ID of the site |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if site details were successfully updated, False otherwise |
Source code in pycentral/scopes/site_collection.py
remove_site(site_id)
¶
Removes the site details (site ID) from the site collection attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id
|
int
|
Site ID of the site |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if site details were removed, False otherwise |
Source code in pycentral/scopes/site_collection.py
__str__()
¶
Returns the string containing the name and ID of the site collection.
Returns:
| Type | Description |
|---|---|
str
|
String representation of this class |
Source code in pycentral/scopes/site_collection.py
__rename_keys(api_attributes)
¶
Renames the keys of the site collection attributes from the API response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_attributes
|
dict
|
Site collection attributes from Central API Response |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Renamed dictionary of site collection attributes mapped to object attributes |
Raises:
| Type | Description |
|---|---|
ValueError
|
If unknown attribute is found in API response |
Source code in pycentral/scopes/site_collection.py
__generate_api_body()
¶
Returns the dictionary of site collection attributes needed for making API calls.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary of site collection attributes needed for making API calls to Central |