Skip to content

Classic API

Legacy PyCentral reference modules for device management, monitoring, and configuration with classic Central.


Audit Logs

audit_logs

Audit

Get the audit logs and event logs with the functions in this class.

get_traillogs(conn, limit=100, offset=0, username=None, start_time=None, end_time=None, description=None, target=None, classification=None, customer_name=None, ip_address=None, app_id=None)

Get audit logs, sort by time in in reverse chronological order. This API returns the first 10,000 results only. Please use filter in the API for more relevant results. MSP Customer Would see logs of MSP's and tenants as well.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param limit: Maximum number of audit events to be returned, defaults to 100 :type limit: int, optional :param offset: Number of items to be skipped before returning the data, useful for pagination, defaults to 0 :type offset: int, optional :param username: Filter audit logs by User Name, defaults to None :type username: str, optional :param start_time: Filter audit logs by Time Range. Start time of the audit logs should be provided in epoch seconds, defaults to None :type start_time: int, optional :param end_time: Filter audit logs by Time Range. End time of the audit logs should be provided in epoch seconds, defaults to None :type end_time: int, optional :param description: Filter audit logs by Description, defaults to None :type description: str, optional :param target: Filter audit logs by target, defaults to None :type target: str, optional :param classification: Filter audit logs by Classification, defaults to None :type classification: str, optional :param customer_name: Filter audit logs by Customer NameFilter audit logs by Customer Name, defaults to None :type customer_name: str, optional :param ip_address: Filter audit logs by IP Address, defaults to None :type ip_address: str, optional :param app_id: Filter audit logs by app_id, defaults to None :type app_id: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/audit_logs.py
def get_traillogs(self, conn, limit=100, offset=0, username=None,
                  start_time=None, end_time=None, description=None,
                  target=None, classification=None, customer_name=None,
                  ip_address=None, app_id=None):
    """Get audit logs, sort by time in in reverse chronological order.
    This API returns the first 10,000 results only. Please use filter
    in the API for more relevant results. MSP Customer Would see logs
    of MSP's and tenants as well.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param limit: Maximum number of audit events to be returned, defaults\
        to 100
    :type limit: int, optional
    :param offset: Number of items to be skipped before returning the \
        data, useful for pagination, defaults to 0
    :type offset: int, optional
    :param username: Filter audit logs by User Name, defaults to None
    :type username: str, optional
    :param start_time: Filter audit logs by Time Range. Start time of the\
        audit logs should be provided in epoch seconds, defaults to None
    :type start_time: int, optional
    :param end_time: Filter audit logs by Time Range. End time of the \
        audit logs should be provided in epoch seconds, defaults to None
    :type end_time: int, optional
    :param description: Filter audit logs by Description, defaults to \
        None
    :type description: str, optional
    :param target: Filter audit logs by target, defaults to None
    :type target: str, optional
    :param classification: Filter audit logs by Classification, defaults \
        to None
    :type classification: str, optional
    :param customer_name: Filter audit logs by Customer NameFilter audit \
        logs by Customer Name, defaults to None
    :type customer_name: str, optional
    :param ip_address: Filter audit logs by IP Address, defaults to None
    :type ip_address: str, optional
    :param app_id: Filter audit logs by app_id, defaults to None
    :type app_id: str, optional
    :return: HTTP Response as provided by 'command' function in \
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.TRAIL_LOG["GET_ALL"]
    params = {"limit": limit, "offset": offset}
    if username:
        params["username"] = username
    if start_time:
        params["start_time"] = start_time
    if end_time:
        params["end_time"] = end_time
    if description:
        params["description"] = description
    if target:
        params["target"] = target
    if classification:
        params["classification"] = classification
    if customer_name:
        params["customer_name"] = customer_name
    if ip_address:
        params["ip_address"] = ip_address
    if app_id:
        params["app_id"] = app_id
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_traillogs_detail(conn, id)

Get details of an audit log

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param id: ID of audit event :type id: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/audit_logs.py
def get_traillogs_detail(self, conn, id):
    """Get details of an audit log

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param id: ID of audit event
    :type id: str
    :return: HTTP Response as provided by 'command' function in \
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.TRAIL_LOG["GET"], id)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

get_eventlogs(conn, limit=100, offset=0, group_name=None, device_id=None, classification=None, start_time=None, end_time=None)

Get audit events for all groups, sort by time in in reverse chronological order.This API returns the first 10,000 results only. Please use filter in the API for more relevant results.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param limit: Maximum number of audit events to be returned, defaults to 100 :type limit: int, optional :param offset: Number of items to be skipped before returning the data, useful for pagination, defaults to 0 :type offset: int, optional :param group_name: Filter audit events by Group Name, defaults to None :type group_name: str, optional :param device_id: Filter audit events by Target / Device ID. Device ID for AP is VC Name and Serial Number for Switches, defaults to None :type device_id: str, optional :param classification: Filter audit events by classification, defaults to None :type classification: str, optional :param start_time: Filter audit logs by Time Range. Start time of the audit logs should be provided in epoch seconds, defaults to None :type start_time: int, optional :param end_time: Filter audit logs by Time Range. End time of the audit logs should be provided in epoch seconds, defaults to None :type end_time: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/audit_logs.py
def get_eventlogs(self, conn, limit=100, offset=0, group_name=None,
                  device_id=None, classification=None, start_time=None,
                  end_time=None):
    """Get audit events for all groups, sort by time in in reverse\
        chronological order.This API returns the first 10,000 results\
        only. Please use filter in the API for more relevant results.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param limit: Maximum number of audit events to be returned, defaults\
        to 100
    :type limit: int, optional
    :param offset: Number of items to be skipped before returning the\
        data, useful for pagination, defaults to 0
    :type offset: int, optional
    :param group_name: Filter audit events by Group Name, defaults to None
    :type group_name: str, optional
    :param device_id: Filter audit events by Target / Device ID. Device ID\
        for AP is VC Name and Serial Number
        for Switches, defaults to None
    :type device_id: str, optional
    :param classification: Filter audit events by classification, defaults\
        to None
    :type classification: str, optional
    :param start_time: Filter audit logs by Time Range. Start time of the\
        audit logs should be provided
        in epoch seconds, defaults to None
    :type start_time: int, optional
    :param end_time: Filter audit logs by Time Range. End time of the\
        audit logs should be provided in epoch
        seconds, defaults to None
    :type end_time: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.EVENT_LOG["GET_ALL"]
    params = {"limit": limit, "offset": offset}
    if group_name:
        params["group_name"] = group_name
    if device_id:
        params["device_id"] = device_id
    if classification:
        params["classification"] = classification
    if start_time:
        params["start_time"] = start_time
    if end_time:
        params["end_time"] = end_time
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_eventlogs_detail(conn, id)

Get details of an audit event/log

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param id: ID of audit event :type id: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/audit_logs.py
def get_eventlogs_detail(self, conn, id):
    """Get details of an audit event/log

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param id: ID of audit event
    :type id: str
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.EVENT_LOG["GET"], id)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

Base Utils

base_utils

clusterBaseURL

Bases: object

This class helps to fetch the API Base URL when Aruba Central cluster name is provided.

getBaseURL(cluster_name)

This method returns the API Base URL of the provided Aruba Central cluster.

:param cluster_name: Name of the Aruba Central cluster whose base_url needs to be returned :type cluster_name: str :return: Base URL of provided cluster :rtype: str

Source code in pycentral/classic/base_utils.py
def getBaseURL(self, cluster_name):
    """This method returns the API Base URL of the provided Aruba Central\
        cluster.

    :param cluster_name: Name of the Aruba Central cluster whose base_url\
        needs to be returned
    :type cluster_name: str
    :return: Base URL of provided cluster
    :rtype: str
    """
    if cluster_name in CLUSTER_API_BASE_URL_LIST:
        return f'https://{CLUSTER_API_BASE_URL_LIST[cluster_name]}'
    else:
        errorMessage = (f"Unable to find cluster_name - {cluster_name}.\n" +
                        URL_BASE_ERR_MESSAGE)
        raise ValueError(errorMessage)

getAllBaseURLs()

This method returns the list of base URLs of all the clusters of Aruba Central

:return: List of all valid base URLs of Aruba Central :rtype: list

Source code in pycentral/classic/base_utils.py
def getAllBaseURLs(self):
    """This method returns the list of base URLs of all the clusters of\
        Aruba Central

    :return: List of all valid base URLs of Aruba Central
    :rtype: list
    """
    return list(CLUSTER_API_BASE_URL_LIST.values())

parseInputArgs(central_info)

This method parses user input, checks for the availability of mandatory arguments. If the user opts to provide a cluster_name instead of base_url, the method will use the cluster_name to fetch the base_url. Optional missing parameters in central_info variable is initialized as defined in C_DEFAULT_ARGS.

:param central_info: central_info dictionary as read from user's input file. :type central_info: dict :return: parsed central_info dict with missing optional params set to default values. :rtype: dict

Source code in pycentral/classic/base_utils.py
def parseInputArgs(central_info):
    """This method parses user input, checks for the availability of mandatory\
        arguments. If the user opts to provide a cluster_name instead of\
        base_url, the method will use the cluster_name to fetch the base_url.\
        Optional missing parameters in central_info variable is\
        initialized as defined in C_DEFAULT_ARGS.

    :param central_info: central_info dictionary as read from user's input\
        file.
    :type central_info: dict
    :return: parsed central_info dict with missing optional params set to\
        default values.
    :rtype: dict
    """
    if not central_info:
        exit("Error: Invalid Input!")

    valid_url_input_keys = ["cluster_name", "base_url"]
    url_conditional = [cluster_var in central_info.keys()
                       for cluster_var in valid_url_input_keys]
    if all(url_conditional):
        errorMessage = ("Cannot provide both base_url & cluster_name in token information. " +
                        URL_BASE_ERR_MESSAGE)
        raise KeyError(errorMessage)
    elif any(url_conditional):
        if "cluster_name" in central_info:
            central_info['base_url'] = c.getBaseURL(
                central_info['cluster_name'])
        elif "base_url" in central_info:
            central_info['base_url'] = valid_url(central_info['base_url'])
    else:
        raise KeyError(URL_BASE_ERR_MESSAGE)

    default_dict = dict(C_DEFAULT_ARGS)
    for key in default_dict.keys():
        if key in central_info:
            default_dict[key] = central_info[key]

    return default_dict

tokenLocalStoreUtil(token_store, customer_id='customer', client_id='client')

Utility function for storeToken and loadToken default access token storage/cache method. This function generates unique file name for a customer and API gateway client to store and load access token in the local machine for reuse. The format of the file name is tok__.json. If customer_id or client_id is not provided, default values mentioned in args will be used.

:param token_store: Placeholder to support different token storage mechanism.

* keyword type: Place holder for different token storage mechanism.            Defaults to local storage.

* keyword path: path where temp folder is created to store token JSON            file.

:type token_store: dict :param customer_id: Aruba Central customer id, defaults to "customer" :type customer_id: str, optional :param client_id: API Gateway client id, defaults to "client" :type client_id: str, optional :return: Filename for access token storage. :rtype: str

Source code in pycentral/classic/base_utils.py
def tokenLocalStoreUtil(token_store, customer_id="customer",
                        client_id="client"):
    """Utility function for storeToken and loadToken default access token\
        storage/cache method. This function generates unique file name for a\
        customer and API gateway client to store and load access token in the\
        local machine for reuse. The format of the file name is\
        tok_<customer_id>_<client_id>.json. If customer_id or client_id is not\
        provided, default values mentioned in args will be used.

    :param token_store: Placeholder to support different token storage\
        mechanism. \n
        * keyword type: Place holder for different token storage mechanism.\
            Defaults to local storage. \n
        * keyword path: path where temp folder is created to store token JSON\
            file. \n
    :type token_store: dict
    :param customer_id: Aruba Central customer id, defaults to "customer"
    :type customer_id: str, optional
    :param client_id: API Gateway client id, defaults to "client"
    :type client_id: str, optional
    :return: Filename for access token storage.
    :rtype: str
    """
    fileName = "tok_"
    if customer_id is not None:
        fileName += str(customer_id)
    fileName += "_" + str(client_id) + ".json"
    filePath = os.path.join(os.getcwd(), "temp")
    if token_store and "path" in token_store:
        filePath = os.path.join(token_store["path"])
    fullName = os.path.join(filePath, fileName)
    return fullName

get_url(base_url, path='', params='', query={}, fragment='')

This method constructs complete URL based on multiple parts of URL.

:param base_url: base url for a HTTP request :type base_url: str :param path: API endpoint path, defaults to '' :type path: str, optional :param params: API endpoint path parameters, defaults to '' :type params: str, optional :param query: HTTP request url query parameters, defaults to {} :type query: dict, optional :param fragment: URL fragment identifier, defaults to '' :type fragment: str, optional :return: Parsed URL :rtype: class:urllib.parse.ParseResult

Source code in pycentral/classic/base_utils.py
def get_url(base_url, path='', params='', query={}, fragment=''):
    """This method constructs complete URL based on multiple parts of URL.

    :param base_url: base url for a HTTP request
    :type base_url: str
    :param path: API endpoint path, defaults to ''
    :type path: str, optional
    :param params: API endpoint path parameters, defaults to ''
    :type params: str, optional
    :param query: HTTP request url query parameters, defaults to {}
    :type query: dict, optional
    :param fragment: URL fragment identifier, defaults to ''
    :type fragment: str, optional
    :return: Parsed URL
    :rtype: class:`urllib.parse.ParseResult`
    """
    base_url = valid_url(base_url)
    parsed_baseurl = urlparse(base_url)
    scheme = parsed_baseurl.scheme
    netloc = parsed_baseurl.netloc
    query = urlencode(query)
    url = urlunparse((scheme, netloc, path, params, query, fragment))
    return url

valid_url(url)

This method verifies & returns the URL in a valid format. If the URL is missing the https prefix, the function will prepend the prefix after verifiying that its a valid base URL of an Aruba Central cluster.

:param base_url: base url for a HTTP request :type base_url: str :return: Valid Base URL :rtype: str

Source code in pycentral/classic/base_utils.py
def valid_url(url):
    """This method verifies & returns the URL in a valid format. If the URL is\
        missing the https prefix, the function will prepend the prefix after\
        verifiying that its a valid base URL of an Aruba Central cluster.

    :param base_url: base url for a HTTP request
    :type base_url: str
    :return: Valid Base URL
    :rtype: str
    """
    parsed_url = urlparse(url)
    if all([parsed_url.scheme, parsed_url.netloc]):
        return parsed_url.geturl()
    elif bool(parsed_url.scheme) is False and bool(parsed_url.path):
        parsed_url = parsed_url._replace(**{"scheme": "https",
                                            "netloc": parsed_url.path,
                                            "path": ''})
        return parsed_url.geturl()
    else:
        errorMessage = ('Invalid Base URL - ' + f'{url}\n' +
                        URL_BASE_ERR_MESSAGE)
        raise ValueError(errorMessage)

console_logger(name, level='DEBUG')

This method create an instance of python logging and sets the following format for log messages.

:param name: String displayed after data and time. Define it to identify        from which part of the code, log message is generated.
:type name: str
:param level: Loggin level set to display messages from a certain logging        level. Refer Python logging library man page, defaults to "DEBUG"
:type level: str, optional
:return: An instance of class logging
:rtype: class:`logging.Logger`
Source code in pycentral/classic/base_utils.py
def console_logger(name, level="DEBUG"):
    """This method create an instance of python logging and sets the following\
        format for log messages.\n<date> <time> - <name> - <level> - <message>

    :param name: String displayed after data and time. Define it to identify\
        from which part of the code, log message is generated.
    :type name: str
    :param level: Loggin level set to display messages from a certain logging\
        level. Refer Python logging library man page, defaults to "DEBUG"
    :type level: str, optional
    :return: An instance of class logging
    :rtype: class:`logging.Logger`
    """
    channel_handler = logging.StreamHandler()
    format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
    date_format = '%Y-%m-%d %H:%M:%S'
    f = format
    if COLOR:
        cformat = '%(log_color)s' + format
        f = colorlog.ColoredFormatter(
            cformat,
            date_format,
            log_colors={
                'DEBUG': 'bold_cyan',
                'INFO': 'blue',
                'WARNING': 'yellow',
                'ERROR': 'red',
                'CRITICAL': 'bold_red'})
    else:
        f = logging.Formatter(format, date_format)
    channel_handler.setFormatter(f)

    logger = logging.getLogger(name)
    logger.setLevel(C_LOG_LEVEL[level])
    logger.addHandler(channel_handler)

    return logger

Configuration

configuration

Groups

Bases: object

A python class consisting of functions to manage Aruba Central Groups via REST API

get_groups(conn, offset=0, limit=20)

Get list of groups

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param offset: Pagination offset, defaults to 0 :type offset: int, optional :param limit: Pagination limit with Max 20, defaults to 20 :type limit: int, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/configuration.py
def get_groups(self, conn, offset=0, limit=20):
    """Get list of groups

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param offset: Pagination offset, defaults to 0
    :type offset: int, optional
    :param limit: Pagination limit with Max 20, defaults to 20
    :type limit: int, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.GROUPS["GET_ALL"]
    params = {
        "offset": offset,
        "limit": limit
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_config_mode_groups(conn, groups)

For each group in the provided list, the configuration mode for Instant APs and Gateways is specified under the 'Wireless' field and for switches under the 'Wired' field. The configuration mode is specified as a boolean value indicating if the device type is managed using the template mode of configuration or not.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param groups: A list of group names with max of 20 groups. :type groups: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/configuration.py
def get_config_mode_groups(self, conn, groups):
    """For each group in the provided list, the configuration mode for\
    Instant APs and Gateways is specified under the 'Wireless' field and\
    for switches under the 'Wired' field. The configuration mode is\
    specified as a boolean value indicating if the device type is managed\
    using the template mode of configuration or not.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param groups: A list of group names with max of 20 groups.
    :type groups: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.GROUPS["GET_TEMPLATE_INFO"]
    params = {
        "groups": ",".join(groups)
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

create_group(conn, group_name, group_password, wired_template=False, wireless_template=False)

Create new group given a group name, group password and configuration mode(UI or template mode of configuration) to be set per device type.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of the group to be created. :type group_name: str :param group_password: Password for the group to be created :type group_password: str :param wired_template: Set to True to make the configuration mode for switches to template mode, defaults to False :type wired_template: bool, optional :param wireless_template: Set to True to make the configuration mode for IAPs and Gateways to template mode, defaults to False :type wireless_template: bool, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/configuration.py
def create_group(self, conn, group_name, group_password,
                 wired_template=False, wireless_template=False):
    """Create new group given a group name, group password and\
    configuration mode(UI or template mode of configuration) to be set per\
    device type.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of the group to be created.
    :type group_name: str
    :param group_password: Password for the group to be created
    :type group_password: str
    :param wired_template: Set to True to make the configuration mode for\
        switches to template mode, defaults to False
    :type wired_template: bool, optional
    :param wireless_template: Set to True to make the configuration mode\
        for IAPs and Gateways to template mode, defaults to False
    :type wireless_template: bool, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.GROUPS["CREATE"]
    data = self._build_group_payload(
        group_name,
        group_password,
        wired_template,
        wireless_template)
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

clone_create_group(conn, new_group_name, existing_group_name)

Clone and create new group from a given group with the given name. The configuration of the new group will be inherited from the given group.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param new_group_name: New group name to be created. :type new_group_name: str :param existing_group_name: Existing group name to be cloned. :type existing_group_name: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/configuration.py
def clone_create_group(self, conn, new_group_name, existing_group_name):
    """Clone and create new group from a given group with the given name.\
        The configuration of the new group will be inherited from the\
        given group.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param new_group_name: New group name to be created.
    :type new_group_name: str
    :param existing_group_name: Existing group name to be cloned.
    :type existing_group_name: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.GROUPS["CREATE_CLONE"]
    data = {
        "group": new_group_name,
        "clone_group": existing_group_name
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

delete_group(conn, group_name)

Delete an existing group

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of the group to be deleted. :type group_name: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/configuration.py
def delete_group(self, conn, group_name):
    """Delete an existing group

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of the group to be deleted.
    :type group_name: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.GROUPS["DELETE"], group_name)
    resp = conn.command(apiMethod="DELETE", apiPath=path)
    return resp

Devices

Bases: object

A python class consisting of functions to manage Aruba Central Devices via REST API

get_devices_group(conn, device_serial)

Get group name for a device

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of Aruba device :type device_serial: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/configuration.py
def get_devices_group(self, conn, device_serial):
    """Get group name for a device

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of Aruba device
    :type device_serial: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.DEVICES["GET"], device_serial, "group")
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

get_devices_configuration(conn, device_serial)

Get last known device configuration for a device.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of Aruba device. :type device_serial: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_devices_configuration(self, conn, device_serial):
    """Get last known device configuration for a device.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of Aruba device.
    :type device_serial: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.DEVICES["GET"], device_serial, "configuration")
    headers = {
        "Accept": "multipart/form-data"
    }
    resp = conn.command(apiMethod="GET", apiPath=path, headers=headers)
    return resp

get_devices_config_details(conn, device_serial, details=True)

Get

  1. central side configuration.
  2. Device running configuration.
  3. Configuration error details.
  4. Template error details and status of a device belonging to a template group.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of Aruba device. :type device_serial: str :param details: Usually pass false to get only the summary of a device's configuration status. Pass true only if detailed response of a device's configuration status is required. Passing true might result in slower API response and performance effect comparatively., defaults to True :type details: bool, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_devices_config_details(self, conn, device_serial, details=True):
    """Get \n
    1. central side configuration.
    2. Device running configuration.
    3. Configuration error details.
    4. Template error details and status of a device belonging to a \
        template group.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of Aruba device.
    :type device_serial: str
    :param details: Usually pass false to get only the summary of a\
        device's configuration status. Pass true only if detailed response\
        of a device's configuration status is required. Passing true might\
        result in slower API response and performance effect\
        comparatively., defaults to True
    :type details: bool, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.DEVICES["GET"], device_serial, "config_details")
    params = {
        "details": details
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_devices_templates(conn, device_serials)

Get existing templates for list of devices

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serials: List of serial number of Aruba devices :type device_serials: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_devices_templates(self, conn, device_serials):
    """Get existing templates for list of devices

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serials: List of serial number of Aruba devices
    :type device_serials: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urls.DEVICES["GET_TEMPLATES"]
    params = {
        "device_serials": ",".join(device_serials)
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_devices_group_templates(conn, device_type='IAP', include_groups=[], exclude_groups=[], all_groups=False, offset=0, limit=20)

Get templates for devices in a group or multiple groups

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_type: Device type (i.e. IAP/ArubaSwitch/ MobilityController/CX), defaults to "IAP" :type device_type: str, optional :param include_groups: Fetch devices templates in list of groups, defaults to [] :type include_groups: list, optional :param exclude_groups: Fetch devices templates not in list of groups, defaults to [] :type exclude_groups: list, optional :param all_groups: Set to True, to fetch devices templates details for all the groups(Only allowed for user having all_groups access or admin), defaults to False :type all_groups: bool, optional :param offset: Pagination offset, defaults to 0 :type offset: int, optional :param limit: Pagination limit with Max 20, defaults to 20 :type limit: int, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_devices_group_templates(
        self,
        conn,
        device_type="IAP",
        include_groups=[],
        exclude_groups=[],
        all_groups=False,
        offset=0,
        limit=20):
    """Get templates for devices in a group or multiple groups

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_type: Device type (i.e. IAP/ArubaSwitch/\
        MobilityController/CX), defaults to "IAP"
    :type device_type: str, optional
    :param include_groups: Fetch devices templates in list of groups,\
        defaults to []
    :type include_groups: list, optional
    :param exclude_groups: Fetch devices templates not in list of groups,\
        defaults to []
    :type exclude_groups: list, optional
    :param all_groups: Set to True, to fetch devices templates details for\
        all the groups(Only allowed for user having all_groups access or\
        admin), defaults to False
    :type all_groups: bool, optional
    :param offset: Pagination offset, defaults to 0
    :type offset: int, optional
    :param limit: Pagination limit with Max 20, defaults to 20
    :type limit: int, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urls.DEVICES["GET_GRP_TEMPLATES"]
    params = {
        "limit": limit,
        "offset": offset,
        "device_type": device_type,
        "all_groups": all_groups
    }
    if include_groups:
        params["include_groups"] = ",".join(include_groups)
    if exclude_groups:
        params["exclude_groups"] = ",".join(exclude_groups)
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_device_templates_from_hash(conn, template_hash, offset=0, limit=20, exclude_hash=False, device_type='IAP')

List of devices with its group name and template information is populated

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param template_hash: Template_hash of the template for which list of devices needs to be populated. :type template_hash: str :param offset: Pagination offset, defaults to 0 :type offset: int, optional :param limit: Pagination limit with Max 20, defaults to 20 :type limit: int, optional :param exclude_hash: Fetch devices template details not matching with provided hash, defaults to False :type exclude_hash: bool, optional :param device_type: Device type (i.e. IAP/ArubaSwitch/ MobilityController/CX), defaults to "IAP" :type device_type: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_device_templates_from_hash(self, conn, template_hash, offset=0,
                                   limit=20, exclude_hash=False,
                                   device_type="IAP"):
    """List of devices with its group name and template information is\
        populated

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param template_hash: Template_hash of the template for which list of\
        devices needs to be populated.
    :type template_hash: str
    :param offset: Pagination offset, defaults to 0
    :type offset: int, optional
    :param limit: Pagination limit with Max 20, defaults to 20
    :type limit: int, optional
    :param exclude_hash: Fetch devices template details not matching with\
        provided hash, defaults to False
    :type exclude_hash: bool, optional
    :param device_type: Device type (i.e. IAP/ArubaSwitch/\
        MobilityController/CX), defaults to "IAP"
    :type device_type: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.DEVICES["GET"], template_hash, "template")
    params = {
        "offset": offset,
        "limit": limit,
        "exclude_hash": exclude_hash,
        "device_type": device_type
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_switch_variablized_templates(conn, device_serial)

Get template and variabled for Aruba device (switch)

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of Aruba device. :type device_serial: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_switch_variablized_templates(self, conn, device_serial):
    """Get template and variabled for Aruba device (switch)

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of Aruba device.
    :type device_serial: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.DEVICES["GET"],
        device_serial,
        "variablised_template")
    headers = {
        "Accept": "multipart/form-data"
    }
    resp = conn.command(apiMethod="GET", apiPath=path, headers=headers)
    return resp

set_switch_ssh_credentials(conn, device_serial, username, password)

Set SSH connection information of Aruba Device (switch)

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of Aruba device. :type device_serial: str :param username: SSH username to set to the device :type username: str :param password: SSH password to set to the device :type password: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def set_switch_ssh_credentials(
        self,
        conn,
        device_serial,
        username,
        password):
    """Set SSH connection information of Aruba Device (switch)

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of Aruba device.
    :type device_serial: str
    :param username: SSH username to set to the device
    :type username: str
    :param password: SSH password to set to the device
    :type password: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.DEVICES["SET_SWITCH_CRED"],
        device_serial,
        "ssh_connection")
    data = {
        "username": username,
        "password": password
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

move_devices(conn, group_name, device_serials, preserve_config_overrides=None)

Move list of devices to group and assign specified group in device management page :param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of a group where devices will be moved :type group_name: str :param device_serials: A list of device serials to be moved to the mentioned group :type device_serials: list :param preserve_config_overrides: List of device types for which configuration overrides should be preserved. This is only supported for AOS-CX switches today, e.g., ["AOS_CX"] :type preserve_config_overrides: list, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def move_devices(self, conn, group_name, device_serials, preserve_config_overrides=None):
    """Move list of devices to group and assign specified group in device\
        management page
    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of a group where devices will be moved
    :type group_name: str
    :param device_serials: A list of device serials to be moved to the\
        mentioned group
    :type device_serials: list
    :param preserve_config_overrides: List of device types for which configuration\
        overrides should be preserved. This is only supported for AOS-CX switches\
        today, e.g., ["AOS_CX"]
    :type preserve_config_overrides: list, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urls.DEVICES["MOVE_DEVICES"]
    data = {
        "group": group_name,
        "serials": device_serials
    }
    # Add preserve_config_overrides to the data payload if provided
    if preserve_config_overrides:
        data["preserve_config_overrides"] = preserve_config_overrides

    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

Templates

Bases: object

A python class consisting of functions to manage Aruba Central Templates via REST API

get_template_text(conn, group_name, template_name)

Get CLI template in text format.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of an existing group :type group_name: str :param template_name: Name of an existing template within mentioned group :type template_name: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_template_text(self, conn, group_name, template_name):
    """Get CLI template in text format.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of an existing group
    :type group_name: str
    :param template_name: Name of an existing template within mentioned\
        group
    :type template_name: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.TEMPLATES["GET"],
        group_name,
        "templates",
        template_name)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

get_template(conn, group_name, device_type='', template_name='', version='', model='', q='', offset=0, limit=20)

Get all templates in group. Query can be filtered by name, device_type, version, model or version number. Response is sorted by template name.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of the group for which the templates will be being queried. :type group_name: str :param device_type: Filter on device_type, defaults to "" :type device_type: str, optional :param template_name: Filter on template name, defaults to "" :type template_name: str, optional :param version: Filter on version property of template, defaults to "" :type version: str, optional :param model: Filter on model property of template. For 'ArubaSwitch' device_type, part number(J number) can be used., defaults to "" :type model: str, optional :param q: Search for template OR version OR model, q will be ignored if any of filter parameters are provided, defaults to "" :type q: str, optional :param offset: Pagination offset, defaults to 0 :type offset: int, optional :param limit: Pagination limit with Max 20, defaults to 20 :type limit: int, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_template(
        self,
        conn,
        group_name,
        device_type="",
        template_name="",
        version="",
        model="",
        q="",
        offset=0,
        limit=20):
    """Get all templates in group. Query can be filtered by name,\
        device_type, version, model or version number. Response is sorted\
        by template name.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of the group for which the templates will be\
        being queried.
    :type group_name: str
    :param device_type: Filter on device_type, defaults to ""
    :type device_type: str, optional
    :param template_name: Filter on template name, defaults to ""
    :type template_name: str, optional
    :param version: Filter on version property of template, defaults to ""
    :type version: str, optional
    :param model: Filter on model property of template. For 'ArubaSwitch'\
        device_type, part number(J number) can be used., defaults to ""
    :type model: str, optional
    :param q: Search for template OR version OR model, q will be ignored\
        if any of filter parameters are
        provided, defaults to ""
    :type q: str, optional
    :param offset: Pagination offset, defaults to 0
    :type offset: int, optional
    :param limit: Pagination limit with Max 20, defaults to 20
    :type limit: int, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.TEMPLATES["GET"], group_name, "templates")
    params = {
        "limit": limit,
        "offset": offset
    }
    if device_type:
        params["device_type"] = device_type
    if template_name:
        params["template"] = template_name
    if version:
        params["version"] = version
    if model:
        params["model"] = model
    if q:
        params["q"] = q
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

create_template(conn, group_name, template_name, template_filename, device_type='IAP', version='ALL', model='ALL')

Upload a new template file

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of the group in which the template file will be created. :type group_name: str :param template_name: Name for the template to be created :type template_name: str :param template_filename: Name of the template file in local machine to be sent to central using API :type template_filename: str :param device_type: Type of the Aruba device, defaults to "IAP" :type device_type: str, optional :param version: Firmware version property of template., defaults to "ALL" :type version: str, optional :param model: Model property of template. For 'ArubaSwitch' device_type, part number (J number) can be used, defaults to "ALL" :type model: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def create_template(self, conn, group_name, template_name,
                    template_filename, device_type="IAP", version="ALL",
                    model="ALL"):
    """Upload a new template file

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of the group in which the template file will\
        be created.
    :type group_name: str
    :param template_name: Name for the template to be created
    :type template_name: str
    :param template_filename: Name of the template file in local machine\
        to be sent to central using API
    :type template_filename: str
    :param device_type: Type of the Aruba device, defaults to "IAP"
    :type device_type: str, optional
    :param version: Firmware version property of template., defaults to\
        "ALL"
    :type version: str, optional
    :param model: Model property of template. For 'ArubaSwitch'\
        device_type, part number (J number) can be
        used, defaults to "ALL"
    :type model: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    # Open template file in binary mode
    files = {}
    fp = None
    try:
        fp = open(template_filename, "rb")
        files = {
            "template": fp
        }
    except Exception as err:
        logger.error("Unable to open the template file! " + str(err))
        return None

    # Make the API request
    path = urlJoin(urls.TEMPLATES["CREATE"], group_name, "templates")
    params = {
        "name": template_name,
        "device_type": device_type,
        "version": version,
        "model": model
    }
    resp = conn.command(apiMethod="POST", apiPath=path,
                        apiParams=params, files=files)

    # Close the file
    if fp:
        fp.close()

    return resp

update_template(conn, group_name, template_name, template_filename, device_type='', version='', model='')

[summary]

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of the group in which the template file exists. :type group_name: str :param template_name: Name of the template to be modified :type template_name: str :param template_filename: Name of the template file in local machine to be sent to central using API :type template_filename: str :param device_type: Aruba device type of the template , defaults to "" :type device_type: str, optional :param version: Firmware version property of template., defaults to "" :type version: str, optional :param model: Device model property of template. For 'ArubaSwitch' device_type, part number (J number) can be used, defaults to "" :type model: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def update_template(
        self,
        conn,
        group_name,
        template_name,
        template_filename,
        device_type="",
        version="",
        model=""):
    """[summary]

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of the group in which the template file exists.
    :type group_name: str
    :param template_name: Name of the template to be modified
    :type template_name: str
    :param template_filename: Name of the template file in local machine\
        to be sent to central using API
    :type template_filename: str
    :param device_type: Aruba device type of the template , defaults to ""
    :type device_type: str, optional
    :param version: Firmware version property of template., defaults to ""
    :type version: str, optional
    :param model: Device model property of template. For 'ArubaSwitch'\
        device_type, part number (J number) can be
        used, defaults to ""
    :type model: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    # Open template file in binary mode
    files = {}
    fp = None
    try:
        fp = open(template_filename, "rb")
        files = {
            "template": fp
        }
    except Exception as err:
        logger.error("Unable to open the template file! " + str(err))
        return None

    path = urlJoin(urls.TEMPLATES["CREATE"], group_name, "templates")
    params = {
        "name": template_name
    }
    if device_type:
        params["device_type"] = device_type
    if version:
        params["version"] = version
    if model:
        params["model"] = model

    resp = conn.command(apiMethod="PATCH", apiPath=path,
                        apiParams=params, files=files)

    # Close the file
    if fp:
        fp.close()

    return resp

delete_template(conn, group_name, template_name)

Delete an existing template

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of the group in which the template file exists. :type group_name: str :param template_name: Name of the template to be deleted. :type template_name: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def delete_template(self, conn, group_name, template_name):
    """Delete an existing template

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of the group in which the template file exists.
    :type group_name: str
    :param template_name: Name of the template to be deleted.
    :type template_name: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.TEMPLATES["GET"],
        group_name,
        "templates",
        template_name)
    resp = conn.command(apiMethod="DELETE", apiPath=path)
    return resp

Variables

Bases: object

A python class consisting of functions to manage Aruba Central Variables via REST API

get_template_variables(conn, device_serial)

Get template variables for a device

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of the device. :type device_serial: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_template_variables(self, conn, device_serial):
    """Get template variables for a device

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of the device.
    :type device_serial: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.VARIABLES["GET"],
        device_serial,
        "template_variables")
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

get_all_template_variables(conn, offset=0, limit=20, format='JSON')

Get template variables for all devices

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param offset: Pagination offset. Number of items to be skipped before returning the data, useful for pagination, defaults to 0 :type offset: int, optional :param limit: Pagination limit. Maximum number of records to be returned, defaults to 20 :type limit: int, optional :param format: Format in which output is desired, defaults to "JSON" :type format: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_all_template_variables(self, conn, offset=0, limit=20,
                               format="JSON"):
    """Get template variables for all devices

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param offset: Pagination offset. Number of items to be skipped before\
        returning the data,
        useful for pagination, defaults to 0
    :type offset: int, optional
    :param limit: Pagination limit. Maximum number of records to be\
        returned, defaults to 20
    :type limit: int, optional
    :param format: Format in which output is desired, defaults to "JSON"
    :type format: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urls.VARIABLES["GET_ALL"]
    params = {
        "format": format,
        "offset": offset,
        "limit": limit
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

create_template_variables(conn, device_serial, variables)

Create template variable for a device

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial Number of a device for which the variables are to be created. :type device_serial: str :param variables: Variables defined in template file to be applied for a device. Sample Variables -

{"_sys_serial": "AB0011111",             "_sys_lan_mac": "11:12:AA:13:14:BB",            "SSID_A": "Z-Employee"}

:type variables: dict :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def create_template_variables(self, conn, device_serial, variables):
    """Create template variable for a device

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial Number of a device for which the\
        variables are to be created.
    :type device_serial: str
    :param variables: Variables defined in template file to be applied for\
        a device. Sample Variables - \n
        {"_sys_serial": "AB0011111", \
        "_sys_lan_mac": "11:12:AA:13:14:BB",\
        "SSID_A": "Z-Employee"}
    :type variables: dict
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.VARIABLES["CREATE"],
        device_serial,
        "template_variables")
    data = {
        "variables": variables
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

create_template_variables_file(conn, variables_filename, format='JSON')

Create template variables for multiple devices defined in JSON format in a file

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param variables_filename: Name of the variable file to be sent to Central via API. :type variables_filename: str :param format: Format of data in the file to be uploaded, defaults to "JSON" :type format: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def create_template_variables_file(
        self, conn, variables_filename, format="JSON"):
    """Create template variables for multiple devices defined in JSON\
        format in a file

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param variables_filename: Name of the variable file to be sent to\
        Central via API.
    :type variables_filename: str
    :param format: Format of data in the file to be uploaded, defaults to\
        "JSON"
    :type format: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urls.VARIABLES["CREATE_ALL"]
    params = {
        "format": format
    }

    # Open variable file in binary mode
    files = {}
    fp = None
    try:
        fp = open(variables_filename, "rb")
        files = {
            "variables": fp
        }
    except Exception as err:
        logger.error("Unable to open the variable file! " + str(err))
        return None

    resp = conn.command(apiMethod="POST", apiPath=path,
                        apiParams=params, files=files)

    # Close the file
    if fp:
        fp.close()

    return resp

update_template_variables(conn, device_serial, variables)

Update values of existing template variables and add new variables to the existing set of variables for a device.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of a device :type device_serial: str :param variables: Template variables to be updated for the mentioned device :type variables: dict :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def update_template_variables(self, conn, device_serial, variables):
    """Update values of existing template variables and add new variables\
        to the existing set of variables for a device.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of a device
    :type device_serial: str
    :param variables: Template variables to be updated for the mentioned\
        device
    :type variables: dict
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.VARIABLES["UPDATE"],
        device_serial,
        "template_variables")
    data = {
        "variables": variables
    }
    resp = conn.command(apiMethod="PATCH", apiPath=path, apiData=data)
    return resp

update_template_variables_file(conn, variables_filename)

Update values of existing template variables and add new variables to the existing set of variables for multiple devices defined in the specified file.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param variables_filename: Local filename of template variables to be uploaded to Central via API. :type variables_filename: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def update_template_variables_file(self, conn, variables_filename):
    """Update values of existing template variables and add new variables\
        to the existing set of variables for multiple devices defined in\
        the specified file.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param variables_filename: Local filename of template variables to be\
        uploaded to Central via API.
    :type variables_filename: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urls.VARIABLES["UPDATE_ALL"]

    # Open variable file in binary mode
    files = {}
    fp = None
    try:
        fp = open(variables_filename, "rb")
        files = {
            "variables": fp
        }
    except Exception as err:
        logger.error("Unable to open the variable file! " + str(err))
        return None

    resp = conn.command(apiMethod="PATCH", apiPath=path, files=files)

    # Close the file
    if fp:
        fp.close()

    return resp

replace_template_variables(conn, device_serial, variables)

Delete all existing template variables and create requested template variables for a device. This API can be used for deleting some variables out of all for a device.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of a device :type device_serial: str :param variables: Delete existing template variables for a device and replace with the new variables. :type variables: dict :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def replace_template_variables(self, conn, device_serial, variables):
    """Delete all existing template variables and create requested\
        template variables for a device. This API can be used for deleting\
        some variables out of all for a device.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of a device
    :type device_serial: str
    :param variables: Delete existing template variables for a device and\
        replace with the new variables.
    :type variables: dict
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.VARIABLES["UPDATE"],
        device_serial,
        "template_variables")
    data = {
        "variables": variables
    }
    resp = conn.command(apiMethod="PUT", apiPath=path, apiData=data)
    return resp

replace_template_variables_file(conn, variables_filename, format='JSON')

Delete all existing template variables and create requested template variables for all devices. This API can be used for deleting some variables out of all for all devices.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param variables_filename: filename of template variables to be uploaded to Central via API from local machine. :type variables_filename: str :param format: Data format of the specified file, defaults to "JSON" :type format: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def replace_template_variables_file(
        self, conn, variables_filename, format="JSON"):
    """Delete all existing template variables and create requested\
        template variables for all devices. This API can be used for\
        deleting some variables out of all for all devices.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param variables_filename: filename of template variables to be\
        uploaded to Central via API from local machine.
    :type variables_filename: str
    :param format: Data format of the specified file, defaults to "JSON"
    :type format: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urls.VARIABLES["CREATE_ALL"]
    params = {
        "format": format
    }

    # Open variable file in binary mode
    files = {}
    fp = None
    try:
        fp = open(variables_filename, "rb")
        files = {
            "variables": fp
        }
    except Exception as err:
        logger.error("Unable to open the variable file! " + str(err))
        return None

    resp = conn.command(apiMethod="PUT", apiPath=path,
                        apiParams=params, files=files)

    # Close the file
    if fp:
        fp.close()

    return resp

delete_template_variables(conn, device_serial)

Delete all existing template variables for a device

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Serial number of a device :type device_serial: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def delete_template_variables(self, conn, device_serial):
    """Delete all existing template variables for a device

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Serial number of a device
    :type device_serial: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(
        urls.VARIABLES["DELETE"],
        device_serial,
        "template_variables")
    resp = conn.command(apiMethod="DELETE", apiPath=path)
    return resp

ApSettings

Bases: object

A Python class to manage AP settings such as AP name, zonename, etc.

get_ap_settings(conn, serial_number: str)

Get existing AP settings

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param serial_number: Serial number of an AP. Example: CNBRHMV3HG :type serial_number: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_ap_settings(self, conn, serial_number: str):
    """Get existing AP settings

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param serial_number: Serial number of an AP. Example: CNBRHMV3HG
    :type serial_number: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.AP_SETTINGS["GET"], serial_number)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

update_ap_settings(conn, serial_number: str, ap_settings_data: dict)

Update Existing AP Settings

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param serial_number: Serial number of an AP. Example: CNBRHMV3HG :type serial_number: str :param ap_settings_data: Data to update ap settings.

* keyword hostname: Name string to set to the AP

* keyword ip_address: IP Address string to set to AP. Should be                set to "0.0.0.0" if AP get IP from DHCP.

* keyword zonename: Zonename string to set to AP

* keyword achannel: achannel string to set to AP

* keyword atxpower: atxpower string to set to AP

* keyword gchannel: gchannel string to set to AP

* keyword gtxpower: gtxpower string to set to AP

* keyword dot11a_radio_disable: dot11a_radio_disable string to set                to AP

* keyword dot11g_radio_disable: dot11g_radio_disable string to set                to AP

* keyword usb_port_disable: usb_port_disable string to set to AP

:type ap_settings_data: dict :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def update_ap_settings(self, conn, serial_number: str,
                       ap_settings_data: dict):
    """Update Existing AP Settings

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param serial_number: Serial number of an AP. Example: CNBRHMV3HG
    :type serial_number: str
    :param ap_settings_data: Data to update ap settings. \n
        * keyword hostname: Name string to set to the AP \n
        * keyword ip_address: IP Address string to set to AP. Should be\
            set to "0.0.0.0" if AP get IP from DHCP. \n
        * keyword zonename: Zonename string to set to AP \n
        * keyword achannel: achannel string to set to AP \n
        * keyword atxpower: atxpower string to set to AP \n
        * keyword gchannel: gchannel string to set to AP \n
        * keyword gtxpower: gtxpower string to set to AP \n
        * keyword dot11a_radio_disable: dot11a_radio_disable string to set\
            to AP \n
        * keyword dot11g_radio_disable: dot11g_radio_disable string to set\
            to AP \n
        * keyword usb_port_disable: usb_port_disable string to set to AP \n
    :type ap_settings_data: dict
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.AP_SETTINGS["UPDATE"], serial_number)
    data = ap_settings_data
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

ApConfiguration

Bases: object

A python class to manage Aruba Central access points with API's from the AP configuration category.

get_ap_config(conn, group_name)

Get whole configuration in CLI format of an UI group or AOS10 device.

:param group_name: Central group name or AOS10 AP serial number. :type group_name: str

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_ap_config(self, conn, group_name):
    """
    Get whole configuration in CLI format of an UI group or AOS10 device.

    :param group_name: Central group name or AOS10 AP serial number.
    :type group_name: str

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.AP_CONFIGURATION["GET"], group_name)
    resp = conn.command(apiMethod="GET", apiPath=path)

    return resp

replace_ap(conn, group_name, data)

Replace whole configuration for a Central UI group or AOS10 device. Configuration is in CLI format.

:param group_name: Central group name or AOS10 AP serial number. :type group_name: str :param data: AP CLI configuration commands. Format for json value is a list of CLI command strings. :type data: json

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def replace_ap(self, conn, group_name, data):
    """
    Replace whole configuration for a Central UI group or AOS10 device.
    Configuration is in CLI format.

    :param group_name: Central group name or AOS10 AP serial number.
    :type group_name: str
    :param data: AP CLI configuration commands. Format for json value
        is a list of CLI command strings.
    :type data: json

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.AP_CONFIGURATION["REPLACE"], group_name)
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)

    return resp

change_wlan_status(conn, group_name, wlan_name, new_wlan_status)

This function lets you enable or disable the specified WLAN in a UI group.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of Aruba Central group which has the WLAN :type group_name: str :param wlan_name: Name of WLAN whose status has to be changed :type wlan_name: str :param new_wlan_status: Status of WLAN - True => Enable WLAN, False => Disable WLAN :type new_wlan_status: bool

:return: True when WLAN status was updated successfully. Otherwise, it will return False :rtype: bool

Source code in pycentral/classic/configuration.py
def change_wlan_status(self, conn, group_name, wlan_name, new_wlan_status):
    """
    This function lets you enable or disable the specified WLAN in a UI \
    group. 

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of Aruba Central group which has the WLAN
    :type group_name: str
    :param wlan_name: Name of WLAN whose status has to be changed
    :type wlan_name: str
    :param new_wlan_status: Status of WLAN - True => Enable WLAN, \
    False => Disable WLAN
    :type new_wlan_status: bool

    :return: True when WLAN status was updated successfully. Otherwise, it\
        will return False
    :rtype: bool
    """
    wlan_action = "enable" if new_wlan_status else "disable"
    ap_config_resp = self.get_ap_config(conn, group_name)
    if ap_config_resp['code'] != 200:
        resp = ap_config_resp
        logger.error(
            f'Unable to {wlan_action} WLAN {wlan_name}. \nError code {resp["code"]}. Error Message - {resp["msg"]}')
        return False

    ap_config = ap_config_resp['msg']
    wlan_list = self._parse_wlans_from_ap_config(ap_config)
    if wlan_name not in wlan_list.keys():
        logger.error(
            f'Unable to find WLAN {wlan_name} in group {group_name}.\n Please provide a valid WLAN to {wlan_action}')
        return False

    new_wlan_config = self._update_wlan_status_ap_config(
        wlan_list[wlan_name]['config'], wlan_action)
    wlan_config_index = wlan_list[wlan_name]['config_start_index']
    new_ap_config = self._update_wlan_in_ap_cli_config(
        ap_config, new_wlan_config, wlan_config_index)
    ap_config_resp = self.replace_ap(
        conn, group_name=group_name, data={"clis": new_ap_config})
    if ap_config_resp['code'] == 200 and ap_config_resp['msg'] == group_name:
        logger.info(f'Successfully {wlan_action}d WLAN {wlan_name}')
        return True
    else:
        logger.error(
            f'Unable to {wlan_action} WLAN {wlan_name}. \nError code {ap_config_resp["code"]}. Error Message - {ap_config_resp["msg"]}')
        return False

Wlan()

Bases: object

A python class consisting of functions to manage Aruba Central WLANs via REST API. This class uses WLAN APIs that have to be allowlisted for the Aruba Central account

Source code in pycentral/classic/configuration.py
def __init__(self):
    logger.info(
        'The WLAN class\'s APIs have to be allowlisted for the Aruba Central account.')

create_wlan(conn, group_name, wlan_name, wlan_data)

Create new WLAN.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of Aruba Central group to create new WLAN inside. :type group_name: str :param wlan_name: Name string for new WLAN :type wlan_name: str :param wlan_data: Data to create new WLAN * keyword essid: SSID name * keyword type: type designation for new SSID * keyword hide_ssid: boolean to hide SSID * keyword vlan: vlan to add new SSID to * keyword zone: vlan zones to add SSID to * keyword opmode: SSID security opmode * keyword wpa_passphrase: Passphrase for SSID * keyword wpa_passphrase_changed: Should always be set true * keyword is_locked: Boolean * keyword captive_profile_name: name for users using captive portal * keyword bandwidth_limit_up: mb up * keyword bandwidth_limit_down: mb down * keyword bandwidth_limit_peruser_up: peruser mb up * keyword bandwidth_limit_peruser_down: peruser mb down * keyword access_rules: dict :type wlan_data: dict(json)

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def create_wlan(self, conn, group_name, wlan_name, wlan_data):
    """
    Create new WLAN.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of  Aruba Central group to create new WLAN
        inside.
    :type group_name: str
    :param wlan_name: Name string for new WLAN
    :type wlan_name: str
    :param wlan_data: Data to create new WLAN
        * keyword essid: SSID name
        * keyword type: type designation for new SSID
        * keyword hide_ssid: boolean to hide SSID
        * keyword vlan: vlan to add new SSID to
        * keyword zone: vlan zones to add SSID to
        * keyword opmode: SSID security opmode
        * keyword wpa_passphrase: Passphrase for SSID
        * keyword wpa_passphrase_changed: Should always be set true
        * keyword is_locked: Boolean
        * keyword captive_profile_name: name for users using captive portal
        * keyword bandwidth_limit_up: mb up
        * keyword bandwidth_limit_down: mb down
        * keyword bandwidth_limit_peruser_up: peruser mb up
        * keyword bandwidth_limit_peruser_down: peruser mb down
        * keyword access_rules: dict
    :type wlan_data: dict(json)

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.WLAN["CREATE"], group_name, wlan_name)
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=wlan_data)
    return resp

create_full_wlan(conn, group_name, wlan_name, wlan_data)

Create new WLAN using the full_wlan endpoint "/configuration/full_wlan/". Used for complex configurations not supported by create_wlan.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of Aruba Central group to create new WLAN inside. :type group_name: str :param wlan_name: Name string for new WLAN :type wlan_name: str :param wlan_data: Data to create new WLAN :type wlan_data: dict(json)

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def create_full_wlan(self, conn, group_name, wlan_name, wlan_data):
    """
    Create new WLAN using the full_wlan endpoint
    "/configuration/full_wlan/". Used for complex configurations not
    supported by create_wlan.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of  Aruba Central group to create new WLAN
        inside.
    :type group_name: str
    :param wlan_name: Name string for new WLAN
    :type wlan_name: str
    :param wlan_data: Data to create new WLAN
    :type wlan_data: dict(json)

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.WLAN["CREATE_FULL"], group_name, wlan_name)
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=wlan_data)
    return resp

delete_wlan(conn, group_name, wlan_name)

Delete an existing WLAN.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Group name of the group or guid of the swarm or serial number of 10x AP. :type group_name: str :param wlan_name: Name of WLAN to delete. :type wlan_name: str

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def delete_wlan(self, conn, group_name, wlan_name):
    """
    Delete an existing WLAN.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Group name of the group or guid of the swarm or
        serial number of 10x AP.
    :type group_name: str
    :param wlan_name: Name of WLAN to delete.
    :type wlan_name: str

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.WLAN["DELETE"], group_name, wlan_name)
    resp = conn.command(apiMethod="DELETE", apiPath=path)
    return resp

update_wlan(conn, group_name, wlan_name, wlan_data)

Update an existing WLAN.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Group name of the group or guid of the swarm or serial number of 10x AP :type group_name: str :param wlan_name: Name string for new WLAN :type wlan_name: str :param wlan_data: Data to update existing wlan. :type wlan_data: dict(json)

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def update_wlan(self, conn, group_name, wlan_name, wlan_data):
    """
    Update an existing WLAN.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Group name of the group or guid of the swarm or
        serial number of 10x AP
    :type group_name: str
    :param wlan_name: Name string for new WLAN
    :type wlan_name: str
    :param wlan_data: Data to update existing wlan.
    :type wlan_data: dict(json)

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.WLAN["UPDATE"], group_name, wlan_name)
    resp = conn.command(apiMethod="PUT", apiPath=path, apiData=wlan_data)
    return resp

update_full_wlan(conn, group_name, wlan_name, wlan_data)

Update an existing WLAN using the full_wlan endpoint "/configuration/full_wlan/". Used for complex configurations not supported by update_wlan.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Group name of the group or guid of the swarm or serial number of 10x AP :type group_name: str :param wlan_name: Name string for new WLAN :type wlan_name: str :param wlan_data: Data to update existing wlan. :type wlan_data: dict(json)

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def update_full_wlan(self, conn, group_name, wlan_name, wlan_data):
    """
    Update an existing WLAN using the full_wlan endpoint
    "/configuration/full_wlan/". Used for complex configurations
    not supported by update_wlan.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Group name of the group or guid of the swarm or
        serial number of 10x AP
    :type group_name: str
    :param wlan_name: Name string for new WLAN
    :type wlan_name: str
    :param wlan_data: Data to update existing wlan.
    :type wlan_data: dict(json)

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.WLAN["UPDATE_FULL"], group_name, wlan_name)
    resp = conn.command(apiMethod="PUT", apiPath=path, apiData=wlan_data)
    return resp

get_wlan(conn, group_name, wlan_name)

Gets configuration of a WLAN in a Central group.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Group name of the group or guid of the swarm. :type group_name: str :param wlan_name: Name string for wlan to get. :type wlan_name: str

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_wlan(self, conn, group_name, wlan_name):
    """
    Gets configuration of a WLAN in a Central group.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Group name of the group or guid of the swarm.
    :type group_name: str
    :param wlan_name: Name string for wlan to get.
    :type wlan_name: str

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """

    path = urlJoin(urls.WLAN["GET"], group_name, wlan_name)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

get_all_wlans(conn, group_name)

Gets a list of each wlan in a Central group.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Group name of the group or guid of the swarm. :type group_name: str

:return: Response as provided by 'command' function in class: pycentral.ArubaCentralBase. :rtype: dict

Source code in pycentral/classic/configuration.py
def get_all_wlans(self, conn, group_name):
    """
    Gets a list of each wlan in a Central group.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Group name of the group or guid of the swarm.
    :type group_name: str

    :return: Response as provided by 'command' function in class:
        `pycentral.ArubaCentralBase`.
    :rtype: dict
    """
    path = urlJoin(urls.WLAN["GET_ALL"], group_name)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

enable_wlan(conn, group_name, wlan_name)

This function will enable the WLAN for client connections.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of Aruba Central UI group which has the WLAN :type group_name: str :param wlan_name: Name of WLAN which has to be enabled :type wlan_name: str

Source code in pycentral/classic/configuration.py
def enable_wlan(self, conn, group_name, wlan_name):
    """
    This function will enable the WLAN for client connections.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of Aruba Central UI group which has the WLAN
    :type group_name: str
    :param wlan_name: Name of WLAN which has to be enabled
    :type wlan_name: str
    """
    a = ApConfiguration()
    a.change_wlan_status(conn, group_name, wlan_name, True)

disable_wlan(conn, group_name, wlan_name)

This function will disable the WLAN for client connections. Current connected clients will be disconnected from this WLAN.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: Name of Aruba Central UI group which has the WLAN :type group_name: str :param wlan_name: Name of WLAN which has to be disabled :type wlan_name: str

Source code in pycentral/classic/configuration.py
def disable_wlan(self, conn, group_name, wlan_name):
    """
    This function will disable the WLAN for client connections. Current 
    connected clients will be disconnected from this WLAN.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group_name: Name of Aruba Central UI group which has the WLAN
    :type group_name: str
    :param wlan_name: Name of WLAN which has to be disabled
    :type wlan_name: str
    """
    a = ApConfiguration()
    a.change_wlan_status(conn, group_name, wlan_name, False)

Constants

constants


Device Inventory

device_inventory

Inventory

Bases: object

A python class consisting of functions to manage Aruba Central inventory from the new device inventory category via REST API.

get_inventory(conn, sku_type='all', limit=0, offset=0)

Get device details from inventory.

:param conn: Instance of class:pycentral.ArubaCentralBase. :type conn: class:pycentral.ArubaCentralBase :param sku_type: target device sku type to pull from inventory. Acceptable arguments: all, iap, switch, controller, gateway, vgw, cap, boc, all_ap, all_controller, others. :type sku_type: str :param limit: Pagination limit. Defaults to 0, which is intrepreted as get all. Maximum limit per request is 50. :type limit: int, optional :param offset: Pagination offset, defaults to 0. :type offset: int, optional

:return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/device_inventory.py
def get_inventory(self, conn, sku_type="all", limit=0, offset=0):
    """Get device details from inventory.

    :param conn: Instance of class:`pycentral.ArubaCentralBase`.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param sku_type: target device sku type to pull from inventory.
        Acceptable arguments: all, iap, switch, controller, gateway,
        vgw, cap, boc, all_ap, all_controller, others.
    :type sku_type: str
    :param limit: Pagination limit. Defaults to 0, which is intrepreted as
        get all. Maximum limit per request is 50.
    :type limit: int, optional
    :param offset: Pagination offset, defaults to 0.
    :type offset: int, optional

    :return: HTTP Response as provided by 'command' function in
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """

    path = urls.DEVICES["GET_DEVICES"]

    # Check limit for default.
    if limit != 0:
        params = {
            "limit": limit,
            "offset": offset,
            "sku_type": sku_type
        }
    else:
        # No limit param to allow get all devices.
        params = {
            "offset": offset,
            "sku_type": sku_type
        }

    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

archive_devices(conn, device_serials=[])

Archive a list of devices using serial numbers

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serials: List of serial number of Aruba devices that should be archived :type device_serials: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/device_inventory.py
def archive_devices(self, conn, device_serials=[]):
    """Archive a list of devices using serial numbers

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serials: List of serial number of Aruba devices that\
        should be archived
    :type device_serials: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.DEVICES["ARCHIVE_DEVICES"]
    if isinstance(device_serials, str):
        device_serials = [device_serials]
    if (len(device_serials)) > MAX_DEVICES:
        logger.error(
            'Unable to archive more than {MAX_DEVICES} devices per API \
            call. Please archive {MAX_DEVICES} or less devices at a time.')
        return
    if len(device_serials) == 0:
        logger.error(
            "Unable to archive devices since no device serial numbers were\
            provided. Please provide atleast one device's details in the\
            device_serials function argument.")
        return

    apiData = {
        "serials": device_serials
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=apiData)
    # Devices in the succeeded_devices list
    successful_devices = [device["serial_number"]
                          for device in resp['msg']['succeeded_devices']]
    # Devices in the failed_devices list
    failed_devices = [device["serial_number"]
                      for device in resp['msg']['failed_devices']]
    if (resp["code"] == 200 and len(failed_devices) == 0):
        logger.info(
            f'Successfully archived devices with SN - \
                {", ".join(str(device) for device in successful_devices)}')
    elif (resp["code"] == 200 and len(failed_devices) > 0):
        logger.error(
            f'Failed to archive devices with SN - \
                {", ".join(str(device) for device in failed_devices)}')
        if (len(successful_devices) > 0):
            logger.info(
                f'Successfully unarchived devices with SN - \
                {", ".join(str(device) for device in successful_devices)}')
    else:
        logger.error(
            f'Error in API Response. Response Code - {resp["code"]}')
    return resp

unarchive_devices(conn, device_serials=[])

Unarchive a list of devices using serial numbers

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serials: List of serial number of Aruba devices that should be unarchived :type device_serials: list :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/device_inventory.py
def unarchive_devices(self, conn, device_serials=[]):
    """Unarchive a list of devices using serial numbers

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serials: List of serial number of Aruba devices that\
        should be unarchived
    :type device_serials: list
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.DEVICES["UNARCHIVE_DEVICES"]
    if isinstance(device_serials, str):
        device_serials = [device_serials]

    if (len(device_serials)) > MAX_DEVICES:
        logger.error(
            'Unable to unarchive more than {MAX_DEVICES} devices per API\
            call. Please unarchive {MAX_DEVICES} or less devices at a\
            time.')
        return
    if len(device_serials) == 0:
        logger.error("Unable to unarchive devices since no device serial \
                     numbers were provided. Please provide atleast one \
                     device's details in the device_serials function \
                     argument.")
        return

    apiData = {
        "serials": device_serials
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=apiData)
    # Devices in the succeeded_devices list
    successful_devices = [device["serial_number"]
                          for device in resp['msg']['succeeded_devices']]
    # Devices in the failed_devices list
    failed_devices = [device["serial_number"]
                      for device in resp['msg']['failed_devices']]
    if (resp["code"] == 200 and len(failed_devices) == 0):
        logger.info(
            f'Successfully unarchived devices with SN - \
            {", ".join(str(device) for device in successful_devices)}')
    elif (resp["code"] == 200 and len(failed_devices) > 0):
        logger.error(
            f'Failed to unarchive devices with SN - \
                {", ".join(str(device) for device in failed_devices)}')
        if (len(successful_devices) > 0):
            logger.info(
                f'Successfully unarchived devices with SN - \
                {", ".join(str(device) for device in successful_devices)}')
    else:
        logger.error(
            f'Error in API Response. Response Code - {resp["code"]}')
    return resp

add_devices(conn, device_details)

Add device(s) using Mac & Serial Numbers

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_details: List of dictionaries with Aruba devices that should be added to the Aruba Central account. Each item in the dictionary should have the following keys - mac & serial. For Central On-Premises account, an additional key is required in the dictionary - partNumber :type device_details: list :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/device_inventory.py
def add_devices(self, conn, device_details):
    """Add device(s) using Mac & Serial Numbers

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_details: List of dictionaries with Aruba devices that\
        should be added to the Aruba Central account. Each item in the\
        dictionary should have the following keys - `mac` & `serial`. For\
        Central On-Premises account, an additional key is required in the\
        dictionary - `partNumber`
    :type device_details: list
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if (len(device_details)) > MAX_DEVICES:
        logger.error(
            'Unable to add more than {MAX_DEVICES} devices per API call.\
            Please add {MAX_DEVICES} or less devices at a time.')
        return
    if len(device_details) == 0:
        logger.error(
            "No device details were provided. Please provide atleast one\
            device's details in the device_details function argument.")
        return

    path = urls.DEVICES["ADD_DEVICE"]
    apiData = device_details
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=apiData)
    extra_resp = None
    error_devices = []
    if 'extra' in resp['msg']:
        extra_resp = resp['msg']['extra']
    if (resp["code"] == 200):
        avail_devices = extra_resp['message']["available_device"]
        device_serials = [device["serial_number"] for device in avail_devices]
        logger.info(
            f'Successfully added devices(with SN - \
            {", ".join(str(device) for device in device_serials)}) \
            to Greenlake Device Inventory.')
    elif (resp["code"] == 400 and extra_resp is not None):
        if (extra_resp['error_code'] == 'ATHENA_ERROR_NO_DEVICE' and
                len(error_devices) > 0):
            # Devices that were in the available_list
            successful_devices = extra_resp['message']["available_device"]
            # Devices that were either on the blocked_list or invalid_list
            error_devices = extra_resp['message']['blocked_device'] + \
                extra_resp['message']['invalid_device']
            logger.error(
                'Some or all of the devices were not added to the device\
                inventory.')
            for device in error_devices:
                logger.error(
                    f'Unable to add device({device["serial"]}). Reason for\
                        error - {device["ccs_message"]}')
            for device in successful_devices:
                logger.info(
                    f'Able to add device({device["serial"]}). Reason for\
                        error - {device["ccs_message"]}')
    else:
        logger.error(
            f'Error in API Response. Response Code - {resp["code"]}, Error\
                Message - {resp["msg"]["detail"]}')
    return resp

Firmware Management

firmware_management

Firmware

A Python Class to manage Aruba Central Device Firmware via REST APIs.

list_firmware_all_swarms(conn, group=None, limit=20, offset=0)

Get a list of swarms with their firmware details. You can optionally specify a group, to filter devices under it

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group: Name of the group, defaults to None :type group: str, optional :param limit: Pagination limit. Default is 20 and max is 1000, defaults to 20 :type limit: int, optional :param offset: Pagination offset, defaults to 0 :type offset: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/firmware_management.py
def list_firmware_all_swarms(self, conn, group=None, limit=20, offset=0):
    """Get a list of swarms with their firmware details. You can \
        optionally specify a group, to filter devices under it

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group: Name of the group, defaults to None
    :type group: str, optional
    :param limit: Pagination limit. Default is 20 and max is 1000,\
        defaults to 20
    :type limit: int, optional
    :param offset: Pagination offset, defaults to 0
    :type offset: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.FIRMWARE["GET_ALL_SWARMS"]
    params = {
        "offset": offset,
        "limit": limit
    }
    if group:
        params["group"] = group
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_firmware_swarm(conn, swarm_id)

Get firmware details for specific swarm.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param swarm_id: Swarm ID for which the firmware detail to be queried :type swarm_id: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/firmware_management.py
def get_firmware_swarm(self, conn, swarm_id):
    """Get firmware details for specific swarm.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param swarm_id: Swarm ID for which the firmware detail to be queried
    :type swarm_id: str
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.FIRMWARE["GET_SWARM"], swarm_id)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

list_supported_version(conn, device_type=None, swarm_id=None, serial=None)

Get list of firmware versions for device. Specify device_type "IAP"/"MAS"/"HP"/"CONTROLLER" to get firmware versions for swarms, MAS switches, aruba switches and controllers respectively or you can specify swarm_id to get list of supported version for specific swarm or you can specify serial to get list of supported version for specific device.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_type: Specify one of "IAP/MAS/HP/CONTROLLER", defaults to None :type device_type: str, optional :param swarm_id: Swarm ID, defaults to None :type swarm_id: str, optional :param serial: Serial of device, defaults to None :type serial: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/firmware_management.py
def list_supported_version(self, conn, device_type=None, swarm_id=None,
                           serial=None):
    """Get list of firmware versions for device. Specify device_type\
        "IAP"/"MAS"/"HP"/"CONTROLLER" to get firmware versions for swarms,\
        MAS switches, aruba switches and controllers respectively or you\
        can specify swarm_id to get list of supported version for specific\
        swarm or you can specify serial to get list of supported version\
        for specific device.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_type: Specify one of "IAP/MAS/HP/CONTROLLER", defaults\
        to None
    :type device_type: str, optional
    :param swarm_id: Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param serial: Serial of device, defaults to None
    :type serial: str, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.FIRMWARE["GET_VERSIONS_IAP"]
    params = {}
    if device_type:
        params["device_type"] = device_type
    elif swarm_id:
        params["swarm_id"] = swarm_id
    elif serial:
        params["serial"] = serial
    else:
        conn.logger.error(
            "Failed to check supported formware version! \
        Missing required parameter: device_type or swarm_id or serial!")
        return None
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

check_firmware_support(conn, firmware_version, device_type)

Check whether specific firmware version is available or not. Specify device_type "IAP"/"MAS"/"HP"/"CONTROLLER" to get firmware versions for swarms/MAS switches/aruba switches/controllers respectively.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param firmware_version: Firmware Version :type firmware_version: str :param device_type: Specify one of "IAP/MAS/HP/CONTROLLER" :type device_type: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/firmware_management.py
def check_firmware_support(self, conn, firmware_version, device_type):
    """Check whether specific firmware version is available or not.\
        Specify device_type "IAP"/"MAS"/"HP"/"CONTROLLER" to get firmware\
        versions for swarms/MAS switches/aruba switches/controllers\
        respectively.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param firmware_version: Firmware Version
    :type firmware_version: str
    :param device_type: Specify one of "IAP/MAS/HP/CONTROLLER"
    :type device_type: str
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(
        urls.FIRMWARE["CHECK_VERSION_SUPPORT"],
        firmware_version)
    print("DEbug!! ", path)
    params = {
        "device_type": device_type
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

check_firmware_status(conn, serial=None, swarm_id=None)

Get firmware upgrade status of device. You can either specify swarm_id if device_type is "IAP" or serial for rest of device_type, but not both.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param serial: Serial of device, defaults to None :type serial: str, optional :param swarm_id: Swarm ID, defaults to None :type swarm_id: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/firmware_management.py
def check_firmware_status(self, conn, serial=None, swarm_id=None):
    """Get firmware upgrade status of device. You can either specify\
        swarm_id if device_type is
    "IAP" or serial for rest of device_type, but not both.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param serial: Serial of device, defaults to None
    :type serial: str, optional
    :param swarm_id: Swarm ID, defaults to None
    :type swarm_id: str, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.FIRMWARE["GET_STATUS"]
    params = {}
    if swarm_id:
        params["swarm_id"] = swarm_id
    elif serial:
        params["serial"] = serial
    else:
        conn.logger.error("Failed to Check Firmware Status! \
            Missing parameters serial or swarm_id!")
        return None
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

upgrade_firmware(conn, firmware_version, reboot=True, device_type=None, model=None, group=None, serial=None, swarm_id=None, schedule_at=None)

Upgrade firmware version for a device or for a whole group of devices under a device type, with additional filter of model. To initiate upgrade for certain type of devices of specific group, specify device_type as one of "IAP" for swarm, "MAS" for MAS switches, "HP" for aruba switches, "CONTROLLER" for controllers respectively, and group name. To upgrade a device, you can specify swarm_id to upgrade a specific swarm or serial to upgrade a specific device. To upgrade a specific model of Aruba switches at group level, please use model in request body.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param firmware_version: Specify firmware version to which you want device to upgrade. If you do not specify this field then firmware upgrade initiated with recommended firmware version :type firmware_version: str :param reboot: Use True for auto reboot after successful firmware download. Default value is False. Applicable only on MAS, Aruba switches and controller since IAP reboots automatically after firmware download., defaults to True :type reboot: bool, optional :param device_type: Specify one of "IAP/MAS/HP/CONTROLLER", defaults to None :type device_type: str, optional :param model: To initiate upgrade at group level for specific model family. Applicable only for Aruba switches, defaults to None :type model: str, optional :param group: Specify Group Name to initiate upgrade for whole group., defaults to None :type group: str, optional :param serial: Serial of device, defaults to None :type serial: str, optional :param swarm_id: Swarm ID, defaults to None :type swarm_id: str, optional :param schedule_at: Firmware upgrade will be scheduled at, firmware_scheduled_at - current time. firmware_scheduled_at is epoch in seconds and default value is current time, defaults to None :type schedule_at: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/firmware_management.py
def upgrade_firmware(self, conn, firmware_version, reboot=True,
                     device_type=None, model=None, group=None, serial=None,
                     swarm_id=None, schedule_at=None):
    """Upgrade firmware version for a device or for a whole group of\
        devices under a device type, with additional filter of model. To\
        initiate upgrade for certain type of devices of specific group,\
        specify device_type as one of "IAP" for swarm, "MAS" for MAS\
        switches, "HP" for aruba switches, "CONTROLLER" for controllers\
        respectively, and group name. To upgrade a device, you can specify\
        swarm_id to upgrade a specific swarm or serial to upgrade a\
        specific device. To upgrade a specific model of Aruba switches at\
        group level, please use model in request body.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param firmware_version: Specify firmware version to which you want\
        device to upgrade. If you do not specify this field then firmware\
        upgrade initiated with recommended firmware version
    :type firmware_version: str
    :param reboot: Use True for auto reboot after successful firmware\
        download. Default value is False. Applicable only on MAS, Aruba\
        switches and controller since IAP reboots automatically after \
        firmware download., defaults to True
    :type reboot: bool, optional
    :param device_type: Specify one of "IAP/MAS/HP/CONTROLLER", defaults\
        to None
    :type device_type: str, optional
    :param model: To initiate upgrade at group level for specific model\
        family. Applicable only for Aruba switches, defaults to None
    :type model: str, optional
    :param group: Specify Group Name to initiate upgrade for whole group.,\
        defaults to None
    :type group: str, optional
    :param serial: Serial of device, defaults to None
    :type serial: str, optional
    :param swarm_id: Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param schedule_at: Firmware upgrade will be scheduled at, \
        `firmware_scheduled_at` - current time. firmware_scheduled_at is\
        epoch in seconds and default value is current time, defaults to\
        None
    :type schedule_at: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.FIRMWARE["UPGRADE"]
    data = {
        "firmware_version": firmware_version,
        "reboot": reboot
    }
    if model:
        data["model"] = model
    if group:
        data["group"] = group
    if serial:
        data["serial"] = serial
    if device_type:
        data["device_type"] = device_type
    if swarm_id:
        data["swarm_id"] = swarm_id
    if schedule_at:
        data["firmware_scheduled_at"] = schedule_at
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

cancel_scheduled_upgrade(conn, serial=None, swarm_id=None, device_type=None, group=None)

Cancel scheduled firmware upgrade for a device or for a whole group of devices. To cancel scheduled upgrade for certain type of devices of specific group, specify device_type as one of "IAP" for swarm, "MAS" for MAS switches, "HP" for aruba switches, "CONTROLLER" for controllers respectively, and the group as the group name. To cancel scheduled upgrade a device, you can specify swarm_id of the specific swarm or serial of the specific device.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param serial: Serial of device, defaults to None :type serial: str, optional :param swarm_id: Swarm ID, defaults to None :type swarm_id: str, optional :param device_type: Specify one of "IAP/MAS/HP/CONTROLLER", defaults to None :type device_type: str, optional :param group: Specify Group Name to initiate upgrade for whole group, defaults to None :type group: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/firmware_management.py
def cancel_scheduled_upgrade(self, conn, serial=None, swarm_id=None,
                             device_type=None, group=None):
    """Cancel scheduled firmware upgrade for a device or for a whole group\
        of devices. To cancel scheduled upgrade for certain type of\
        devices of specific group, specify device_type as one of "IAP" for\
        swarm, "MAS" for MAS switches, "HP" for aruba switches,\
        "CONTROLLER" for controllers respectively, and the group as the\
        group name. To cancel scheduled upgrade a device, you can specify\
        swarm_id of the specific swarm or serial of the specific device.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param serial: Serial of device, defaults to None
    :type serial: str, optional
    :param swarm_id: Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param device_type: Specify one of "IAP/MAS/HP/CONTROLLER", defaults\
        to None
    :type device_type: str, optional
    :param group: Specify Group Name to initiate upgrade for whole group,\
        defaults to None
    :type group: str, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.FIRMWARE["CANCEL"]
    data = {}
    if serial:
        data["serial"] = serial
    if swarm_id:
        data["swarm_id"] = swarm_id
    if device_type:
        data["device_type"] = device_type
    if group:
        data["group"] = group
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

Licensing

licensing

Subscriptions

Bases: object

A python class to manage subscriptions for Aruba Central

get_user_subscription_keys(conn, license_type='', offset=0, limit=100)

This function is used to get license subscription keys

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param license_type: Accepts basic/special, defaults to "" :type license_type: str, optional :param offset: Pagination offset, defaults to 0 :type offset: int, optional :param limit: Number of subscriptions to get, defaults to 100 :type limit: int, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def get_user_subscription_keys(self, conn, license_type="", offset=0,
                               limit=100):
    """This function is used to get license subscription keys

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param license_type: Accepts basic/special, defaults to ""
    :type license_type: str, optional
    :param offset: Pagination offset, defaults to 0
    :type offset: int, optional
    :param limit: Number of subscriptions to get, defaults to 100
    :type limit: int, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["GET_KEYS"]
    params = {
        "offset": offset,
        "limit": limit
    }
    if license_type:
        params["license_type"] = license_type
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_enabled_services(conn)

This function is used to get the list of services which are enabled for customer.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def get_enabled_services(self, conn):
    """This function is used to get the list of services which are enabled\
        for customer.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["GET_ENABLED_SVC"]
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

assign_device_subscription(conn, device_serials, services)

This function is used to assign subscriptions to device by specifying its serial.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serials: List of serial number of device. :type device_serials: list :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def assign_device_subscription(self, conn, device_serials, services):
    """This function is used to assign subscriptions to device by\
        specifying its serial.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serials: List of serial number of device.
    :type device_serials: list
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["ASSIGN"]
    data = {
        "serials": device_serials,
        "services": services
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

unassign_device_subscription(conn, device_serials, services)

This function is used to unassign subscriptions to device by specifying its serial.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serials: List of serial number of device. :type device_serials: list :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def unassign_device_subscription(self, conn, device_serials, services):
    """This function is used to unassign subscriptions to device by\
        specifying its serial.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serials: List of serial number of device.
    :type device_serials: list
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["UNASSIGN"]
    data = {
        "serials": device_serials,
        "services": services
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

get_user_subscription_status(conn, license_type='all', service='')

This function is used to return subscription stats.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param license_type: basic/special/all. special - will fetch the statistics of special central services like presence analytics(pa), ucc, clarity etc basic - will fetch the statistics of device management service licenses, all - will fetch both of these license types, defaults to "all" :type license_type: str, optional :param service: Service type: pa/pa,clarity etc, defaults to "" :type service: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def get_user_subscription_status(self, conn, license_type="all",
                                 service=""):
    """This function is used to return subscription stats.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param license_type: basic/special/all. special - will fetch the\
        statistics of special central services like presence\
        analytics(pa), ucc, clarity etc basic - will fetch the statistics\
        of device management service licenses, all - will fetch both of\
        these license types, defaults to "all"
    :type license_type: str, optional
    :param service: Service type: pa/pa,clarity etc, defaults to ""
    :type service: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["GET_STATS"]
    params = {}
    if license_type:
        params["license_type"] = license_type
    if service:
        params["service"] = service
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_services_license_config(conn, service_category='', device_type='')

This function is used to return services configuration for licensing purpose.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param service_category: Service category - dm/network, defaults to "" :type service_category: str, optional :param device_type: Device Type - iap/switch, defaults to "" :type device_type: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def get_services_license_config(self, conn, service_category="",
                                device_type=""):
    """This function is used to return services configuration for\
        licensing purpose.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param service_category: Service category - dm/network, defaults to ""
    :type service_category: str, optional
    :param device_type: Device Type - iap/switch, defaults to ""
    :type device_type: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["GET_LIC_SVC"]
    params = {}
    if service_category:
        params["service_category"] = service_category
    if device_type:
        params["device_type"] = device_type
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

assign_subscription_all(conn, services)

This function is used to assign licenses to all devices for given services.

Note: This API is not applicable for MSP customer

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def assign_subscription_all(self, conn, services):
    """This function is used to assign licenses to all devices for given\
        services. \n
    Note: This API is not applicable for MSP customer

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["ASSIGN_LIC"]
    data = {
        "services": services
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

unassign_subscription_all(conn, services)

This function is used to unassign licenses to all devices for given services.

Note: This API is not applicable for MSP customer

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def unassign_subscription_all(self, conn, services):
    """This function is used to unassign licenses to all devices for given\
        services.\n
    Note: This API is not applicable for MSP customer

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["UNASSIGN_LIC"]
    data = {
        "services": services
    }
    resp = conn.command(apiMethod="DELETE", apiPath=path, apiData=data)
    return resp

assign_msp_subscription_all(conn, services, include_customers=[], exclude_customers=[])

Assign licenses to all devices owned by tenant customers for given services. If include_customers and exclude_customers parameters are not provided, licenses will be assigned for all customers(MSP, tenants) devices.

Note: License assignment is not supported for the MSP owned devices. Since it is a background job, please wait for few minutes for all devices to be subscribed in case of customer having large number of devices

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :param include_customers: if provided, licenses will be assigned only for the customers present in include_customers list

(Exception: License assignment will be ignored for MSP owned             devices), default=[]

:type include_customers: list, optional :param exclude_customers: if provided, licenses will be assigned for MSP/tenant customers except the customers present in exclude_customers list, default=[] :type exclude_customers: list, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def assign_msp_subscription_all(self, conn, services, include_customers=[],
                                exclude_customers=[]):
    """Assign licenses to all devices owned by tenant customers for given\
    services. If include_customers and exclude_customers parameters are\
    not provided, licenses will be assigned for all customers(MSP, \
    tenants) devices. \n
    Note: License assignment is not supported for the MSP owned devices.\
    Since it is a background job, please wait for few minutes for all\
    devices to be subscribed in case of customer having large number of\
    devices

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :param include_customers:  if provided, licenses will be assigned only\
        for the customers present in include_customers list\n
        (Exception: License assignment will be ignored for MSP owned \
        devices), default=[]
    :type include_customers: list, optional
    :param exclude_customers:  if provided, licenses will be assigned for\
        MSP/tenant customers except the customers present in\
        exclude_customers list, default=[]
    :type exclude_customers: list, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["ASSIGN_LIC_MSP"]
    data = {
        "services": services
    }
    if include_customers:
        data["include_customers"] = include_customers
    if exclude_customers:
        data["exclude_customers"] = exclude_customers
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

unassign_msp_subscription_all(conn, services, include_customers=[], exclude_customers=[])

Remove service licenses to all devices the devices owned by tenant and MSP. However license assignment is not supported for the MSP owned devices but un-assignment is supported for the customers who are transitioning from Non-MSP to MSP mode to release license quantity for better utilization.

Note: If include_customers and exclude_customers parameters are not provided, licenses will be unassigned for all customers(MSP, tenants) devices.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :param include_customers: if provided, licenses will be unassigned only for the customers present in include_customers list.

(Exception: License assignment will be ignored for MSP owned             devices), default=[]

:type include_customers: list, optional :param exclude_customers: if provided, licenses will be unassigned for MSP/tenant customers except the customers present in exclude_customers list, default=[] :type exclude_customers: list, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def unassign_msp_subscription_all(self, conn, services,
                                  include_customers=[],
                                  exclude_customers=[]):
    """Remove service licenses to all devices the devices owned by tenant\
    and MSP. However license assignment is not supported for the MSP owned\
    devices but un-assignment is supported for the customers who are\
    transitioning from Non-MSP to MSP mode to release license quantity for\
    better utilization. \n

    Note: If include_customers and exclude_customers parameters are not\
    provided, licenses will be unassigned for all customers(MSP, tenants)\
    devices.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :param include_customers:  if provided, licenses will be unassigned\
        only for the customers present in include_customers list.\n
        (Exception: License assignment will be ignored for MSP owned \
        devices), default=[]
    :type include_customers: list, optional
    :param exclude_customers:  if provided, licenses will be unassigned\
        for MSP/tenant customers except the customers present in\
        exclude_customers list, default=[]
    :type exclude_customers: list, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SUBSCRIPTIONS["UNASSIGN_LIC_MSP"]
    data = {
        "services": services
    }
    if include_customers:
        data["include_customers"] = include_customers
    if exclude_customers:
        data["exclude_customers"] = exclude_customers
    resp = conn.command(apiMethod="DELETE", apiPath=path, apiData=data)
    return resp

AutoLicense

Bases: object

A python class to manage auto-licenses for Aruba Central

disable_autolicensing_services(conn, services)

This function is used to disable auto licensing. Note: This API is not applicable for MSP customer

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def disable_autolicensing_services(self, conn, services):
    """This function is used to disable auto licensing.
    Note: This API is not applicable for MSP customer

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.AUTO_LICENSE["DISABLE_SVC"]
    data = {
        "services": services
    }
    resp = conn.command(apiMethod="DELETE", apiPath=path, apiData=data)
    return resp

get_autolicense_services(conn)

This function is used to get services which are auto enabled.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def get_autolicense_services(self, conn):
    """This function is used to get services which are auto enabled.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.AUTO_LICENSE["GET_SVC"]
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

assign_autolicense_services(conn, services)

This function is used to assign licenses to all devices for given services and enable auto licensing.

Note: This API is not applicable for MSP customer

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def assign_autolicense_services(self, conn, services):
    """This function is used to assign licenses to all devices for given\
        services and enable auto licensing. \n
        Note: This API is not applicable for MSP customer

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.AUTO_LICENSE["ASSIGN_LIC_SVC"]
    data = {
        "services": services
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

disable_msp_autolicense_services(conn, services, include_customers=[], exclude_customers=[])

Disable auto license settings for MSP and Tenants for the given services. This will not change the current license device mapping

Note: If include_customers and exclude_customers are not provided then auto license setting will be disabled for all customers i.e MSP and tenants.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :param include_customers: if provided, licensing will be disable only for the customers present in include_customers list, defaults to [] :type include_customers: list, optional :param exclude_customers: if provided, licensing will be disabled for the customers except the customers present in exclude_customers list, defaults to [] :type exclude_customers: list, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def disable_msp_autolicense_services(self, conn, services,
                                     include_customers=[],
                                     exclude_customers=[]):
    """Disable auto license settings for MSP and Tenants for the given\
        services. This will not change the current
    license device mapping

    Note: If include_customers and exclude_customers are not provided then\
        auto license setting will be disabled
    for all customers i.e MSP and tenants.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :param include_customers: if provided, licensing will be disable only\
        for the customers present in include_customers list, defaults to []
    :type include_customers: list, optional
    :param exclude_customers: if provided, licensing will be disabled for\
        the customers except the customers present in exclude_customers\
        list, defaults to []
    :type exclude_customers: list, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.AUTO_LICENSE["DISABLE_LIC_SVC_MSP"]
    data = {
        "services": services
    }
    if include_customers:
        data["include_customers"] = include_customers
    if exclude_customers:
        data["exclude_customers"] = exclude_customers
    resp = conn.command(apiMethod="DELETE", apiPath=path, apiData=data)
    return resp

get_msp_autolicense_services(conn, customer_id: str)

[summary]

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_id: Customer id of msp or tenant. :type customer_id: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def get_msp_autolicense_services(self, conn, customer_id: str):
    """[summary]

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param customer_id: Customer id of msp or tenant.
    :type customer_id: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.AUTO_LICENSE["GET_LIC_SVC_MSP"]
    params = {
        "customer_id": customer_id
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

assign_msp_autolicense_services(conn, services, include_customers=[], exclude_customers=[])

Enable auto license settings for MSP and Tenants. Assign licenses for given services to all the devices owned by tenant customers.

Note - License assignment is not supported for the MSP owned devices. License assignment will be in paused state if the total license tokens are less than total device counts(including MSP and tenants)

Note: If include_customers and exclude_customers are not provided then license settings will be enabled for all customers i.e MSP, tenants and future tenants(Note: Newly created tenant will be inherited license settings from MSP)

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param services: List of service names. Call services/config API to get the list of valid service names. :type services: list :param include_customers: if provided, license settings will be enabled only for the customers present in include_customers list., defaults to [] :type include_customers: list, optional :param exclude_customers: if provided, license settings will be enabled for customers except the customers present in exclude_customers list, defaults to [] :type exclude_customers: list, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def assign_msp_autolicense_services(self, conn, services,
                                    include_customers=[],
                                    exclude_customers=[]):
    """Enable auto license settings for MSP and Tenants. Assign licenses\
    for given services to all the devices owned by tenant customers.\n
    Note - License assignment is not supported for the MSP owned devices.\
    License assignment will be in paused state if the total license tokens\
    are less than total device counts(including MSP and tenants)

    Note: If include_customers and exclude_customers are not provided then\
    license settings will be enabled for all customers i.e MSP, tenants\
    and future tenants(Note: Newly created tenant will be inherited\
    license settings from MSP)

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param services: List of service names. Call services/config API to\
        get the list of valid service names.
    :type services: list
    :param include_customers: if provided, license settings will be\
        enabled only for the customers present
        in include_customers list., defaults to []
    :type include_customers: list, optional
    :param exclude_customers: if provided, license settings will be\
        enabled for customers except the customers present in\
        exclude_customers list, defaults to []
    :type exclude_customers: list, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.AUTO_LICENSE["ASSIGN_LIC_SVC_MSP"]
    data = {
        "services": services
    }
    if include_customers:
        data["include_customers"] = include_customers
    if exclude_customers:
        data["exclude_customers"] = exclude_customers
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

get_license_status(conn, service_name: str)

Get services and corresponding license token availability status. If True, license tokens are more than device count else less than device count.(Note - Autolicense is in paused state when license tokens are less than device count)

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param service_name: Specific service name(dm/pa/..). Call services/config API to get the list of valid service names. :type service_name: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/licensing.py
def get_license_status(self, conn, service_name: str):
    """Get services and corresponding license token availability status.\
    If True, license tokens are more than device count else less than\
    device count.(Note - Autolicense is in paused state when license\
    tokens are less than device count)

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param service_name: Specific service name(dm/pa/..). Call\
        services/config API to get the list of valid service names.
    :type service_name: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(
        urls.AUTO_LICENSE["GET_SVC_LIC_TOK"],
        service_name,
        "status")
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

Monitoring

monitoring

Sites

Bases: object

A python class consisting of functions to manage Aruba Central Sites via REST API

get_sites(conn, calculate_total=False, offset=0, limit=100, sort='+site_name')

Get list of sites

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param calculate_total: Whether to calculate total number of sites, defaults to False :type calculate_total: bool, optional :param offset: Pagination offset, defaults to 0 :type offset: int, optional :param limit: Pagination limit with Max 1000, defaults to 100 :type limit: int, optional :param sort: Sort list of sites based on one of '+site_name', '-site_name', defaults to "+site_name" :type sort: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/monitoring.py
def get_sites(self, conn, calculate_total=False, offset=0, limit=100,
              sort="+site_name"):
    """Get list of sites

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param calculate_total: Whether to calculate total number of sites,\
        defaults to False
    :type calculate_total: bool, optional
    :param offset: Pagination offset, defaults to 0
    :type offset: int, optional
    :param limit: Pagination limit with Max 1000, defaults to 100
    :type limit: int, optional
    :param sort: Sort list of sites based on one of '+site_name',\
        '-site_name', defaults to "+site_name"
    :type sort: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SITES["GET_ALL"]
    params = {
        "offset": offset,
        "limit": limit,
        "calculate_total": calculate_total,
        "sort": sort
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

create_site(conn, site_name, site_address={}, geolocation={})

Creates a new site

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param site_name: Name of the site be created. :type site_name: str :param site_address: Address of the site, defaults to {}

* keyword address: Site address string

* keyword city: City name string

* keyword state: State name string

* keyword country: Country name string

* keyword zipcode: Zipcode string

:type site_address: dict, optional :param geolocation: Mutually exclusive with site address. Provide either one option, defaults to {}

* keyword latitude: Site location latitude in the world map

* keyword longitude: Site location longitude in the world map

:type geolocation: dict, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/monitoring.py
def create_site(self, conn, site_name, site_address={}, geolocation={}):
    """Creates a new site

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param site_name: Name of the site be created.
    :type site_name: str
    :param site_address: Address of the site, defaults to {} \n
        * keyword address: Site address string \n
        * keyword city: City name string \n
        * keyword state: State name string \n
        * keyword country: Country name string \n
        * keyword zipcode: Zipcode string \n
    :type site_address: dict, optional
    :param geolocation: Mutually exclusive with site address. Provide\
        either one option, defaults to {} \n
        * keyword latitude: Site location latitude in the world map \n
        * keyword longitude: Site location longitude in the world map \n
    :type geolocation: dict, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SITES["CREATE"]
    if not site_address and not geolocation:
        logger.error(
            "Site {} Creation Error.. \
                Pass Address OR Geolocation!".format(site_name))
        return None

    if site_address and geolocation:
        logger.error(
            "Site {} Creation Error.. Pass Address OR Geolocation,\
                Not Both!".format(site_name))
        return None

    data = self._build_site_payload(
        site_name=site_name,
        site_address=site_address,
        geolocation=geolocation)
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

update_site(conn, site_id, site_name, site_address={}, geolocation={})

Update/Modify an existing site

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param site_id: ID assigned by Aruba Central when the site is created. Can be obtained from find_site_id function. :type site_id: int :param site_name: Name of the site be created. :type site_name: str :param site_address: Address of the site, defaults to {}

* keyword address: Site address string

* keyword city: City name string

* keyword state: State name string

* keyword country: Country name string

* keyword zipcode: Zipcode string

:type site_address: dict, optional :param geolocation: Mutually exclusive with site address. Provide either one option, defaults to {}

* keyword latitude: Site location latitude in the world map

* keyword longitude: Site location longitude in the world map

:type geolocation: dict, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/monitoring.py
def update_site(self, conn, site_id, site_name, site_address={},
                geolocation={}):
    """Update/Modify an existing site

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param site_id: ID assigned by Aruba Central when the site is created.\
        Can be obtained from find_site_id function.
    :type site_id: int
    :param site_name: Name of the site be created.
    :type site_name: str
    :param site_address: Address of the site, defaults to {} \n
        * keyword address: Site address string \n
        * keyword city: City name string \n
        * keyword state: State name string \n
        * keyword country: Country name string \n
        * keyword zipcode: Zipcode string \n
    :type site_address: dict, optional
    :param geolocation: Mutually exclusive with site address. Provide\
        either one option, defaults to {} \n
        * keyword latitude: Site location latitude in the world map \n
        * keyword longitude: Site location longitude in the world map \n
    :type geolocation: dict, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.SITES["UPDATE"], str(site_id))
    if not site_address and not geolocation:
        logger.error(
            "Site {} Update Error.. \
                Pass Address OR Geolocation!".format(site_name))
        return None

    if site_address and geolocation:
        logger.error(
            "Site {} Update Error.. Pass Address OR Geolocation, \
                Not Both!".format(site_name))
        return None

    data = self._build_site_payload(
        site_name=site_name,
        site_address=site_address,
        geolocation=geolocation)
    resp = conn.command(apiMethod="PATCH", apiPath=path, apiData=data)
    return resp

delete_site(conn, site_id)

Delete an existing site

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param site_id: ID assigned by Aruba Central when the site is created. Can be obtained from find_site_id function. :type site_id: int :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/monitoring.py
def delete_site(self, conn, site_id):
    """Delete an existing site

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param site_id: ID assigned by Aruba Central when the site is created.\
        Can be obtained from find_site_id function.
    :type site_id: int
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.SITES["DELETE"], str(site_id))
    resp = conn.command(apiMethod="DELETE", apiPath=path)
    return resp

associate_devices(conn, site_id, device_type, device_ids)

Associate multiple devices to a site

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param site_id: ID assigned by Aruba Central when the site is created. Can be obtained from find_site_id function. :type site_id: int :param device_type: Type of the device. One of the "IAP", "ArubaSwitch", "CX", "MobilityController". :type device_type: str :param device_ids: List of Aruba devices' serial number :type device_ids: list :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/monitoring.py
def associate_devices(self, conn, site_id, device_type, device_ids):
    """Associate multiple devices to a site

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param site_id: ID assigned by Aruba Central when the site is created.\
        Can be obtained from find_site_id function.
    :type site_id: int
    :param device_type: Type of the device. One of the "IAP",\
        "ArubaSwitch", "CX", "MobilityController".
    :type device_type: str
    :param device_ids: List of Aruba devices' serial number
    :type device_ids: list
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SITES["ADD_DEVICES"]
    if isinstance(device_ids, str):
        device_ids = [device_ids]
    data = self._build_site_devices_payload(
        site_id=site_id, device_type=device_type, device_ids=device_ids)
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

unassociate_devices(conn, site_id, device_type, device_ids)

Unassociate a device from a site

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param site_id: ID assigned by Aruba Central when the site is created. Can be obtained from find_site_id function. :type site_id: int :param device_type: Type of the device. One of the "IAP", "ArubaSwitch", "CX", "MobilityController". :type device_type: str :param device_id: Aruba device serial number :type device_id: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/monitoring.py
def unassociate_devices(self, conn, site_id, device_type, device_ids):
    """Unassociate a device from a site

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param site_id: ID assigned by Aruba Central when the site is created.\
        Can be obtained
        from find_site_id function.
    :type site_id: int
    :param device_type: Type of the device. One of the "IAP",\
        "ArubaSwitch", "CX", "MobilityController".
    :type device_type: str
    :param device_id: Aruba device serial number
    :type device_id: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.SITES["DELETE_DEVICES"]
    if isinstance(device_ids, str):
        device_ids = [device_ids]
    data = self._build_site_devices_payload(
        site_id=site_id, device_type=device_type, device_ids=device_ids)
    resp = conn.command(apiMethod="DELETE", apiPath=path, apiData=data)
    return resp

find_site_id(conn, site_name)

Find site id from site name

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param site_name: Name of the site be created. :type site_name: str :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/monitoring.py
def find_site_id(self, conn, site_name):
    """Find site id from site name

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param site_name: Name of the site be created.
    :type site_name: str
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    max_limit_size = 1000
    total_count = 0
    pagination_check = True
    offset = 0
    count = 0

    while pagination_check:
        resp = self.get_sites(conn, offset=offset, limit=max_limit_size)
        if resp and "msg" in resp and "sites" in resp["msg"]:
            resp = resp["msg"]
            count = resp["count"]
            total_count = total_count + count
            offset = offset + count

            if total_count == resp["total"]:
                pagination_check = False

            for site in resp["sites"]:
                if site["site_name"] == site_name:
                    return site["site_id"]

    return None

MSP

msp

MSP

Bases: object

A python class consisting of functions to manage Aruba Central's MSP mode via REST API

get_customers(conn, offset=0, limit=100, customer_name=None)

This function returns the list of customers based on the provided parameters

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param offset: Pagination start index, defaults to 0 :type offset: int, optional :param limit: Pagination end index, defaults to 100 :type limit: int, optional :param customer_name: Filter on customer name, defaults to None. :type customer_name: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def get_customers(self, conn, offset=0, limit=100, customer_name=None):
    """This function returns the list of customers based on the provided \
        parameters

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param offset: Pagination start index, defaults to 0
    :type offset: int, optional
    :param limit: Pagination end index, defaults to 100
    :type limit: int, optional
    :param customer_name: Filter on customer name, defaults to None.
    :type customer_name: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    apiPath = urls.MSP["V1_CUSTOMER"]
    apiParams = {
        "offset": offset,
        "limit": limit
    }
    if customer_name is not None:
        apiParams['customer_name'] = customer_name
    resp = conn.command(apiMethod="GET",
                        apiPath=apiPath,
                        apiParams=apiParams)
    if resp['code'] == 200:
        log_message = 'Successfully fetched list of customers based on' \
            ' the provided API parameters'
        logger.info(log_message)
    return resp

get_all_customers(conn)

This function returns a list of all the customers in the MSP account

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :return: Returns list of dictionaries. Each dictionary has the following keys associated with a customer - account_status, account_type, ap_config_diff, application_id, application_instance_id, created_at, customer_id, customer_name, description, device_quota, hppc_config_diff, lock_msp_ssids, msp_conversion_status, msp_id, platform_customer_details, platform_customer_id, provision_status, region, switch_config_diff, updated_at, username :rtype: list

Source code in pycentral/classic/msp.py
def get_all_customers(self, conn):
    """This function returns a list of all the customers in the MSP \
        account

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :return: Returns list of dictionaries. Each dictionary has the\
        following keys associated with a customer - account_status,\
        account_type, ap_config_diff, application_id,\
        application_instance_id, created_at, customer_id, customer_name,\
        description, device_quota, hppc_config_diff, lock_msp_ssids,\
        msp_conversion_status, msp_id, platform_customer_details,\
        platform_customer_id, provision_status, region, switch_config_diff,\
        updated_at, username
    :rtype: list
    """
    offset = 0
    limit = 100
    customer_list = []
    while True:
        resp = self.get_customers(conn, offset=offset, limit=limit)
        if resp['code'] == 200:
            resp_message = resp['msg']
            resp_customers = resp_message['customers']
            if (len(resp_customers) > 0):
                customer_list.extend(resp_customers)
            if resp_message['total'] == len(customer_list):
                break
        else:
            log_message = f'Response code {resp["code"]}. ' \
                'Error in fetching list of customers.'
            logger.error(log_message)
            return
        offset += limit
    return customer_list

create_customer(conn, customer_details)

This function creates a customer in the MSP account based on the provided customer details

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_details: Details of customer that has to be created. The customer details should have the following the keys - customer_name, country_name, street_address, city, state, country_name, zip_postal_code. These keys are optional - lock_msp_ssids, description, group_name :type customer_details: dict :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def create_customer(self, conn, customer_details):
    """This function creates a customer in the MSP account based on the \
        provided customer details

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param customer_details: Details of customer that has to be created. \
        The customer details should have the following the keys -\
        customer_name, country_name, street_address, city, state,\
        country_name, zip_postal_code. These keys are optional - \
        lock_msp_ssids, description, group_name
    :type customer_details: dict
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    apiPath = urls.MSP["V2_CUSTOMER"]
    if self.__validate_customer_attributes__(customer_details):
        customer_apiData = self.__create_customer_body__(
            conn, customer_details)
        resp = conn.command(apiMethod="POST",
                            apiPath=apiPath,
                            apiData=customer_apiData)
        if resp['code'] == 201:
            logger.info(
                f'Successfully created customer {customer_details["name"]}')
        return resp

__validate_customer_attributes__(customer_details)

This function verifies the customer details to ensure that the necessary parameters for the "create customer" API are present in the customer details body. :param customer_details: Details of customer that has to be created. The customer details should have the following the keys - customer_name, country_name, street_address, city, state, country_name, zip_postal_code. These keys are optional - lock_msp_ssids, description, group_name :type customer_details: dict :return: True when the necessary parameters are available in the customer details. :rtype: bool

Source code in pycentral/classic/msp.py
def __validate_customer_attributes__(self, customer_details):
    """This function verifies the customer details to ensure that the\
        necessary parameters for the "create customer" API are present in\
        the customer details body.
    :param customer_details: Details of customer that has to be created. \
        The customer details should have the following the keys -\
        customer_name, country_name, street_address, city, state,\
        country_name, zip_postal_code. These keys are optional - \
        lock_msp_ssids, description, group_name
    :type customer_details: dict
    :return: True when the necessary parameters are available in the\
        customer details.
    :rtype: bool
    """
    required_keys = ["customer_name", "country_name", "street_address",
                     "city", "state", "country_name", "zip_postal_code"]
    missingKey = True
    for key in required_keys:
        if key not in customer_details:
            log_message = f'Missing required key {key} & value in customer'\
                'details. Please add the missing key before calling the function.'
            logger.error(log_message)
            missingKey = False
    return missingKey

__create_customer_body__(conn, customer_details)

This function creates the create customer API's body :param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_details: Details of customer that has to be created. The customer details should have the following the keys - customer_name, country_name, street_address, city, state, country_name, zip_postal_code. These keys are optional - lock_msp_ssids, description, group_name :type customer_details: dict :return: Dictionary that has the customer details structured for the customer API body :rtype: dict

Source code in pycentral/classic/msp.py
def __create_customer_body__(self, conn, customer_details):
    """This function creates the create customer API's body\

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param customer_details: Details of customer that has to be created. \
        The customer details should have the following the keys -\
        customer_name, country_name, street_address, city, state,\
        country_name, zip_postal_code. These keys are optional - \
        lock_msp_ssids, description, group_name
    :type customer_details: dict
    :return: Dictionary that has the customer details structured for the\
        customer API body
    :rtype: dict
    """
    if (len(customer_details["country_name"]) > 2):
        country_code = self.get_country_code(
            conn, customer_details["country_name"])
        if country_code is not None:
            customer_details["country_name"] = self.get_country_code(
                conn, customer_details["country_name"])
        else:
            log_message = f'Unable to find {customer_details["country_name"]}.'\
                "Please provide a valid country name. Please check out " \
                "get_country_codes_list function to get list of valid " \
                "countries/country codes"
            logger.error(log_message)
            return

    customer_JSON = {
        "customer_name": customer_details['customer_name'],
        "description": "",
        "lock_msp_ssids": False,
        "address": {
            "street_address": customer_details['street_address'],
            "city": customer_details['city'],
            "state": customer_details['state']
        },
        "country_name": customer_details['country_name'],
        "zip_postal_code": customer_details['zip_postal_code']
    }
    optional_keys = ["lock_msp_ssids", "description"]
    for key in optional_keys:
        if key in customer_details:
            customer_JSON[key] = customer_details[key]

    if 'group_name' in customer_details and len(
            customer_details['group_name']) > 0:
        customer_JSON['group'] = {
            "name": customer_details['group_name'],
        }
    return customer_JSON

update_customer(conn, customer_details, customer_id=None, customer_name=None)

This function updates the details of an existing customer in the MSP account

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_details: Details of customer that has to be updated. The customer details should have the following the keys - customer_name, country_name, street_address, city, state, country_name, zip_postal_code. These keys are optional - lock_msp_ssids, description, group_name :type customer_details: dict :param customer_id: Customer ID of the customer, defaults to None. :type customer_id: str, optional
:param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def update_customer(
        self,
        conn,
        customer_details,
        customer_id=None,
        customer_name=None):
    """This function updates the details of an existing customer in the \
        MSP account

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param customer_details: Details of customer that has to be updated. \
        The customer details should have the following the keys -\
        customer_name, country_name, street_address, city, state,\
        country_name, zip_postal_code. These keys are optional - \
        lock_msp_ssids, description, group_name
    :type customer_details: dict
    :param customer_id: Customer ID of the customer, defaults to None.
    :type customer_id: str, optional        
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if customer_details is None:
        logger.error("Attribute Error. Please pass in customer details")
        return

    if customer_id is None and customer_name is None:
        logger.error(
            "Attribute Error. Pass either customer_id or customer_name")
        return

    elif customer_id is None and customer_name:
        customer_id = self.get_customer_id(
            conn, customer_name=customer_name)
        if customer_id is None:
            log_message = 'Unable to get customer_id. Please provide a ' \
                'valid customer name'
            logger.error(log_message)
            return

    if self.__validate_customer_attributes__(customer_details):
        customer_apiData = self.__create_customer_body__(
            conn, customer_details)
        apiPath = f'{urls.MSP["V2_CUSTOMER"]}/{customer_id}'
        resp = conn.command(
            apiMethod="PUT",
            apiPath=apiPath,
            apiData=customer_apiData)
        if resp['code'] == 200:
            logger.info(
                f'Successfully updated customer {customer_details["customer_name"]}')
        return resp

delete_customer(conn, customer_id=None, customer_name=None)

This function deletes the customer in the MSP account

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_id: Customer ID of the customer, defaults to None. :type customer_id: str, optional
:param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def delete_customer(self, conn, customer_id=None, customer_name=None):
    """This function deletes the customer in the MSP account

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param customer_id: Customer ID of the customer, defaults to None.
    :type customer_id: str, optional        
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if customer_id is None and customer_name is None:
        logger.error(
            "Attribute Error. Pass either customer_id or customer_name")
        return
    elif customer_id is None and customer_name:
        customer_id = self.get_customer_id(
            conn, customer_name=customer_name)
        if customer_id is None:
            logger.error(
                'Unable to get customer_id. Please provide a valid customer name')
            return

    apiPath = f'{urls.MSP["V1_CUSTOMER"]}/{customer_id}'
    resp = conn.command(apiMethod="DELETE", apiPath=apiPath)
    if resp['code'] == 200:
        logger.info(
            f'Successfully deleted customer with customer-id - {customer_id}')
    return resp

get_customer_details(conn, customer_id=None, customer_name=None)

This function fetches the details of the customer in the MSP account

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_id: Customer ID of the customer, defaults to None. :type customer_id: str, optional
:param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def get_customer_details(self, conn, customer_id=None, customer_name=None):
    """This function fetches the details of the customer in the MSP account

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param customer_id: Customer ID of the customer, defaults to None.
    :type customer_id: str, optional        
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if customer_id is None and customer_name is None:
        logger.error(
            "Attribute Error. Pass either customer_id or customer_name")
        return None

    elif customer_id is None and customer_name:
        customer_id = self.get_customer_id(
            conn, customer_name=customer_name)
        if customer_id is None:
            logger.error(
                'Unable to get customer_id. Please provide a valid customer name')
            return

    apiPath = f'{urls.MSP["V1_CUSTOMER"]}/{customer_id}'
    resp = conn.command(apiMethod="GET", apiPath=apiPath)
    if (resp["code"] == 200):
        log_message = "Successfully fetched details of customer with " \
            f"customer-id - {customer_id}"
        logger.info(log_message)
    return resp

get_customer_id(conn, customer_name=None)

This function fetches the customer id of the customer based on the customer name.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase
:param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :return: Customer ID of the customer. It will return None if no customer is found :rtype: string

Source code in pycentral/classic/msp.py
def get_customer_id(self, conn, customer_name=None):
    """This function fetches the customer id of the customer based on the\
        customer name.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`      
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :return: Customer ID of the customer. It will return None if no\
        customer is found
    :rtype: string
    """
    if not customer_name:
        log_message = 'Unable to find customer ID when no customer name is '\
            'passed. Please provide a valid customer name'
        logger.error(log_message)
        return None

    apiPath = urls.MSP["V1_CUSTOMER"]
    apiParams = {
        "customer_name": customer_name
    }
    resp = conn.command(
        apiMethod="GET",
        apiPath=apiPath,
        apiParams=apiParams)
    if (resp["code"] == 200 and len(resp['msg']['customers']) > 0):
        for customer in resp['msg']['customers']:
            if customer['customer_name'] == customer_name:
                return resp['msg']['customers'][0]['customer_id']
    logger.error(f'Unable to find customer_id of {customer_name}.')
    return None

get_msp_id(conn)

This function fetches the MSP ID of the MSP.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase
:return: MSP ID of the MSP account. It will return None if no ID is found :rtype: string

Source code in pycentral/classic/msp.py
def get_msp_id(self, conn):
    """This function fetches the MSP ID of the MSP.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`      
    :return: MSP ID of the MSP account. It will return None if no\
        ID is found
    :rtype: string
    """
    customer_response = self.get_customers(conn, offset=0, limit=100)
    customer_list = customer_response['msg']['customers']
    for customer in customer_list:
        if 'msp_id' in customer:
            return customer['msp_id']
    return None

get_country_code(conn, country_name)

This function fetches the country code of a country. This country code is needed for the Create Customer API

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase
:param country_name: Name of country :type country_name: str :return: Country Code of country. It will return None if no country is found :rtype: string

Source code in pycentral/classic/msp.py
def get_country_code(self, conn, country_name):
    """This function fetches the country code of a country. This country\
        code is needed for the Create Customer API

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`      
    :param country_name: Name of country
    :type country_name: str
    :return: Country Code of country. It will return None if no\
        country is found
    :rtype: string
    """
    country_list = self.get_country_codes_list(conn)['msg']
    if country_name in country_list:
        return country_list[country_name]
    return None

get_country_codes_list(conn)

This function fetches the dictionary of the country codes of countries. The keys of the dictionary are the country names and the values are the country codes

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase
:return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def get_country_codes_list(self, conn):
    """This function fetches the dictionary of the country codes of countries. \
        The keys of the dictionary are the country names and the values\
        are the country codes

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`  
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    apiPath = urls.MSP["COUNTRY_CODE"]
    resp = conn.command(apiMethod="GET", apiPath=apiPath)
    if resp['code'] == 200:
        logger.info('Successfully fetched country code list')
    return resp

get_msp_users(conn, offset=0, limit=10)

This function returns the list of users under the MSP account based on the provided parameters

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param offset: Pagination start index, defaults to 0 :type offset: int, optional :param limit: Pagination end index, defaults to 10 :type limit: int, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def get_msp_users(self, conn, offset=0, limit=10):
    """This function returns the list of users under the MSP account\
        based on the provided parameters

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param offset: Pagination start index, defaults to 0
    :type offset: int, optional
    :param limit: Pagination end index, defaults to 10
    :type limit: int, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    apiPath = urls.MSP["USERS"]
    apiParams = {
        "offset": offset,
        "limit": limit
    }
    resp = conn.command(apiMethod="GET",
                        apiPath=apiPath, apiParams=apiParams)
    if (resp['code'] == 200 and resp['msg']['status'] == "success"):
        logger.info('Successfully fetched users in the MSP account')
    return resp

get_customer_users(conn, offset=0, limit=10, customer_id=None, customer_name=None)

This function returns the list of users under a customer in the MSP account based on the provided parameters

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param offset: Pagination start index, defaults to 0 :type offset: int, optional :param limit: Pagination end index, defaults to 10 :type limit: int, optional :param customer_id: Customer ID of the customer, defaults to None. :type customer_id: str, optional
:param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def get_customer_users(
        self,
        conn,
        offset=0,
        limit=10,
        customer_id=None,
        customer_name=None):
    """This function returns the list of users under a customer in the \
        MSP account based on the provided parameters

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param offset: Pagination start index, defaults to 0
    :type offset: int, optional
    :param limit: Pagination end index, defaults to 10
    :type limit: int, optional
    :param customer_id: Customer ID of the customer, defaults to None.
    :type customer_id: str, optional        
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if customer_id is None and customer_name is None:
        logger.error(
            "Attribute Error. Provide either customer_id or customer_name")
        return
    elif customer_id is None and customer_name:
        customer_id = self.get_customer_id(
            conn, customer_name=customer_name)
        if customer_id is None:
            log_message = f'Unable to get customer_id of {customer_name}.' \
                'Please provide a valid customer name'
            logger.error(log_message)
            return

    apiPath = urls.MSP["USERS"].split('/')
    apiPath.insert(-1, customer_id)
    apiPath = '/'.join(apiPath)

    apiParams = {
        "offset": offset,
        "limit": limit
    }
    resp = conn.command(apiMethod="GET",
                        apiPath=apiPath, apiParams=apiParams)
    if (resp['code'] == 200):
        logger.info('Successfully fetched users in the customer account')
    return resp

get_msp_resources(conn)

This function returns the branding resources under an MSP account

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def get_msp_resources(self, conn):
    """This function returns the branding resources under an MSP account

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    apiPath = urls.MSP["RESOURCES"]
    resp = conn.command(apiMethod="GET",
                        apiPath=apiPath)
    if (resp['code'] == 200):
        logger.info('Successfully fetched resources under the MSP')
    return resp

edit_msp_resources(conn, resources_dict)

This function edits the branding resources under an MSP account

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param resources_dict: Details of new branding resources of the MSP. This parameter's structure should match the structure of the sample API body in the Swagger. :type resources_dict: dict :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def edit_msp_resources(self, conn, resources_dict):
    """This function edits the branding resources under an MSP account

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param resources_dict: Details of new branding resources of the MSP.\
        This parameter's structure should match the structure of the\
        sample API body in the Swagger.
    :type resources_dict: dict
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    apiPath = urls.MSP["RESOURCES"]
    apiData = resources_dict
    resp = conn.command(apiMethod="PUT",
                        apiPath=apiPath,
                        apiData=apiData)
    if (resp['code'] == 200):
        return resp['msg']
    return resp

get_customer_devices_and_subscriptions(conn, customer_id=None, customer_name=None, offset=0, limit=10, device_type=None)

This function gets the devices & subscriptions under the customer account based on the provided parameters

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_id: Customer ID of the customer, defaults to None. :type customer_id: str, optional
:param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :param offset: Pagination start index, defaults to 0 :type offset: int, optional :param limit: Pagination end index, defaults to 10 :type limit: int, optional :param device_type: Filter on device_type. Accepted values - iap, switch, all_controller. Defaults to None. :type device_type: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def get_customer_devices_and_subscriptions(
        self,
        conn,
        customer_id=None,
        customer_name=None,
        offset=0,
        limit=10,
        device_type=None):
    """This function gets the devices & subscriptions under the customer\
        account based on the provided parameters

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param customer_id: Customer ID of the customer, defaults to None.
    :type customer_id: str, optional        
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :param offset: Pagination start index, defaults to 0
    :type offset: int, optional
    :param limit: Pagination end index, defaults to 10
    :type limit: int, optional
    :param device_type: Filter on device_type. Accepted values - iap,\
        switch, all_controller. Defaults to None. 
    :type device_type: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if customer_id is None and customer_name is None:
        logger.error(
            "Attribute Error. Provide either customer_id or customer_name")
        return

    elif customer_id is None and customer_name:
        customer_id = self.get_customer_id(
            conn, customer_name=customer_name)
        if customer_id is None:
            logger.error(
                'Unable to get customer_id. Please provide a valid customer name')
            return

    apiPath = f'{urls.MSP["V1_CUSTOMER"]}/{customer_id}/devices'
    apiParams = {
        "offset": offset,
        "limit": limit
    }
    if device_type is not None:
        apiParams['device_type'] = device_type
    resp = conn.command(apiMethod="GET",
                        apiPath=apiPath,
                        apiParams=apiParams)
    if (resp['code'] == 200 and 'status' in resp['msg']
            and resp['msg']['status'] == 'success'):
        log_message = 'Successfully fetched devices & subscriptions in the' \
            ' customer account'
        logger.info(log_message)
    return resp

assign_devices_to_customers(conn, devices, group_name=None, customer_id=None, customer_name=None)

This function assign devices to customer

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param devices: List of dictionaries of devices that will be assigned to the customer account. Each dictionary corresponds to a device & will have the following keys - serial, mac :type devices: list :param group_name: Name of the group to which the devices will be moved to within the customer. :type group_name: str, optional :param customer_id: Customer ID of the customer, defaults to None. :type customer_id: str, optional
:param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def assign_devices_to_customers(
        self,
        conn,
        devices,
        group_name=None,
        customer_id=None,
        customer_name=None):
    """This function assign devices to customer

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param devices: List of dictionaries of devices that will be assigned\
        to the customer account. Each dictionary corresponds to a device &\
        will have the following keys - serial, mac
    :type devices: list
    :param group_name: Name of the group to which the devices will be\
        moved to within the customer.
    :type group_name: str, optional
    :param customer_id: Customer ID of the customer, defaults to None.
    :type customer_id: str, optional       
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if devices is None:
        log_message = 'Attribute Error. Please provide list of devices that'\
            'should be moved to the customer'
        logger.error(log_message)
        return

    if customer_id is None and customer_name is None:
        logger.error(
            "Attribute Error. Provide either customer_id or customer_name")
        return

    elif customer_id is None and customer_name:
        customer_id = self.get_customer_id(
            conn, customer_name=customer_name)
        if customer_id is None:
            log_message = 'Unable to get customer_id. Please provide a'\
                'valid customer name'
            logger.error(log_message)
            return

    apiPath = f'{urls.MSP["V1_CUSTOMER"]}/{customer_id}/devices'
    apiData = {
        "devices": devices
    }
    if group_name is not None:
        apiData['group'] = group_name

    resp = conn.command(apiMethod="PUT",
                        apiPath=apiPath,
                        apiData=apiData)
    if (resp['code'] == 200 and 'status_code' in resp['msg']
            and resp['msg']['status_code'] == 200):
        device_serials = ", ".join(device["serial"] for device in devices)
        log_message = f"Successfully moved devices {device_serials} " \
            "to customer\'s Central Instance"
        logger.info(log_message)
    return resp

unassign_devices_from_customers(conn, devices, msp_id=None)

This function unassign devices from the customer to the MSP's device inventory

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param devices: List of dictionaries of devices that will be assigned to the customer account. Each dictionary corresponds to a device & will have the following keys - serial, mac :type devices: list :param msp_id: ID of the MSP account. If no ID is provided, then the the msp_id will be fetched with the get_msp_id function :type msp_id: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def unassign_devices_from_customers(self, conn, devices, msp_id=None):
    """This function unassign devices from the customer to the MSP's \
        device inventory

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param devices: List of dictionaries of devices that will be assigned\
        to the customer account. Each dictionary corresponds to a device &\
        will have the following keys - serial, mac
    :type devices: list
    :param msp_id: ID of the MSP account. If no ID is provided, then the\
        the msp_id will be fetched with the get_msp_id function
    :type msp_id: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if devices is None:
        log_message = 'Attribute Error. Please provide list of devices that' \
            ' should be moved from the customer to the MSP device inventory.'
        logger.error(log_message)
        return

    if msp_id is None:
        msp_id = self.get_msp_id(conn)
        if msp_id is None:
            logger.error("Attribute Error. Unable to find MSP ID")
        return

    apiPath = f'{urls.MSP["V1_CUSTOMER"]}/{msp_id}/devices'
    apiData = {
        "devices": devices
    }

    resp = conn.command(apiMethod="PUT",
                        apiPath=apiPath,
                        apiData=apiData)
    if (resp['code'] == 200 and 'status_code' in resp['msg']
            and resp['msg']['status_code'] == 200):
        log_message = "Successfully moved devices" + \
            {", ".join(device["serial"] for device in devices)} + \
            "from customer\'s Central Instance to MSP's device inventory."
        logger.info(log_message)
    return resp

unassign_all_customer_device(conn, customer_id=None, customer_name=None)

This function unassigns all devices & subscriptions from a customer's Central Instance. It will move these devices & subsciptions to the MSP's device & subscription inventory.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_id: Customer ID of the customer, defaults to None. :type customer_id: str, optional
:param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def unassign_all_customer_device(
        self,
        conn,
        customer_id=None,
        customer_name=None):
    """This function unassigns all devices & subscriptions from a\
        customer's Central Instance. It will move these devices &\
        subsciptions to the MSP's device & subscription inventory.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param customer_id: Customer ID of the customer, defaults to None.
    :type customer_id: str, optional            
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    if customer_id is None and customer_name is None:
        logger.error(
            "Attribute Error. Provide either customer_id or customer_name")
        return

    elif customer_id is None and customer_name:
        customer_id = self.get_customer_id(
            conn, customer_name=customer_name)
        if customer_id is None:
            log_message = 'Unable to get customer_id. Please provide a ' \
                'valid customer name'
            logger.error(log_message)
            return

    apiSubPath = "/".join(urls.MSP["V2_CUSTOMER"].split("/")[:-1])
    apiPath = f'{apiSubPath}/{customer_id}/devices'
    resp = conn.command(apiMethod="PUT",
                        apiPath=apiPath)
    if resp['code'] == 200:
        log_message = 'Successfully unassigned all devices from customer' \
            f' with customer id {customer_id}'
        logger.info(log_message)
    return resp

get_msp_devices_and_subscriptions(conn, offset=0, limit=10, device_allocation_status=0, device_type=None, customer_name=None)

This function fetches the list of devices & licenses under the MSP account based on the provided parameters.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param offset: Pagination start index, defaults to 0 :type offset: int, optional :param limit: Pagination end index, defaults to 100 :type limit: int, optional :param device_allocation_status: Filter on device_allocation_status. This parameter accepts the following values - 0(All), 1(Allocated),2(Available). Defaults to 0. :type device_allocation_status: str, optional :param device_type: Filter on device_type. Accepted values - iap, switch, all_controller. Defaults to None. :type device_type: str, optional :param customer_name: Name of customer, defaults to None. :type customer_name: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/msp.py
def get_msp_devices_and_subscriptions(
        self,
        conn,
        offset=0,
        limit=10,
        device_allocation_status=0,
        device_type=None,
        customer_name=None):
    """This function fetches the list of devices & licenses under the MSP\
        account based on the provided parameters.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param offset: Pagination start index, defaults to 0
    :type offset: int, optional
    :param limit: Pagination end index, defaults to 100
    :type limit: int, optional
    :param device_allocation_status: Filter on device_allocation_status.\
        This parameter accepts the following values - 0(All),\
        1(Allocated),2(Available). Defaults to 0. 
    :type device_allocation_status: str, optional
    :param device_type: Filter on device_type. Accepted values - iap,\
        switch, all_controller. Defaults to None. 
    :type device_type: str, optional
    :param customer_name: Name of customer, defaults to None.
    :type customer_name: str, optional
    :return: Response as provided by 'command' function in\
                class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    apiPath = urls.MSP["DEVICES"]
    apiParams = {
        "offset": offset,
        "limit": limit,
        "device_allocation_status": device_allocation_status
    }
    if device_type is not None:
        apiParams['device_type'] = device_type
    if customer_name is not None:
        apiParams['customer_name'] = customer_name

    resp = conn.command(apiMethod="GET",
                        apiPath=apiPath,
                        apiParams=apiParams)
    if resp['code'] == 200:
        log_message = 'Successfully fetched the list of devices & licenses'\
            ' based on the provided parameters'
        logger.info(log_message)
    return resp

get_msp_all_devices_and_subscriptions(conn, customer_name=None)

This function fetches all the devices & subscriptions from a MSP account. If the customer_name parameter is passed, then it will return all the devices & licenses in the customer account.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param customer_name: Name of customer, defaults to None. This parameter will be ignored if customer_id parameter is passed :type customer_name: str, optional :return: List of device & licenses in the MSP or customer account :rtype: list

Source code in pycentral/classic/msp.py
def get_msp_all_devices_and_subscriptions(self, conn, customer_name=None):
    """This function fetches all the devices & subscriptions from a MSP\
        account. If the customer_name parameter is passed, then it will\
        return all the devices & licenses in the customer account.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase` 
    :param customer_name: Name of customer, defaults to None. This \
        parameter will be ignored if customer_id parameter is passed
    :type customer_name: str, optional
    :return: List of device & licenses in the MSP or customer account
    :rtype: list
    """
    if customer_name is not None:
        customer_id = self.get_customer_id(
            conn, customer_name=customer_name)
        if customer_id is None:
            log_message = 'Unable to get customer_id. ' \
                'Please provide a valid customer name'
            logger.error(log_message)
            return

    offset = 0
    limit = 50
    device_list = []
    while True:
        if customer_name:
            resp = self.get_customer_devices_and_subscriptions(
                conn, offset=offset, limit=limit, customer_id=customer_id)
        else:
            resp = self.get_msp_devices_and_subscriptions(
                conn, offset=offset, limit=limit)
        if resp['code'] == 200 and resp['msg']['status'] == 'success' \
                and 'deviceList' in resp['msg']:
            resp_message = resp['msg']['deviceList']
            resp_devices = resp_message['devices']
            device_list.extend(resp_devices)
            if (len(device_list) == resp_message['total_devices']):
                break
        else:
            logger.error(resp)
            return
        offset += limit
    return device_list

get_customers_per_group(conn, group_name, offset=0, limit=10)

This function fetches the list of customers to MSP group based on the provided parameters.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group_name: MSP group name :type group_name: str :param offset: Pagination start index, defaults to 0 :type offset: int, optional :param limit: Pagination end index, defaults to 10 :type limit: int, optional :return: List of device & licenses in the MSP or customer account :rtype: list

Source code in pycentral/classic/msp.py
def get_customers_per_group(self, conn, group_name, offset=0, limit=10):
    """This function fetches the list of customers to MSP group based on \
        the provided parameters.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase` 
    :param group_name: MSP group name
    :type group_name: str
    :param offset: Pagination start index, defaults to 0
    :type offset: int, optional
    :param limit: Pagination end index, defaults to 10
    :type limit: int, optional
    :return: List of device & licenses in the MSP or customer account
    :rtype: list
    """

    if group_name is None:
        logger.error("Attribute Error. Provide a valid group name.")
        return

    apiPath = f'{urls.MSP["GROUPS"]}/{group_name}/customers'
    apiParams = {
        "offset": offset,
        "limit": limit
    }
    resp = conn.command(apiMethod="GET",
                        apiPath=apiPath,
                        apiParams=apiParams)
    return resp

RAPIDS

rapids

Rogues

A Python class to obtain Aruba Central's Rougue details via REST APIs.

list_rogue_aps(conn, group=None, label=None, site=None, swarm_id=None, start=None, end=None, from_timestamp=None, to_timestamp=None, limit=100, offset=0)

Get rogue APs over a time period

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group: List of group names, defaults to None :type group: list, optional :param label: List of label names, defaults to None :type label: list, optional :param site: List of site names, defaults to None :type site: list, optional :param swarm_id: Filter by Swarm ID, defaults to None :type swarm_id: str, optional :param start: Need information from this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp minus 3 hours, defaults to None :type start: int, optional :param end: Need information to this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp, defaults to None :type end: int, optional :param from_timestamp: This parameter supercedes start parameter. Need information from this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp minus 3 hours, defaults to None :type from_timestamp: int, optional :param to_timestamp: This parameter supercedes end parameter. Need information to this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp, defaults to None :type to_timestamp: int, optional :param limit: pagination size (default = 100), defaults to 100 :type limit: int, optional :param offset: Pagination offset (default = 0), defaults to 0 :type offset: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/rapids.py
def list_rogue_aps(self, conn, group=None, label=None, site=None,
                   swarm_id=None, start=None, end=None,
                   from_timestamp=None, to_timestamp=None, limit=100,
                   offset=0):
    """Get rogue APs over a time period

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group: List of group names, defaults to None
    :type group: list, optional
    :param label: List of label names, defaults to None
    :type label: list, optional
    :param site: List of site names, defaults to None
    :type site: list, optional
    :param swarm_id: Filter by Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param start: Need information from this timestamp. Timestamp is epoch\
        in milliseconds.
        Default is current timestamp minus 3 hours, defaults to None
    :type start: int, optional
    :param end: Need information to this timestamp. Timestamp is epoch in\
        milliseconds. Default is current timestamp, defaults to None
    :type end: int, optional
    :param from_timestamp: This parameter supercedes start parameter. Need\
        information from this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp minus 3 hours, defaults to None
    :type from_timestamp: int, optional
    :param to_timestamp: This parameter supercedes end parameter. Need\
        information to this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp, defaults to None
    :type to_timestamp: int, optional
    :param limit: pagination size (default = 100), defaults to 100
    :type limit: int, optional
    :param offset: Pagination offset (default = 0), defaults to 0
    :type offset: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.ROGUES["GET_ROGUE_AP"]
    params = {
        "limit": limit,
        "offset": offset
    }
    if group:
        params["group"] = group
    if label:
        params["label"] = label
    if site:
        params["site"] = site
    if swarm_id:
        params["swarm_id"] = swarm_id
    if start:
        params["start"] = start
    if end:
        params["end"] = end
    if from_timestamp:
        params["from_timestamp"] = from_timestamp
    if to_timestamp:
        params["to_timestamp"] = to_timestamp
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

list_interfering_aps(conn, group=None, label=None, site=None, swarm_id=None, start=None, end=None, from_timestamp=None, to_timestamp=None, limit=100, offset=0)

Get interfering APs over a time period

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group: List of group names, defaults to None :type group: list, optional :param label: List of label names, defaults to None :type label: list, optional :param site: List of site names, defaults to None :type site: list, optional :param swarm_id: Filter by Swarm ID, defaults to None :type swarm_id: str, optional :param start: Need information from this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp minus 3 hours, defaults to None :type start: int, optional :param end: Need information to this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp, defaults to None :type end: int, optional :param from_timestamp: This parameter supercedes start parameter. Need information from this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp minus 3 hours, defaults to None :type from_timestamp: int, optional :param to_timestamp: This parameter supercedes end parameter. Need information to this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp, defaults to None :type to_timestamp: int, optional :param limit: pagination size (default = 100), defaults to 100 :type limit: int, optional :param offset: Pagination offset (default = 0), defaults to 0 :type offset: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/rapids.py
def list_interfering_aps(self, conn, group=None, label=None, site=None,
                         swarm_id=None, start=None, end=None,
                         from_timestamp=None, to_timestamp=None, limit=100,
                         offset=0):
    """Get interfering APs over a time period

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
    API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group: List of group names, defaults to None
    :type group: list, optional
    :param label: List of label names, defaults to None
    :type label: list, optional
    :param site: List of site names, defaults to None
    :type site: list, optional
    :param swarm_id: Filter by Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param start: Need information from this timestamp. Timestamp is epoch\
        in milliseconds.
        Default is current timestamp minus 3 hours, defaults to None
    :type start: int, optional
    :param end: Need information to this timestamp. Timestamp is epoch in\
        milliseconds.
        Default is current timestamp, defaults to None
    :type end: int, optional
    :param from_timestamp: This parameter supercedes start parameter. Need\
        information from this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp minus 3 hours, defaults to None
    :type from_timestamp: int, optional
    :param to_timestamp: This parameter supercedes end parameter. Need\
        information to this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp, defaults to None
    :type to_timestamp: int, optional
    :param limit: pagination size (default = 100), defaults to 100
    :type limit: int, optional
    :param offset: Pagination offset (default = 0), defaults to 0
    :type offset: int, optional
    :return: HTTP Response as provided by 'command' function in \
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.ROGUES["GET_INTERFERING_AP"]
    params = {
        "limit": limit,
        "offset": offset
    }
    if group:
        params["group"] = group
    if label:
        params["label"] = label
    if site:
        params["site"] = site
    if swarm_id:
        params["swarm_id"] = swarm_id
    if start:
        params["start"] = start
    if end:
        params["end"] = end
    if from_timestamp:
        params["from_timestamp"] = from_timestamp
    if to_timestamp:
        params["to_timestamp"] = to_timestamp
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

list_suspect_aps(conn, group=None, label=None, site=None, swarm_id=None, start=None, end=None, from_timestamp=None, to_timestamp=None, limit=100, offset=0)

Get suspect APs over a time period

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group: List of group names, defaults to None :type group: list, optional :param label: List of label names, defaults to None :type label: list, optional :param site: List of site names, defaults to None :type site: list, optional :param swarm_id: Filter by Swarm ID, defaults to None :type swarm_id: str, optional :param start: Need information from this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp minus 3 hours, defaults to None :type start: int, optional :param end: Need information to this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp, defaults to None :type end: int, optional :param from_timestamp: This parameter supercedes start parameter. Need information from this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp minus 3 hours, defaults to None :type from_timestamp: int, optional :param to_timestamp: This parameter supercedes end parameter. Need information to this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp, defaults to None :type to_timestamp: int, optional :param limit: pagination size (default = 100), defaults to 100 :type limit: int, optional :param offset: Pagination offset (default = 0), defaults to 0 :type offset: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/rapids.py
def list_suspect_aps(self, conn, group=None, label=None, site=None,
                     swarm_id=None, start=None, end=None,
                     from_timestamp=None, to_timestamp=None, limit=100,
                     offset=0):
    """Get suspect APs over a time period

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group: List of group names, defaults to None
    :type group: list, optional
    :param label: List of label names, defaults to None
    :type label: list, optional
    :param site: List of site names, defaults to None
    :type site: list, optional
    :param swarm_id: Filter by Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param start: Need information from this timestamp. Timestamp is epoch\
        in milliseconds. Default is current timestamp minus 3 hours,\
        defaults to None
    :type start: int, optional
    :param end: Need information to this timestamp. Timestamp is epoch in\
        milliseconds. Default is current timestamp, defaults to None
    :type end: int, optional
    :param from_timestamp: This parameter supercedes start parameter. Need\
        information from this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp minus 3 hours, defaults to None
    :type from_timestamp: int, optional
    :param to_timestamp: This parameter supercedes end parameter. Need\
        information to this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp, defaults to None
    :type to_timestamp: int, optional
    :param limit: pagination size (default = 100), defaults to 100
    :type limit: int, optional
    :param offset: Pagination offset (default = 0), defaults to 0
    :type offset: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.ROGUES["GET_SUSPECT_AP"]
    params = {
        "limit": limit,
        "offset": offset
    }
    if group:
        params["group"] = group
    if label:
        params["label"] = label
    if site:
        params["site"] = site
    if swarm_id:
        params["swarm_id"] = swarm_id
    if start:
        params["start"] = start
    if end:
        params["end"] = end
    if from_timestamp:
        params["from_timestamp"] = from_timestamp
    if to_timestamp:
        params["to_timestamp"] = to_timestamp
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

list_neighbor_aps(conn, group=None, label=None, site=None, swarm_id=None, start=None, end=None, from_timestamp=None, to_timestamp=None, limit=100, offset=0)

Get neighbor APs over a time period

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group: List of group names, defaults to None :type group: list, optional :param label: List of label names, defaults to None :type label: list, optional :param site: List of site names, defaults to None :type site: list, optional :param swarm_id: Filter by Swarm ID, defaults to None :type swarm_id: str, optional :param start: Need information from this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp minus 3 hours, defaults to None :type start: int, optional :param end: Need information to this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp, defaults to None :type end: int, optional :param from_timestamp: This parameter supercedes start parameter. Need information from this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp minus 3 hours, defaults to None :type from_timestamp: int, optional :param to_timestamp: This parameter supercedes end parameter. Need information to this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp, defaults to None :type to_timestamp: int, optional :param limit: pagination size (default = 100), defaults to 100 :type limit: int, optional :param offset: Pagination offset (default = 0), defaults to 0 :type offset: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/rapids.py
def list_neighbor_aps(self, conn, group=None, label=None, site=None,
                      swarm_id=None, start=None, end=None,
                      from_timestamp=None, to_timestamp=None, limit=100,
                      offset=0):
    """Get neighbor APs over a time period

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group: List of group names, defaults to None
    :type group: list, optional
    :param label: List of label names, defaults to None
    :type label: list, optional
    :param site: List of site names, defaults to None
    :type site: list, optional
    :param swarm_id: Filter by Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param start: Need information from this timestamp. Timestamp is epoch\
        in milliseconds. Default is current timestamp minus 3 hours,\
        defaults to None
    :type start: int, optional
    :param end: Need information to this timestamp. Timestamp is epoch in\
        milliseconds. Default is current timestamp, defaults to None
    :type end: int, optional
    :param from_timestamp: This parameter supercedes start parameter. Need\
        information from this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp minus 3 hours, defaults to None
    :type from_timestamp: int, optional
    :param to_timestamp: This parameter supercedes end parameter. Need\
        information to this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp, defaults to None
    :type to_timestamp: int, optional
    :param limit: pagination size (default = 100), defaults to 100
    :type limit: int, optional
    :param offset: Pagination offset (default = 0), defaults to 0
    :type offset: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.ROGUES["GET_NEIGHBOR_AP"]
    params = {
        "limit": limit,
        "offset": offset
    }
    if group:
        params["group"] = group
    if label:
        params["label"] = label
    if site:
        params["site"] = site
    if swarm_id:
        params["swarm_id"] = swarm_id
    if start:
        params["start"] = start
    if end:
        params["end"] = end
    if from_timestamp:
        params["from_timestamp"] = from_timestamp
    if to_timestamp:
        params["to_timestamp"] = to_timestamp
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

WIDS

A Python Class to obtain Aruba Central's Wireless Intrusion Detection details based on REST APIs.

list_client_attacks(conn, group=None, label=None, site=None, swarm_id=None, start=None, end=None, from_timestamp=None, to_timestamp=None, limit=100, calculate_total=True, sort='-ts', offset=0)

Get client attacks over a time period

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group: List of group names, defaults to None :type group: list, optional :param label: List of label names, defaults to None :type label: list, optional :param site: List of site names, defaults to None :type site: list, optional :param swarm_id: Filter by Swarm ID, defaults to None :type swarm_id: str, optional :param start: Need information from this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp minus 3 hours, defaults to None :type start: int, optional :param end: Need information to this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp, defaults to None :type end: int, optional :param from_timestamp: This parameter supercedes start parameter. Need information from this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp minus 3 hours, defaults to None :type from_timestamp: int, optional :param to_timestamp: This parameter supercedes end parameter. Need information to this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp, defaults to None :type to_timestamp: int, optional :param limit: pagination size (default = 100), defaults to 100 :type limit: int, optional :param calculate_total: Whether to calculate total client attacks, defaults to True :type calculate_total: bool, optional :param sort: Sort parameter -ts(sort based on the timestamps in descending), +ts(sort based on timestamps ascending), -macaddr (sort based on station mac descending) and +macaddr(sort based station mac ascending), defaults to "-ts" :type sort: str, optional :param offset: Pagination offset (default = 0), defaults to 0 :type offset: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/rapids.py
def list_client_attacks(self, conn, group=None, label=None, site=None,
                        swarm_id=None, start=None, end=None,
                        from_timestamp=None, to_timestamp=None, limit=100,
                        calculate_total=True, sort="-ts", offset=0):
    """Get client attacks over a time period

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group: List of group names, defaults to None
    :type group: list, optional
    :param label: List of label names, defaults to None
    :type label: list, optional
    :param site: List of site names, defaults to None
    :type site: list, optional
    :param swarm_id: Filter by Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param start: Need information from this timestamp. Timestamp is epoch\
        in milliseconds. Default is current timestamp minus 3 hours,\
        defaults to None
    :type start: int, optional
    :param end: Need information to this timestamp. Timestamp is epoch in\
        milliseconds. Default is current timestamp, defaults to None
    :type end: int, optional
    :param from_timestamp: This parameter supercedes start parameter. Need\
        information from this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp minus 3 hours, defaults to None
    :type from_timestamp: int, optional
    :param to_timestamp: This parameter supercedes end parameter. Need\
        information to this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp, defaults to None
    :type to_timestamp: int, optional
    :param limit: pagination size (default = 100), defaults to 100
    :type limit: int, optional
    :param calculate_total: Whether to calculate total client attacks,\
        defaults to True
    :type calculate_total: bool, optional
    :param sort: Sort parameter -ts(sort based on the timestamps in\
        descending), +ts(sort based on timestamps ascending), -macaddr\
        (sort based on station mac descending) and +macaddr(sort based \
        station mac ascending), defaults to "-ts"
    :type sort: str, optional
    :param offset: Pagination offset (default = 0), defaults to 0
    :type offset: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.WIDS["GET_CLIENT_ATTACKS"]
    params = {
        "limit": limit,
        "offset": offset,
        "sort": sort,
        "calculate_total": calculate_total
    }
    if group:
        params["group"] = group
    if label:
        params["label"] = label
    if site:
        params["site"] = site
    if swarm_id:
        params["swarm_id"] = swarm_id
    if start:
        params["start"] = start
    if end:
        params["end"] = end
    if from_timestamp:
        params["from_timestamp"] = from_timestamp
    if to_timestamp:
        params["to_timestamp"] = to_timestamp
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

list_infrastructure_attacks(conn, group=None, label=None, site=None, swarm_id=None, start=None, end=None, from_timestamp=None, to_timestamp=None, limit=100, calculate_total=True, sort='-ts', offset=0)

Get infrastructure attacks over a time period

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group: List of group names, defaults to None :type group: list, optional :param label: List of label names, defaults to None :type label: list, optional :param site: List of site names, defaults to None :type site: list, optional :param swarm_id: Filter by Swarm ID, defaults to None :type swarm_id: str, optional :param start: Need information from this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp minus 3 hours, defaults to None :type start: int, optional :param end: Need information to this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp, defaults to None :type end: int, optional :param from_timestamp: This parameter supercedes start parameter. Need information from this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp minus 3 hours, defaults to None :type from_timestamp: int, optional :param to_timestamp: This parameter supercedes end parameter. Need information to this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp, defaults to None :type to_timestamp: int, optional :param limit: pagination size (default = 100), defaults to 100 :type limit: int, optional :param calculate_total: Whether to calculate total client attacks, defaults to True :type calculate_total: bool, optional :param sort: Sort parameter -ts(sort based on the timestamps in descending), +ts(sort based on timestamps ascending), -macaddr (sort based on station mac descending) and +macaddr(sort based station mac ascending), defaults to "-ts" :type sort: str, optional :param offset: Pagination offset (default = 0), defaults to 0 :type offset: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/rapids.py
def list_infrastructure_attacks(self, conn, group=None, label=None,
                                site=None, swarm_id=None, start=None,
                                end=None, from_timestamp=None,
                                to_timestamp=None, limit=100,
                                calculate_total=True, sort="-ts",
                                offset=0):
    """Get infrastructure attacks over a time period

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group: List of group names, defaults to None
    :type group: list, optional
    :param label: List of label names, defaults to None
    :type label: list, optional
    :param site: List of site names, defaults to None
    :type site: list, optional
    :param swarm_id: Filter by Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param start: Need information from this timestamp. Timestamp is epoch\
        in milliseconds. Default is current timestamp minus 3 hours,\
        defaults to None
    :type start: int, optional
    :param end: Need information to this timestamp. Timestamp is epoch in\
        milliseconds. Default is current timestamp, defaults to None
    :type end: int, optional
    :param from_timestamp: This parameter supercedes start parameter. Need\
        information from this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp minus 3 hours, defaults to None
    :type from_timestamp: int, optional
    :param to_timestamp: This parameter supercedes end parameter. Need\
        information to this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp, defaults to None
    :type to_timestamp: int, optional
    :param limit: pagination size (default = 100), defaults to 100
    :type limit: int, optional
    :param calculate_total: Whether to calculate total client attacks,\
        defaults to True
    :type calculate_total: bool, optional
    :param sort: Sort parameter -ts(sort based on the timestamps in\
        descending), +ts(sort based on timestamps ascending), -macaddr\
        (sort based on station mac descending) and +macaddr(sort based\
        station mac ascending), defaults to "-ts"
    :type sort: str, optional
    :param offset: Pagination offset (default = 0), defaults to 0
    :type offset: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.WIDS["GET_INFRA_ATTACKS"]
    params = {
        "limit": limit,
        "offset": offset,
        "sort": sort,
        "calculate_total": calculate_total
    }
    if group:
        params["group"] = group
    if label:
        params["label"] = label
    if site:
        params["site"] = site
    if swarm_id:
        params["swarm_id"] = swarm_id
    if start:
        params["start"] = start
    if end:
        params["end"] = end
    if from_timestamp:
        params["from_timestamp"] = from_timestamp
    if to_timestamp:
        params["to_timestamp"] = to_timestamp
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

list_wids_attacks(conn, group=None, label=None, site=None, swarm_id=None, start=None, end=None, from_timestamp=None, to_timestamp=None, limit=100, sort='-ts', offset=0)

Get WIDS events over a time period

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param group: List of group names, defaults to None :type group: list, optional :param label: List of label names, defaults to None :type label: list, optional :param site: List of site names, defaults to None :type site: list, optional :param swarm_id: Filter by Swarm ID, defaults to None :type swarm_id: str, optional :param start: Need information from this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp minus 3 hours, defaults to None :type start: int, optional :param end: Need information to this timestamp. Timestamp is epoch in milliseconds. Default is current timestamp, defaults to None :type end: int, optional :param from_timestamp: This parameter supercedes start parameter. Need information from this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp minus 3 hours, defaults to None :type from_timestamp: int, optional :param to_timestamp: This parameter supercedes end parameter. Need information to this timestamp. Timestamp is epoch in seconds. Default is current UTC timestamp, defaults to None :type to_timestamp: int, optional :param limit: pagination size (default = 100), defaults to 100 :type limit: int, optional :param sort: Sort parameter -ts(sort based on the timestamps in descending), +ts(sort based on timestamps ascending), -macaddr (sort based on station mac descending) and +macaddr(sort based station mac ascending), defaults to "-ts" :type sort: str, optional :param offset: Pagination offset (default = 0), defaults to 0 :type offset: int, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/rapids.py
def list_wids_attacks(self, conn, group=None, label=None, site=None,
                      swarm_id=None, start=None, end=None,
                      from_timestamp=None, to_timestamp=None, limit=100,
                      sort="-ts", offset=0):
    """Get WIDS events over a time period

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param group: List of group names, defaults to None
    :type group: list, optional
    :param label: List of label names, defaults to None
    :type label: list, optional
    :param site: List of site names, defaults to None
    :type site: list, optional
    :param swarm_id: Filter by Swarm ID, defaults to None
    :type swarm_id: str, optional
    :param start: Need information from this timestamp. Timestamp is epoch\
        in milliseconds. Default is current timestamp minus 3 hours,\
        defaults to None
    :type start: int, optional
    :param end: Need information to this timestamp. Timestamp is epoch in\
        milliseconds. Default is current timestamp, defaults to None
    :type end: int, optional
    :param from_timestamp: This parameter supercedes start parameter. Need\
        information from this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp minus 3 hours, defaults to None
    :type from_timestamp: int, optional
    :param to_timestamp: This parameter supercedes end parameter. Need\
        information to this timestamp. Timestamp is epoch in seconds.\
        Default is current UTC timestamp, defaults to None
    :type to_timestamp: int, optional
    :param limit: pagination size (default = 100), defaults to 100
    :type limit: int, optional
    :param sort: Sort parameter -ts(sort based on the timestamps in\
        descending), +ts(sort based on timestamps ascending), -macaddr\
        (sort based on station mac descending) and +macaddr(sort based\
        station mac ascending), defaults to "-ts"
    :type sort: str, optional
    :param offset: Pagination offset (default = 0), defaults to 0
    :type offset: int, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.WIDS["GET_WIDS_EVENTS"]
    params = {
        "limit": limit,
        "offset": offset,
        "sort": sort
    }
    if group:
        params["group"] = group
    if label:
        params["label"] = label
    if site:
        params["site"] = site
    if swarm_id:
        params["swarm_id"] = swarm_id
    if start:
        params["start"] = start
    if end:
        params["end"] = end
    if from_timestamp:
        params["from_timestamp"] = from_timestamp
    if to_timestamp:
        params["to_timestamp"] = to_timestamp
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

Refresh API Token

refresh_api_token

RefreshApiToken

Bases: object

Refresh the API access token in API Gateway using OAUTH API

refresh_token(conn, apigw_client_id, apigw_client_secret, old_refresh_token)

This function refreshes the existing access token and replaces old token with new token. The returned token dict will contain both access and refresh token. Use refresh token provided in the return dict for next refresh.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param apigw_client_id: Client ID from API Gateway page :type apigw_client_id: str :param apigw_client_secret: Client Secret from API Gateway page :type apigw_client_secret: str :param old_refresh_token: Refresh token value from the current/expired API token. :type old_refresh_token: str :return: Refrehed token dict consisting of access_token and refresh_token. :rtype: dict

Source code in pycentral/classic/refresh_api_token.py
def refresh_token(self, conn, apigw_client_id, apigw_client_secret,
                  old_refresh_token):
    """This function refreshes the existing access token and replaces old\
    token with new token. The returned token dict will contain both access\
    and refresh token. Use refresh token provided in the return dict for\
    next refresh.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param apigw_client_id: Client ID from API Gateway page
    :type apigw_client_id: str
    :param apigw_client_secret: Client Secret from API Gateway page
    :type apigw_client_secret: str
    :param old_refresh_token: Refresh token value from the current/expired\
        API token.
    :type old_refresh_token: str
    :return: Refrehed token dict consisting of access_token and\
        refresh_token.
    :rtype: dict
    """
    path = urls.REFRESH_TOKEN["REFRESH"]
    resp = None
    params = {
        "client_id": apigw_client_id,
        "client_secret": apigw_client_secret,
        "grant_type": "refresh_token",
        "refresh_token": old_refresh_token
    }
    resp = conn.command(
        apiMethod="POST",
        apiPath=path,
        apiParams=params,
        retry_api_call=False)
    return resp

Topology

topology

Topology

A python class to obtain Aruba Central Site's topology details via REST APIs.

get_topology(conn, site_id)

Get topology details of a site. The input is the id corresponding to a label or a site.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param site_id: Site ID :type site_id: int :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/topology.py
def get_topology(self, conn, site_id):
    """Get topology details of a site. The input is the id corresponding\
    to a label or a site.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param site_id: Site ID
    :type site_id: int
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.TOPOLOGY["GET_TOPO_SITE"], str(site_id))
    print(path)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

get_device_details(conn, device_serial)

Provides details of a device when serial number is passed as input.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Device Serial Number :type device_serial: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/topology.py
def get_device_details(self, conn, device_serial):
    """Provides details of a device when serial number is passed as input.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Device Serial Number
    :type device_serial: str
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.TOPOLOGY["GET_DEVICES"], device_serial)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

get_edge_details(conn, source_serial, dest_serial)

Get details of an edge grouped by lagname. The serials of nodes/devices on both sides of the edge should passed as input.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param source_serial: Device serial number. :type source_serial: str :param dest_serial: Device serial number. :type dest_serial: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/topology.py
def get_edge_details(self, conn, source_serial, dest_serial):
    """Get details of an edge grouped by lagname. The serials of\
    nodes/devices on both sides of the edge should passed as input.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param source_serial: Device serial number.
    :type source_serial: str
    :param dest_serial: Device serial number.
    :type dest_serial: str
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.TOPOLOGY["GET_EDGES"], source_serial, dest_serial)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

Get details of an uplink. The serials of node/device on one side of the uplink and the uplink id of the uplink should passed as input.Desired uplink id can be found in get topology details api.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param source_serial: Device serial number.xx :type source_serial: str :param uplink_id: Uplink id. :type uplink_id: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/topology.py
    def get_uplink_details(self, conn, source_serial, uplink_id):
        """Get details of an uplink. The serials of node/device on one side of\
        the uplink and the uplink id of the uplink should passed as input.\
Desired uplink id can be found in get
        topology details api.

        :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
            API call.
        :type conn: class:`pycentral.ArubaCentralBase`
        :param source_serial: Device serial number.xx
        :type source_serial: str
        :param uplink_id: Uplink id.
        :type uplink_id: str
        :return: HTTP Response as provided by 'command' function in\
            class:`pycentral.ArubaCentralBase`
        :rtype: dict
        """
        path = urlJoin(
            urls.TOPOLOGY["GET_UPLINK"],
            source_serial,
            str(uplink_id))
        resp = conn.command(apiMethod="GET", apiPath=path)
        return resp

tunnel_details(conn, site_id, tunnel_map_names)

Get tunnel details.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param site_id: Site ID :type site_id: int :param tunnel_map_names: Comma separated list of tunnel map names. :type tunnel_map_names: list :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/topology.py
def tunnel_details(self, conn, site_id, tunnel_map_names):
    """Get tunnel details.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param site_id: Site ID
    :type site_id: int
    :param tunnel_map_names: Comma separated list of tunnel map names.
    :type tunnel_map_names: list
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.TOPOLOGY["GET_TUNNEL"], str(site_id))
    params = {}
    params["tunnel_map_names"] = tunnel_map_names
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

ap_lldp_neighbors(conn, device_serial)

Get neighbor details reported by AP via LLDP.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param device_serial: Device serial number. :type device_serial: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/topology.py
def ap_lldp_neighbors(self, conn, device_serial):
    """Get neighbor details reported by AP via LLDP.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param device_serial: Device serial number.
    :type device_serial: str
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.TOPOLOGY["GET_AP_LLDP"], device_serial)

    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

URL Utility

url_utils


User Management

user_management

Users

Bases: object

A Python class to manage Aruba Central Users via REST APIs.

list_users(conn, limit=20, offset=0, sort='+timestamp', email=None)

(This API will be deprecated in future release). Use get_users(). Returns all users from the system associated to user's account

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param limit: Maximum number of items to return, defaults to 20 :type limit: int, optional :param offset: Zero based offset to start from, defaults to 0 :type offset: int, optional :param sort: Sort ordering. One if +timestamp/-timestamp/+username/ -username, defaults to "+timestamp" :type sort: str, optional :param email: Filter users by email, defaults to None :type email: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def list_users(self, conn, limit=20, offset=0, sort="+timestamp",
               email=None):
    """(This API will be deprecated in future release). Use get_users().
    Returns all users from the system associated to user's account

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param limit: Maximum number of items to return, defaults to 20
    :type limit: int, optional
    :param offset: Zero based offset to start from, defaults to 0
    :type offset: int, optional
    :param sort: Sort ordering. One if +timestamp/-timestamp/+username/\
        -username, defaults to "+timestamp"
    :type sort: str, optional
    :param email: Filter users by email, defaults to None
    :type email: str, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.USERS["LIST"]
    params = {
        "limit": limit,
        "offset": offset,
        "sort": sort
    }
    if email:
        params["email"] = email

    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_users(conn, limit=20, offset=0, order_by='+username', app_name=None, user_type=None, status=None)

Returns all users from the system associated to user's account

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param limit: Maximum number of items to return, defaults to 20 :type limit: int, optional :param offset: Zero based offset to start from, defaults to 0 :type offset: int, optional :param order_by: Sort ordering (ascending or descending). +username signifies ascending order of username., defaults to "+username" :type order_by: str, optional :param app_name: Filter users based on app_name, defaults to None :type app_name: str, optional :param user_type: Filter based on system or federated user, defaults to None :type user_type: str, optional :param status: Filter user based on status (inprogress, failed), defaults to None :type status: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def get_users(self, conn, limit=20, offset=0, order_by="+username",
              app_name=None, user_type=None, status=None):
    """Returns all users from the system associated to user's account

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param limit: Maximum number of items to return, defaults to 20
    :type limit: int, optional
    :param offset: Zero based offset to start from, defaults to 0
    :type offset: int, optional
    :param order_by: Sort ordering (ascending or descending). +username\
        signifies ascending order of username., defaults to "+username"
    :type order_by: str, optional
    :param app_name: Filter users based on app_name, defaults to None
    :type app_name: str, optional
    :param user_type: Filter based on system or federated user, defaults\
        to None
    :type user_type: str, optional
    :param status: Filter user based on status (inprogress, failed),\
        defaults to None
    :type status: str, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.USERS["GET_USERS"]
    params = {
        "offset": offset,
        "limit": limit,
        "order_by": order_by
    }
    if app_name:
        params["app_name"] = app_name
    if user_type:
        params["type"] = user_type
    if status:
        params["status"] = status

    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_user(conn, username, system_user=True)

Get user account details specified by user email

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param username: User's email id is specified as the user id :type username: str :param system_user: false if federated user, defaults to True :type system_user: bool, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def get_user(self, conn, username, system_user=True):
    """Get user account details specified by user email

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param username: User's email id is specified as the user id
    :type username: str
    :param system_user: false if federated user, defaults to True
    :type system_user: bool, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.USERS["GET"], username)
    params = {
        "system_user": system_user
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

create_user(conn, username: str, password: str, description: str, name: dict, phone: str, address: dict, applications: dict)

Create a user account. For public cloud environment, user has to re-register via invitation email. Email will be sent during processing of this request. Providing role on account setting app is mandatory in this API along with other subscribed apps. Scope must be given only for NMS app. For non-nms apps such as account setting refer the parameters in the example json payload.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param username: User's email id is specified as the user id :type username: str :param password: password of user account, defaults to None :type password: str :param description: description of user :type description: str :param name: 'firstname' and 'lastname' of the user. :type name: dict :param phone: Phone number. Format: +country_code-local_number :type phone: str :param address: Address of the user. Dict containing 'street', 'city', 'state', 'country' and 'zipcode'. :type address: dict :param applications: Define applications that needs access.

* keyword name: Name of the application. Example: 'nms',                'account_setting', etc.

* keyword info:  A list of dictionaries. Each element containing                'role', 'tenant_role', and 'scope'. Where 'scope' contains                'groups' key with list of groups.

:type applications: dict :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def create_user(self, conn, username: str, password: str, description: str,
                name: dict, phone: str, address: dict, applications: dict):
    """Create a user account. For public cloud environment, user has to\
    re-register via invitation email. Email will be sent during processing\
    of this request. Providing role on account setting app is mandatory in\
    this API along with other subscribed apps. Scope must be given only\
    for NMS app. For non-nms apps such as account setting refer the\
    parameters in the example json payload.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param username: User's email id is specified as the user id
    :type username: str
    :param password: password of user account, defaults to None
    :type password: str
    :param description: description of user
    :type description: str
    :param name: 'firstname' and 'lastname' of the user.
    :type name: dict
    :param phone: Phone number. Format: +country_code-local_number
    :type phone: str
    :param address: Address of the user. Dict containing 'street', 'city',\
        'state', 'country' and 'zipcode'.
    :type address: dict
    :param applications: Define applications that needs access. \n
        * keyword name: Name of the application. Example: 'nms',\
            'account_setting', etc. \n
        * keyword info:  A list of dictionaries. Each element containing\
            'role', 'tenant_role', and 'scope'. Where 'scope' contains\
            'groups' key with list of groups. \n
    :type applications: dict
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.USERS["CREATE"]
    data = self._build_user(
        username,
        description,
        name,
        phone,
        address,
        applications,
        password)
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

update_user(conn, username: str, description: str, name: dict, phone: str, address: dict, applications: dict)

Update user account details specified by user id. Providing info on account setting app is mandatory in this API along with other subscribed apps.Scope must be given only for NMS app. For non-nms apps such as account setting refer the parameters in the example json payload.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param username: User's email id is specified as the user id :type username: str :param description: description of user :type description: str :param name: 'firstname' and 'lastname' of the user. :type name: dict :param phone: Phone number. Format: +country_code-local_number :type phone: str :param address: Address of the user. Dict containing 'street', 'city', 'state', 'country' and 'zipcode'. :type address: dict :param applications: Define applications that needs access.

* keyword name: Name of the application. Example: 'nms',                'account_setting', etc.

* keyword info:  A list of dictionaries. Each element containing                'role', 'tenant_role', and 'scope'. Where 'scope' contains                'groups' key with list of groups.

:type applications: dict :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def update_user(self, conn, username: str, description: str,
                name: dict, phone: str, address: dict, applications: dict):
    """Update user account details specified by user id. Providing info on\
    account setting app is mandatory in this API along with other\
    subscribed apps.Scope must be given only for NMS app. For non-nms apps\
    such as account setting refer the parameters in the example json\
    payload.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param username: User's email id is specified as the user id
    :type username: str
    :param description: description of user
    :type description: str
    :param name: 'firstname' and 'lastname' of the user.
    :type name: dict
    :param phone: Phone number. Format: +country_code-local_number
    :type phone: str
    :param address: Address of the user. Dict containing 'street', 'city',\
        'state', 'country' and 'zipcode'.
    :type address: dict
    :param applications: Define applications that needs access. \n
        * keyword name: Name of the application. Example: 'nms',\
            'account_setting', etc. \n
        * keyword info:  A list of dictionaries. Each element containing\
            'role', 'tenant_role', and 'scope'. Where 'scope' contains\
            'groups' key with list of groups. \n
    :type applications: dict
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.USERS["UPDATE"], username)
    data = self._build_user(
        username,
        description,
        name,
        phone,
        address,
        applications)
    resp = conn.command(apiMethod="PATCH", apiPath=path, apiData=data)
    return resp

delete_user(conn, username, system_user=True)

Delete user account details specified by user id

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param username: User's email id is specified as the user id :type username: str :param system_user: false if federated user, defaults to True :type system_user: bool, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def delete_user(self, conn, username, system_user=True):
    """Delete user account details specified by user id

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param username: User's email id is specified as the user id
    :type username: str
    :param system_user: false if federated user, defaults to True
    :type system_user: bool, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.USERS["DELETE"], username)
    params = {
        "system_user": system_user
    }
    resp = conn.command(apiMethod="DELETE", apiPath=path, apiParams=params)
    return resp

Roles

Bases: object

A Python class to manage Aruba Central User Roles via REST APIs.

get_user_roles(conn, app_name=None, limit=20, offset=0, order_by='+rolename')

Get list of all roles

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param app_name: Filter users based on app_name, defaults to None :type app_name: str, optional :param limit: Maximum number of items to return, defaults to 20 :type limit: int, optional :param offset: Zero based offset to start from, defaults to 0 :type offset: int, optional :param order_by: Sort ordering. +rolename means ascending order of rolename, defaults to "+rolename" :type order_by: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def get_user_roles(self, conn, app_name=None, limit=20, offset=0,
                   order_by="+rolename"):
    """Get list of all roles

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param app_name: Filter users based on app_name, defaults to None
    :type app_name: str, optional
    :param limit: Maximum number of items to return, defaults to 20
    :type limit: int, optional
    :param offset: Zero based offset to start from, defaults to 0
    :type offset: int, optional
    :param order_by: Sort ordering. +rolename means ascending order of\
        rolename, defaults to "+rolename"
    :type order_by: str, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.ROLES["GET_ROLES"]
    params = {
        "limit": limit,
        "offset": offset,
        "order_by": order_by
    }
    if app_name:
        params["app_name"] = app_name
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

create_user_role(conn, app_name, rolename, applications, permission='modify')

Create an user role in an app

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param app_name: app name where role needs to be created :type app_name: str :param rolename: name of the role :type rolename: str :param applications: List of dict. Each element containing the following structure.

* keyword appname: Name of the application. Example: 'nms',                'account_setting', etc.

* keyword modules:  A list of dictionaries. Each element                containing 'module_name'
    and 'permission' for the modules.

* keyword permission: permission for the app

:type applications: dict :param permission: permission of the role, defaults to "modify" :type permission: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def create_user_role(self, conn, app_name, rolename, applications,
                     permission="modify"):
    """Create an user role in an app

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param app_name: app name where role needs to be created
    :type app_name: str
    :param rolename: name of the role
    :type rolename: str
    :param applications: List of dict. Each element containing the\
        following structure. \n
        * keyword appname: Name of the application. Example: 'nms',\
            'account_setting', etc. \n
        * keyword modules:  A list of dictionaries. Each element\
            containing 'module_name'
            and 'permission' for the modules. \n
        * keyword permission: permission for the app \n
    :type applications: dict
    :param permission: permission of the role, defaults to "modify"
    :type permission: str, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.ROLES["CREATE"], app_name, "roles")
    data = {
        "rolename": rolename,
        "permission": permission,
        "applications": applications
    }
    resp = conn.command(apiMethod="POST", apiPath=path, apiData=data)
    return resp

delete_user_role(conn, app_name, rolename)

Delete a role specified by role name

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param app_name: app name :type app_name: str :param rolename: User role name :type rolename: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def delete_user_role(self, conn, app_name, rolename):
    """Delete a role specified by role name

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param app_name: app name
    :type app_name: str
    :param rolename: User role name
    :type rolename: str
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.ROLES["DELETE"], app_name, "roles", rolename)
    resp = conn.command(apiMethod="DELETE", apiPath=path)
    return resp

get_user_role(conn, app_name, rolename)

Get Role details

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param app_name: app name :type app_name: str :param rolename: User role name :type rolename: str :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def get_user_role(self, conn, app_name, rolename):
    """Get Role details

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
         API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param app_name: app name
    :type app_name: str
    :param rolename: User role name
    :type rolename: str
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.ROLES["GET"], app_name, "roles", rolename)
    resp = conn.command(apiMethod="GET", apiPath=path)
    return resp

update_user_role(conn, app_name, rolename, applications, permission='modify')

Update a role specified by role name

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param app_name: app name :type app_name: str :param rolename: User role name :type rolename: str :param applications: List of dict. Each element containing the following structure.

* keyword appname: Name of the application. Example: 'nms',                'account_setting', etc.

* keyword modules:  A list of dictionaries. Each element                containing 'module_name' and 'permission' for the modules.

* keyword permission: permission for the app

:type applications: dict :param permission: [description], defaults to "modify" :type permission: str, optional :return: HTTP Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/user_management.py
def update_user_role(
        self,
        conn,
        app_name,
        rolename,
        applications,
        permission="modify"):
    """Update a role specified by role name

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param app_name: app name
    :type app_name: str
    :param rolename: User role name
    :type rolename: str
    :param applications: List of dict. Each element containing the\
        following structure. \n
        * keyword appname: Name of the application. Example: 'nms',\
            'account_setting', etc. \n
        * keyword modules:  A list of dictionaries. Each element\
            containing 'module_name' and 'permission' for the modules. \n
        * keyword permission: permission for the app \n
    :type applications: dict
    :param permission: [description], defaults to "modify"
    :type permission: str, optional
    :return: HTTP Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.ROLES["GET"], app_name, "roles", rolename)
    data = {
        "rolename": rolename,
        "permission": permission,
        "applications": applications
    }
    resp = conn.command(apiMethod="PATCH", apiPath=path, apiData=data)
    return resp

VisualRF

visualrf

ClientLocation

Bases: object

A python class to obtain client location based on visualRF floor map.

get_client_location(conn, macaddr: str, offset=0, limit=100, units='FEET')

Get location of a client. This function provides output only when visualRF is configured in Aruba Central.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param macaddr: Provide a macaddr of a client. For example "ac:bb:cc:dd:ec:10" :type macaddr: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :param units: METERS or FEET, defaults to "FEET" :type units: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_client_location(self, conn, macaddr: str, offset=0, limit=100,
                        units="FEET"):
    """Get location of a client. This function provides output only when\
        visualRF is configured in Aruba Central.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param macaddr: Provide a macaddr of a client. For example\
        "ac:bb:cc:dd:ec:10"
    :type macaddr: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :param units: METERS or FEET, defaults to "FEET"
    :type units: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.CLIENT_LOCATION["GET_CLIENT_LOC"], macaddr)
    params = {
        "offset": offset,
        "limit": limit,
        "units": units
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_floor_clients(conn, floor_id: str, offset=0, limit=100, units='FEET')

Get location of clients within a floormap in Aruba Central visualRF.

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param floor_id: Provide floor_id returned by get_building_floors() function in class:FloorPlan :type floor_id: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :param units: METERS or FEET, defaults to "FEET" :type units: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_floor_clients(self, conn, floor_id: str, offset=0, limit=100,
                      units="FEET"):
    """Get location of clients within a floormap in Aruba Central visualRF.

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param floor_id: Provide floor_id returned by `get_building_floors()`\
        function in class:`FloorPlan`
    :type floor_id: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :param units: METERS or FEET, defaults to "FEET"
    :type units: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(
        urls.CLIENT_LOCATION["GET_FLOOR_CLIENTS"],
        floor_id,
        "client_location")
    params = {
        "offset": offset,
        "limit": limit,
        "units": units
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

RougueLocation

Bases: object

A python class to obtain location of rogue access points

get_rogueap_location(conn, macaddr: str, offset=0, limit=100, units='FEET')

Get location of rogue a access point based on its Mac Address

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param macaddr: Provide Mac Address of an Access Point :type macaddr: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :param units: METERS or FEET, defaults to "FEET" :type units: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_rogueap_location(self, conn, macaddr: str, offset=0, limit=100,
                         units="FEET"):
    """Get location of rogue a access point based on its Mac Address

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
         API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param macaddr: Provide Mac Address of an Access Point
    :type macaddr: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :param units: METERS or FEET, defaults to "FEET"
    :type units: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.ROGUE_LOCATION["GET_AP_LOC"], macaddr)
    params = {
        "offset": offset,
        "limit": limit,
        "units": units
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_floor_rogueaps(conn, floor_id: str, offset=0, limit=100, units='FEET')

Get rogue access points within a floor

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param floor_id: Provide floor id. Can be obtained from get_building_floors() within class:FloorPlan :type floor_id: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :param units: METERS or FEET, defaults to "FEET" :type units: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_floor_rogueaps(self, conn, floor_id: str, offset=0, limit=100,
                       units="FEET"):
    """Get rogue access points within a floor

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param floor_id: Provide floor id. Can be obtained from\
        `get_building_floors()` within class:`FloorPlan`
    :type floor_id: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :param units: METERS or FEET, defaults to "FEET"
    :type units: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.ROGUE_LOCATION["GET_FLOOR_APS"], floor_id)
    params = {
        "offset": offset,
        "limit": limit,
        "units": units
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

FloorPlan

Bases: object

A Python class to obtain information of floorplan in Aruba Central visualRF.

get_campus_list(conn, offset=0, limit=100)

Get list of campuses in visualRF floorplan

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_campus_list(self, conn, offset=0, limit=100):
    """Get list of campuses in visualRF floorplan

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urls.FLOOR_PLAN["GET_CAMPUS_LIST"]
    params = {
        "offset": offset,
        "limit": limit
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_campus_buildings(conn, campus_id: str, offset=0, limit=100)

Get campus info and buildings within the campus

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param campus_id: Provide campus id. Can be obtained from get_campus_list function in class:FloorPlan :type campus_id: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_campus_buildings(self, conn, campus_id: str, offset=0, limit=100):
    """Get campus info and buildings within the campus

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param campus_id: Provide campus id. Can be obtained from\
        `get_campus_list` function in class:`FloorPlan`
    :type campus_id: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.FLOOR_PLAN["GET_CAMPUS_INFO"], campus_id)
    params = {
        "offset": offset,
        "limit": limit
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_building_floors(conn, building_id: str, offset=0, limit=100, units='FEET')

Get building info and floors within the building

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param building_id: Provide building id. Can be obtained from get_campus_buildings within class:FloorPlan :type building_id: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :param units: METERS or FEET, defaults to "FEET" :type units: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_building_floors(self, conn, building_id: str, offset=0, limit=100,
                        units="FEET"):
    """Get building info and floors within the building

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param building_id: Provide building id. Can be obtained from\
        `get_campus_buildings` within class:`FloorPlan`
    :type building_id: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :param units: METERS or FEET, defaults to "FEET"
    :type units: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.FLOOR_PLAN["GET_BUILDING_INFO"], building_id)
    params = {
        "offset": offset,
        "limit": limit,
        "units": units
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_floor_info(conn, floor_id: str, offset=0, limit=100, units='FEET')

Get floor information

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param floor_id: Provide floor id. Can be obtained from get_building_floors() within class:FloorPlan :type floor_id: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :param units: METERS or FEET, defaults to "FEET" :type units: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_floor_info(self, conn, floor_id: str, offset=0, limit=100,
                   units="FEET"):
    """Get floor information

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param floor_id: Provide floor id. Can be obtained from\
        `get_building_floors()` within class:`FloorPlan`
    :type floor_id: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :param units: METERS or FEET, defaults to "FEET"
    :type units: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.FLOOR_PLAN["GET_FLOOR_INFO"], floor_id)
    params = {
        "offset": offset,
        "limit": limit,
        "units": units
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_floor_image(conn, floor_id, offset=0, limit=100)

Get Floor's background image in base64 format

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param floor_id: Provide floor id. Can be obtained from get_building_floors() within class:FloorPlan :type floor_id: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_floor_image(self, conn, floor_id, offset=0, limit=100):
    """Get Floor's background image in base64 format

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param floor_id: Provide floor id. Can be obtained from\
        `get_building_floors()` within class:`FloorPlan`
    :type floor_id: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.FLOOR_PLAN["GET_FLOOR_IMG"], floor_id, "image")
    params = {
        "offset": offset,
        "limit": limit
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_floor_aps(conn, floor_id, offset=0, limit=100, units='FEET')

Get access points within a floor

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param floor_id: Provide floor id. Can be obtained from get_building_floors() within class:FloorPlan :type floor_id: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :param units: METERS or FEET, defaults to "FEET" :type units: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_floor_aps(self, conn, floor_id, offset=0, limit=100, units="FEET"):
    """Get access points within a floor

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param floor_id: Provide floor id. Can be obtained from\
        `get_building_floors()` within class:`FloorPlan`
    :type floor_id: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :param units: METERS or FEET, defaults to "FEET"
    :type units: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(
        urls.FLOOR_PLAN["GET_FLOOR_APS"],
        floor_id,
        "access_point_location")
    params = {
        "offset": offset,
        "limit": limit,
        "units": units
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp

get_ap_location(conn, ap_id: str, offset=0, limit=100, units='FEET')

Get location of an access point within a floorplan

:param conn: Instance of class:pycentral.ArubaCentralBase to make an API call. :type conn: class:pycentral.ArubaCentralBase :param ap_id: Provide ap_id returned by get_floor_aps() within class:FloorPlan :type ap_id: str :param offset: Pagination start index., defaults to 0 :type offset: int, optional :param limit: Pagination size. Default 100 Max 100, defaults to 100 :type limit: int, optional :param units: METERS or FEET, defaults to "FEET" :type units: str, optional :return: Response as provided by 'command' function in class:pycentral.ArubaCentralBase :rtype: dict

Source code in pycentral/classic/visualrf.py
def get_ap_location(self, conn, ap_id: str, offset=0, limit=100,
                    units="FEET"):
    """Get location of an access point within a floorplan

    :param conn: Instance of class:`pycentral.ArubaCentralBase` to make an\
        API call.
    :type conn: class:`pycentral.ArubaCentralBase`
    :param ap_id: Provide ap_id returned by `get_floor_aps()` within\
        class:`FloorPlan`
    :type ap_id: str
    :param offset: Pagination start index., defaults to 0
    :type offset: int, optional
    :param limit: Pagination size. Default 100 Max 100, defaults to 100
    :type limit: int, optional
    :param units: METERS or FEET, defaults to "FEET"
    :type units: str, optional
    :return: Response as provided by 'command' function in\
        class:`pycentral.ArubaCentralBase`
    :rtype: dict
    """
    path = urlJoin(urls.FLOOR_PLAN["GET_AP_LOC"], ap_id)
    params = {
        "offset": offset,
        "limit": limit,
        "units": units
    }
    resp = conn.command(apiMethod="GET", apiPath=path, apiParams=params)
    return resp