### Live Hoststats View Example Source: https://python.applogicnetworks.com/python3/current/_sources/hoststats_view.rst.txt Example of how to use the HoststatsView to get live host statistics. Ensure necessary imports are present. ```python from activelogic.liveview import HoststatsView hoststats = HoststatsView() hoststats.connect() print(hoststats.connected()) hoststats.close() ``` -------------------------------- ### Install websockets Library Source: https://python.applogicnetworks.com/python3/current/_sources/liveview.rst.txt Install the 'websockets' library using pip. This is a prerequisite for using Liveview. ```bash $ pip install websockets ``` -------------------------------- ### Live View API Usage Example Source: https://python.applogicnetworks.com/python3/current/_sources/view.rst.txt This example demonstrates the basic usage of the Live View API, including connecting, adding columns, and waiting for updates. Ensure the activelogic.liveview module is imported. ```python from activelogic.liveview import View view = View() view.connect() view.add_columns(["column1", "column2"]) view.wait_for_update() view.close() ``` -------------------------------- ### Install ActiveLogic API Source: https://python.applogicnetworks.com/python3/current/_sources/quickstart.rst.txt Install the API package using pip from the provided wheel file. ```bash pip3 install activelogic-23.24.00.1-py3-none-any.whl ``` -------------------------------- ### Install ActiveLogic API Source: https://python.applogicnetworks.com/python3/current/quickstart.html Install the API package using pip. ```bash $ pip3 install activelogic-23.24.00.1-py3-none-any.whl ``` -------------------------------- ### Install paramiko dependency Source: https://python.applogicnetworks.com/python3/current/_sources/sessioncontext.rst.txt Install the required paramiko library for SessionContext functionality. ```bash $ pip install paramiko ``` -------------------------------- ### Asynchronous Connection Example Source: https://python.applogicnetworks.com/python3/current/connection.html Connect to a system using the asynchronous API with async/await syntax. Requires asyncio to run. ```python import asyncio import activelogic as api async def amain(host, username, password): async with await api.async_connect(host, username, password) as conn: rs = await conn.ruleset() sd = await conn.sysdiag() # ... asyncio.run(amain("127.0.1.2", "admin", "password")) ``` -------------------------------- ### GET /config/get Source: https://python.applogicnetworks.com/python3/current/genindex.html Retrieves a configuration value from the system. ```APIDOC ## GET /config/get ### Description Retrieves a specific configuration value using the activelogic.Config method. ### Method GET ### Endpoint /config/get ### Parameters #### Query Parameters - **key** (string) - Required - The configuration key to retrieve. ``` -------------------------------- ### GET /logs/open Source: https://python.applogicnetworks.com/python3/current/genindex.html Opens a log file for reading. ```APIDOC ## GET /logs/open ### Description Opens a log file using the activelogic.Logs method. ### Method GET ### Endpoint /logs/open ### Parameters #### Query Parameters - **log_id** (string) - Required - The identifier of the log file to open. ``` -------------------------------- ### Initialize EnrichObjectItem Source: https://python.applogicnetworks.com/python3/current/enrich_object.html Examples of creating individual EnrichObjectItem instances with different keys, values, and spoof actions. ```python >>> EnrichObjectItem(key=EnrichObjectNetObjectSubscriberKey(10), ... value=EnrichObjectSessionContextValue("session/subscriber"), ... spoof_action=EnrichObjectSpoof.OVERWRITE, ... default_value="Unknown subscriber") >>> EnrichObjectItem(key=EnrichObjectNetObjectSubscriberKey(10), ... value=EnrichObjectSessionContextValue("session/subscriber")) >>> EnrichObjectItem(key=EnrichObjectNetObjectSubscriberKey(10), ... value=EnrichObjectNetObjectSubscriberValue(10)) >>> EnrichObjectItem(key=EnrichObjectFixedStringKey("X-Forwarded-For"), ... value=EnrichObjectNetObjectSubscriberValue(15624), ... spoof_action=EnrichObjectSpoof.OVERWRITE, ... default_value="Unknown subscriber") >>> EnrichObjectItem(key=EnrichObjectFileNameKey("Accept"), ... value=EnrichObjectUUIDValue(""), ... spoof_action=EnrichObjectSpoof.REMOVE) >>> EnrichObjectItem(key=EnrichObjectFixedStringKey("User-Agent"), ... value=EnrichObjectUUIDValue("SP/"), ... spoof_action=EnrichObjectSpoof.APPEND) >>> EnrichObjectItem(key=EnrichObjectFixedStringKey("Accept-Encoding"), ... value=EnrichObjectFixedStringValue("enrich")) >>> EnrichObjectItem(key=EnrichObjectFixedStringKey(key='X-Back-URL'), ... value=EnrichObjectTemplateValue('{}'), ... spoof_action=EnrichObjectSpoof.OVERWRITE, ... default_value='') ``` -------------------------------- ### System Information Output Example Source: https://python.applogicnetworks.com/python3/current/system_overview.html Sample output generated by the recursive system information printing function. ```text name: system, value: |name: sys_model, value: |name: bmc_version, value: |name: boot_time, value: 1623843427 |name: dist_version, value: 23.20.00.8-2106161136 |name: sys_machineid, value: |name: firmware_version, value: 6520E110 |name: raid_type, value: software |name: raid, value: | |name: adapter, value: | | |name: 0, value: | | | |name: ld, value: | | | | |name: 0, value: | | | | | |name: raidlevel, value: raid1 | | | | | |name: spans, value: | | | | | | |name: 0, value: | | | | | | | |name: state, value: optimal | | | | | | | |name: disks, value: | | | | | | | | |name: 1, value: | | | | | | | | | |name: snr, value: | | | | | | | | | |name: vendor-model, value: | | | | | | | | | |name: label, value: Upper disk | | | | | | | | | |name: scsiid, value: 1:0:0:0 | | | | | | | | | |name: state, value: optimal | | | | | | | | |name: 0, value: | | | | | | | | | |name: snr, value: | | | | | | | | | |name: vendor-model, value: | | | | | | | | | |name: label, value: Lower disk | | | | | | | | | |name: scsiid, value: 2:0:0:0 | | | | | | | | | |name: state, value: optimal | | | | | |name: state, value: optimal |name: raid_status, value: Adapter 0, logical device 0: optimal ``` -------------------------------- ### Initialize SessionContextObjectItem instances Source: https://python.applogicnetworks.com/python3/current/sessioncontext_object.html Examples of creating individual items for a SessionContextObject with specific schema, column, value, and match type parameters. ```python >>> SessionContextObjectItem(schemaname="SchemaName", columnname="ColName", value="43") >>> SessionContextObjectItem(schemaname="SchemaName", columnname="ColName", value="43", matchtype=SessionContextObjectItemType.EQUAL) >>> SessionContextObjectItem(schemaname="SchemaName", columnname="ColName", value="43", matchtype=SessionContextObjectItemType.CONTAINS) >>> SessionContextObjectItem(schemaname="SchemaName", columnname="ColName", value="43", matchtype=SessionContextObjectItemType.EXISTS) ``` -------------------------------- ### Listing Available Dimensions and Metrics Source: https://python.applogicnetworks.com/python3/current/analytics_object.html Example of how to list available dimensions and metrics using the Ruleset API. ```APIDOC ## GET /api/ruleset/list ### Description Lists available dimensions and metrics that can be used with Analytics Objects. ### Method GET ### Endpoint /api/ruleset/list ### Query Parameters - **type** (AnalyticsObjectDimension | AnalyticsObjectMetric) - Required - The type of item to list (e.g., 'AnalyticsObjectDimension' or 'AnalyticsObjectMetric'). ### Response #### Success Response (200) - **items** (array) - A list of available dimensions or metrics. - **id** (int) - The ID of the item. - **flags** (int) - Flags associated with the item. - **name** (str) - The name of the item. - **display_name** (str) - The display name of the item. - **doc** (str) - Documentation for the item. ### Request Example To list dimensions starting with 'ip': ```python rs.list(AnalyticsObjectDimension) [d for d in rs.list(AnalyticsObjectDimension) if d.name.startswith('ip')] ``` ### Response Example ```json { "items": [ { "id": 1, "flags": 0, "name": "ip_address", "display_name": "IP Address", "doc": "The IP address of the client." } ] } ``` ``` -------------------------------- ### Create ViewDistribution Source: https://python.applogicnetworks.com/python3/current/view.html Instantiate a ViewDistribution object to represent a distribution on a view. This example creates a distribution for 'Local Host'. ```python >>> d = ViewDistribution('Local Host') ``` -------------------------------- ### Add a FlowObject to a ruleset Source: https://python.applogicnetworks.com/python3/current/flow_object.html Example of initializing a FlowObject with specific flags and a template string. ```python >>> obj = rs.add(FlowObject('myobj', flags=FlowObjectFlags.IPFIX, templatestring='proceraServiceObject:2')) ``` -------------------------------- ### GET /config/get Source: https://python.applogicnetworks.com/python3/current/config.html Retrieves the full configuration object or the specific value for a given configuration key. ```APIDOC ## GET /config/get ### Description Fetches the configuration object for a specific key. ### Method GET ### Endpoint /config/get ### Parameters #### Query Parameters - **key** (string) - Required - The unique identifier for the configuration. ### Response #### Success Response (200) - **ConfigValue** (Object) - The configuration object containing key, value, type, and metadata. --- ## GET /config/get_value ### Description Fetches only the raw value associated with a specific configuration key. ### Method GET ### Endpoint /config/get_value ### Parameters #### Query Parameters - **key** (string) - Required - The unique identifier for the configuration. ### Response #### Success Response (200) - **value** (string|int|float|bool) - The configuration value. ``` -------------------------------- ### Liveview Aggregated View Source: https://python.applogicnetworks.com/python3/current/view.html Example of how to set up and use the Liveview aggregated view to process data updates. ```APIDOC ## Liveview Aggregated View Example ### Description This example demonstrates how to initialize a Liveview, add distributions and filters, connect to the server, and continuously process incoming data updates. ### Method Asynchronous Python script using the `activelogic.liveview` module. ### Endpoint `ws://127.0.1.2:8000/view` (or `wss://` for secure connections) ### Parameters None directly in the example script, but the `View` class constructor takes parameters. ### Request Body Not applicable for this example script. ### Response Data updates are received asynchronously and processed by the `process_data_in_update` function. ### Response Example ```json { "name": "example_item", "children": [], "inbound": 1000, "outbound": 1200, "in.int.quality": 0.99, "out.ext.quality": 0.98, "in.shapingavg.latency": 5, "in.shapingdrops": 0, "connections": 10 } ``` ``` -------------------------------- ### GET /config/list Source: https://python.applogicnetworks.com/python3/current/config.html Lists all configuration values, categories, or flags based on the provided object type. ```APIDOC ## GET /config/list ### Description Retrieves a list of configuration data based on the specified class type (ConfigValue, ConfigCategory, or ConfigFlags). ### Method GET ### Endpoint /config/list ### Parameters #### Query Parameters - **cls** (Object) - Required - The object type to list (ConfigValue, ConfigCategory, or ConfigFlag). ### Response #### Success Response (200) - **list** (Array) - A list of objects matching the requested type. #### Response Example [ {"key": "ALLOW_FWD_ON_INJECT", "value": false}, {"key": "ALWAYS_FORWARD", "value": true} ] ``` -------------------------------- ### Create Shaping Objects Source: https://python.applogicnetworks.com/python3/current/shaping_object.html Examples of initializing and adding shaping objects to a ruleset, including basic and split-type configurations. ```python >>> so = rs.add(ShapingObject("Unlimited")) >>> limits = ShapingObjectLimitGroup(inbound=ShapingObjectLimit(kbps=1024), outbound=ShapingObjectLimit(kbps=1024)) >>> so = rs.add(ShapingObject("Per host 1Mbps", split_type=ShapingObjectSplitType.LOCALHOST, limits=limits)) ``` -------------------------------- ### Create SessionContextObject instances Source: https://python.applogicnetworks.com/python3/current/sessioncontext_object.html Examples of adding a SessionContextObject to a ruleset with different item configurations and match types. ```python >>> so = rs.add(SessionContextObject('MySessionContextObject', items=[("SchemaName", "ColName", "43")])) >>> so = rs.add(SessionContextObject('MySessionContextObject', items=[("SchemaName", "ColName", "43", SessionContextObjectItemType.EQUAL)])) >>> so = rs.add(SessionContextObject('MySessionContextObject', items=[("SchemaName", "ColName", "43", SessionContextObjectItemType.CONTAINS)])) >>> so = rs.add(SessionContextObject('MySessionContextObject', items=[("SchemaName", "ColName", "43", SessionContextObjectItemType.EXISTS)])) ``` -------------------------------- ### Initialize VlanIDObjectRangeItem Source: https://python.applogicnetworks.com/python3/current/vlanid_object.html Creates a range of VLAN IDs defined by a start and end integer. ```python >>> VlanIDObjectRangeItem(30, 45) ``` -------------------------------- ### Create MPLSObject Source: https://python.applogicnetworks.com/python3/current/mpls_object.html Instantiate MPLSObject with single items, ranges, or a list of items. Requires prior setup of 'rs'. ```python >>> mo = rs.add(MPLSObject('MyMPLSObject', items=['1'])) ``` ```python >>> mo = rs.add(MPLSObject('MyMPLSObject', items=['1', '2-100'])) ``` ```python >>> mo = rs.add(MPLSObject('MyMPLSObject', items=[MPLSObjectRangeItem(1,5)])) ``` -------------------------------- ### Verify Python Version Source: https://python.applogicnetworks.com/python3/current/_sources/quickstart.rst.txt Check the installed Python version to ensure compatibility with the API requirements (Python 3.7+). ```bash python3 --version ``` -------------------------------- ### Connect to API and Initialize System Overview Source: https://python.applogicnetworks.com/python3/current/system_overview.html Establishes a synchronous connection to the API and initializes the System Overview resource. Replace placeholders with your actual IP/host, username, and password. ```python import activelogic as api conn = api.sync_connect(, , ) so = conn.system_overview() ``` -------------------------------- ### Synchronous Connection Example Source: https://python.applogicnetworks.com/python3/current/connection.html Connect to a system using synchronous API and close the connection. This method is useful for simpler tasks or direct interpreter use. ```python conn = api.sync_connect("127.0.1.2", "admin", "password") rs = conn.ruleset() conn.close() ``` -------------------------------- ### Create and Add Shaping Rule Source: https://python.applogicnetworks.com/python3/current/shaping_rule.html Example of creating a ShapingObject and adding a ShapingRule to a ruleset. Ensure 'rs' is initialized as a ruleset object. ```python obj = ShapingObject("Unlimited") ruleobj = rs.add(ShapingRule(name='newsrule', objects=[obj], priority=3, precedence=4)) ``` -------------------------------- ### List top subscribers with StatsFS Source: https://python.applogicnetworks.com/python3/current/statsfs.html Retrieves a list of top subscribers between two dates. The example demonstrates iterating through the returned list of nodes. ```python >>> res=s.list_subscribers("2021-09-14", "2021-09-14", "/Applications?Statistics Object") >>> for node in res: ... print node ... {'values': {'bytes out': 30924881920.0, 'bytes in': 6812166656.0}, 'name': 'Sub113'} {'values': {'bytes out': 10508003328.0, 'bytes in': 2729902848.0}, 'name': 'Sub5'} {'values': {'bytes out': 2935312384.0, 'bytes in': 2098169216.0}, 'name': 'Sub49'} {'values': {'bytes out': 577248896.0, 'bytes in': 1004788544.0}, 'name': 'Sub362'} {'values': {'bytes out': 7716958720.0, 'bytes in': 923890496.0}, 'name': 'Sub74'} ``` -------------------------------- ### Initialize VlanIDObject instances Source: https://python.applogicnetworks.com/python3/current/vlanid_object.html Demonstrates creating VlanIDObject instances using lists of integers, strings, or specific item objects. ```python >>> obj1 = rs.add(VlanIDObject('myobj', items=[1, "4-5"])) >>> obj2 = rs.add(VlanIDObject('myobj2', items=[VlanIDObjectSingleItem(1)])) >>> obj3 = rs.add(VlanIDObject('myobj3', items=[VlanIDObjectRangeItem(4, 5)])) ``` -------------------------------- ### Configure Logging with dictConfig Source: https://python.applogicnetworks.com/python3/current/logging.html Defines logging configuration using a dictionary, suitable for passing to dictConfig. This method allows for structured logging setup. ```python LOGGING_CONFIG = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s' } }, 'handlers': { 'console': { 'formatter': 'standard', 'class': 'logging.StreamHandler', }, }, 'loggers': { 'activelogic': { 'handlers': ['console'], 'level': 'INFO', 'propagate': False } } } ``` -------------------------------- ### Add Analytics Object Source: https://python.applogicnetworks.com/python3/current/analytics_object.html Instantiate and add an `AnalyticsObject` to the ruleset. This example demonstrates setting dimensions, a partition key, and metrics for data export. ```python rs.add(AnalyticsObject('myobj', AnalyticsObjectFlags.DUMP_TO_DISK, dimensions='subscriber,ip_address', partition_key='subscriber', metrics='bytes_in,bytes_out')) ``` -------------------------------- ### PLDBDetached Source: https://python.applogicnetworks.com/python3/current/exceptions.html Raised when a session is getting detached. ```APIDOC ## PLDBDetached ### Description Raised when a session is getting detached. ### Exception Type _class _activelogic.exception.PLDBDetached ``` -------------------------------- ### List Users and Public Keys with ActiveLogic Source: https://python.applogicnetworks.com/python3/current/users.html Demonstrates retrieving a list of system users and their associated public keys using the list method. ```python >>> us = conn.users() >>> us.list(User) [User(id=1, name='user', readbm=55, writebm=99, lviewbm=99, timeout=0, hosts=[]] >>> user_1 = us.list(User)[0] >>> us.list(UserPubKey, user=user_1) [UserPubKey(username='user', key='AAAAB3NzaC1yc2EAAAADAQABAAACAQDHPNnxH8BLNZ..')] >>> us.list(UserPubKey, user='user') [UserPubKey(username='user', key='AAAAB3NzaC1yc2EAAAADAQABAAACAQDHPNnxH8BLNZ..')] ``` -------------------------------- ### GET /fields_list Source: https://python.applogicnetworks.com/python3/current/statsfs.html List available statistics fields. ```APIDOC ## GET /fields_list ### Description Returns a dictionary containing available statistics fields categorized into 'graphs' and 'totals'. ### Method GET ### Endpoint /fields_list ### Response #### Success Response (200) - **graphs** (list) - List of graph statistics objects. - **totals** (list) - List of total statistics objects. #### Response Example { "graphs": [{"desc": "Incoming bps", "id": 1, "type": 1}], "totals": [{"desc": "Incoming Bytes", "id": 1, "type": 1}] } ``` -------------------------------- ### GET /date_list Source: https://python.applogicnetworks.com/python3/current/statsfs.html List the dates for which statistics are available. ```APIDOC ## GET /date_list ### Description Returns a sorted list of dates that have statistics data available. ### Method GET ### Endpoint /date_list ### Response #### Success Response (200) - **dates** (list) - A sorted list of strings representing dates (YYYY-MM-DD). #### Response Example ["2005-12-01", "2005-12-02", "2005-12-03"] ``` -------------------------------- ### SystemOverview.list Source: https://python.applogicnetworks.com/python3/current/_sources/system_overview.rst.txt Retrieves a list of system overview components. ```APIDOC ## GET /SystemOverview/list ### Description Retrieves a list of available system overview components. ### Method GET ### Endpoint /SystemOverview/list ``` -------------------------------- ### GET /sysdiag/list Source: https://python.applogicnetworks.com/python3/current/genindex.html Lists system diagnostic information. ```APIDOC ## GET /sysdiag/list ### Description Lists diagnostic data available through the activelogic.SysDiag interface. ### Method GET ### Endpoint /sysdiag/list ``` -------------------------------- ### Create a PortObject Source: https://python.applogicnetworks.com/python3/current/port_object.html Instantiate a PortObject with either a list of integers or a list of PortObjectSingleItem instances. ```python >>> po = rs.add(PortObject('MyPortObject', items=[1, 2])) >>> po = rs.add(PortObject('MyPortObject', items=[PortObjectSingleItem(1)])) ``` -------------------------------- ### GET /list Source: https://python.applogicnetworks.com/python3/current/statsfs.html List stats nodes between two dates. ```APIDOC ## GET /list ### Description Retrieves a list of statistics nodes between two specified dates. ### Method GET ### Endpoint /list ### Parameters #### Query Parameters - **start** (string) - Required - Start date - **end** (string) - Required - End date - **path** (string) - Required - Statistics path - **pathtype** (integer) - Optional - Value path type - **replymask** (integer) - Optional - Field mask for filtering returned data ### Response #### Success Response (200) - **nodes** (list) - A list of dictionaries representing stats nodes. ``` -------------------------------- ### Configure Simple Logger with Python Code Source: https://python.applogicnetworks.com/python3/current/_sources/logging.rst.txt Use this method to set up a basic logger, console handler, and formatter explicitly using Python code. Ensure the logging module is imported. ```python import logging import logging.config # Create a logger logger = logging.getLogger('simple_example') logger.setLevel(logging.DEBUG) # Create a console handler ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) # Create a formatter and add it to the handler formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ch.setFormatter(formatter) # Add the handler to the logger logger.addHandler(ch) # Example log message logger.info('This is an informational message.') logger.warning('This is a warning message.') ``` -------------------------------- ### Create an Accelerate Rule Source: https://python.applogicnetworks.com/python3/current/accelerate_rule.html Demonstrates how to instantiate an AccelerateRule and add it to a ruleset after creating an AccelerateObject. ```python >>> obj = rs.add(AccelerateObject('myobj')) >>> ruleobj = rs.add(AccelerateRule(name='myacceleraterule', accelerate_object=obj.id)) ``` -------------------------------- ### GET /path_is_expandable Source: https://python.applogicnetworks.com/python3/current/statsfs.html Verify if a specific statistics path is expandable. ```APIDOC ## GET /path_is_expandable ### Description Checks if the provided statistics path can be expanded within the given date range. ### Method GET ### Endpoint /path_is_expandable ### Parameters #### Query Parameters - **start** (string) - Required - Start date (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS) - **end** (string) - Required - End date (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS) - **path** (string) - Required - The statistics path to check - **pathtype** (integer) - Optional - Value path type ### Response #### Success Response (200) - **is_expandable** (boolean) - True if the path is expandable. ``` -------------------------------- ### GET /enum_names Source: https://python.applogicnetworks.com/python3/current/sysdiag.html Retrieves all enum names for a given zone. ```APIDOC ## GET /enum_names ### Description Retrieves all enum names for a given zone. ### Parameters #### Query Parameters - **zone_oid** (SysDiagZone or str) - Required - The zone or oid of the zone from which to get values. ### Response #### Success Response (200) - **response** (dict) - A dict of {id: names} ``` -------------------------------- ### Initialize AppContentObject Source: https://python.applogicnetworks.com/python3/current/appcontent_object.html Creates a new AppContentObject instance and adds it to the ruleset. ```python >>> obj = rs.add(AppContentObject('appcontentobj', items=[1, 2])) ``` -------------------------------- ### GET /names_list Source: https://python.applogicnetworks.com/python3/current/statsfs.html Lists the names of statistics nodes between two dates. ```APIDOC ## GET /names_list ### Description Retrieves a list of statistics node names within a specified date range. ### Parameters #### Query Parameters - **start** (string) - Required - Start date in YYYY-MM-DD format - **end** (string) - Required - End date in YYYY-MM-DD format - **path** (string) - Required - The statistics path to list - **pathtype** (integer) - Optional - Value path type - **matchstr** (string) - Optional - Match string ### Response #### Success Response (200) - **nodes** (list) - A list of dictionaries, each representing a stats node. ``` -------------------------------- ### Instantiate Resources via Connection Source: https://python.applogicnetworks.com/python3/current/resource.html Instantiate resource objects like Config and Ruleset using a connection object. These resources represent subsets of the system's configuration. ```python c = await conn.config() rs = await conn.ruleset() ``` -------------------------------- ### GET /list_subscribers Source: https://python.applogicnetworks.com/python3/current/statsfs.html List top N subscribers between two dates. ```APIDOC ## GET /list_subscribers ### Description List top N subscribers between two dates (N=0, returns all subscribers). ### Parameters #### Query Parameters - **start** (string) - Required - Start date in the format YYYY-MM-DD or YYYY-MM-DD HH:MM:SS - **end** (string) - Required - End date in the format YYYY-MM-DD or YYYY-MM-DD HH:MM:SS - **path** (string) - Required - The statistics path to list e.g. /NetObjects - **pathtype** (integer) - Optional - Value path type. - **max_nodes** (integer) - Optional - Maximum number of nodes to output. - **replymask** (integer) - Optional - If replymask is non-zero only data for the fields in the mask will be returned. ``` -------------------------------- ### Initialize TCP Accelerator Object Source: https://python.applogicnetworks.com/python3/current/accelerate_object.html Demonstrates how to instantiate an acceleration object with specific congestion control parameters. ```python >>> obj = rs.add(AccelerateObject('myaccelerateobj'), internal_congestion_control_initial_cwnd = 15) ``` -------------------------------- ### GET /transfer_get Source: https://python.applogicnetworks.com/python3/current/statsfs.html Retrieve total transfer for a path between two dates. ```APIDOC ## GET /transfer_get ### Description Retrieves the total transfer data for a specific path between two dates. ### Method GET ### Endpoint /transfer_get ### Parameters #### Query Parameters - **start** (string) - Required - Start date - **end** (string) - Required - End date - **path** (string) - Required - Statistics path - **pathtype** (integer) - Optional - Value path type - **replymask** (integer) - Optional - Field mask ``` -------------------------------- ### GET /get_aggregated_values Source: https://python.applogicnetworks.com/python3/current/sysdiag.html Retrieves all aggregated (top-level) values for a given zone. ```APIDOC ## GET /get_aggregated_values ### Description Retrieves all aggregated (top-level) values for a given zone. ### Parameters #### Query Parameters - **zone_oid** (SysDiagZone or str) - Required - The zone or oid of the zone to get values from. ### Response #### Success Response (200) - **List[SysDiagAggregatedValue]** - A list of aggregated diagnostic value objects. ### Errors - **KeyError**: The zone oid was not found. ``` -------------------------------- ### Upload files using Fileserv Source: https://python.applogicnetworks.com/python3/current/fileserv.html Demonstrates uploading files using either a file object or an input path. The input file must be opened in binary mode. ```python >>> fs = conn.fileserv() >>> with open('testfile', 'rb') as testfile: ... fs.upload(FileservArea.FIRMWARE_CLI, 'Testfile', ifile_obj=testfile) >>> fs.upload(FileservArea.FIRMWARE_CLI, 'Testfile_', in_path='test_path') ``` -------------------------------- ### GET /subitem_count Source: https://python.applogicnetworks.com/python3/current/statsfs.html Count number of subitems for requested path between the two dates. ```APIDOC ## GET /subitem_count ### Description Count number of subitems for requested path between the two dates. ### Parameters #### Query Parameters - **start** (string) - Required - Start date in the format YYYY-MM-DD - **end** (string) - Required - End date in the format YYYY-MM-DD - **path** (string) - Required - The statistics path to list e.g. / - **pathtype** (integer) - Optional - Value path type. ### Response #### Success Response (200) - **data** (dictionary) - Dictionary of various subtypes with their count. ``` -------------------------------- ### GET /subscriber_count_graph Source: https://python.applogicnetworks.com/python3/current/statsfs.html Retrieve subscriber count for each requested interval between two dates. ```APIDOC ## GET /subscriber_count_graph ### Description Retrieve subscriber count for each requested interval between two dates. ### Parameters #### Query Parameters - **start** (string) - Required - Start date in the format YYYY-MM-DD - **end** (string) - Required - End date in the format YYYY-MM-DD - **path** (string) - Required - The statistics path to list e.g. /NetObjects - **pathtype** (integer) - Optional - Value path type. - **numvals** (integer) - Optional - The number of data points to retrieve. ### Response #### Success Response (200) - **data** (list) - A dictionary for each stats node inside a list. ``` -------------------------------- ### activelogic.async_connect() Source: https://python.applogicnetworks.com/python3/current/connection.html Asynchronously connects to a system using the async/await syntax. ```APIDOC ## activelogic.async_connect() ### Description Connects to a system using the asynchronous API. Most methods in this API, this function included, are implemented as coroutines using the **async/await** syntax. ### Method `async` ### Endpoint `activelogic.async_connect(_host_, _username_, _password_, _*_, _port =42000_) ### Parameters #### Path Parameters * **host** (str) - Required - Address of the system to connect to. * **username** (str) - Required - User to authenticate as. * **password** (str) - Required - Password to authenticate with. * **port** (int) - Optional - Keyword-only. Connect to specified port instead of default port. #### Raises * **TimeoutError** – Connection attempt times out. * **ConnectionRefusedError** – Connection attempt is refused by peer. * **PLDBIOError** – Authorization failure. * **PLDBCapabilityError** – Server does not announce sufficient capabilities. #### Returns Connection instance ### Request Example ```python import asyncio import activelogic as api async def amain(host, username, password): async with await api.async_connect(host, username, password) as conn: rs = await conn.ruleset() sd = await conn.sysdiag() # ... asyncio.run(amain("127.0.1.2", "admin", "password")) ``` ### Note Calling a coroutine directly does not schedule it for execution. Use `await`, `asyncio.run()`, or `asyncio.create_task()` to run a coroutine. ``` -------------------------------- ### Add EnrichObject to Ruleset Source: https://python.applogicnetworks.com/python3/current/enrich_object.html Examples of creating and adding various EnrichObject configurations to a ruleset. ```python >>> so = rs.add(EnrichObject('MyEnrichObject', ... items=[(EnrichObjectNetObjectSubscriberKey(10), ... EnrichObjectSessionContextValue("session/subscriber"), ... EnrichObjectSpoof.OVERWRITE, "Unknown subscriber")])) >>> so = rs.add(EnrichObject('MyEnrichObject1', ... items=[(EnrichObjectNetObjectSubscriberKey(10), ... EnrichObjectSessionContextValue("session/subscriber")]))) >>> so = rs.add(EnrichObject('MyEnrichObject2', ... items=[(EnrichObjectNetObjectSubscriberKey(10), ... EnrichObjectNetObjectSubscriberValue(10))])) >>> so = rs.add(EnrichObject("propertyobj4", ... items=[(EnrichObjectFixedStringKey("Accept-Encoding"), ... EnrichObjectFixedStringValue("enrich"), ... (EnrichObjectNetObjectSubscriberKey(100), ... EnrichObjectUUIDValue("connid"), ... EnrichObjectSpoof.APPEND, "SubscriberA")] )) >>> so = rs.add(EnrichObject('EnrichObj', ... items=[(EnrichObjectFixedStringKey('X-Back-URL'), ... EnrichObjectTemplateValue('{}'), ... EnrichObjectSpoof.OVERWRITE)])) ``` -------------------------------- ### List Fileserv Data Source: https://python.applogicnetworks.com/python3/current/fileserv.html Demonstrates how to list available file types and files using the list method with different parameter types. ```python >>> fs.list(FileservFileType) [FileservFileType(id=0, name='Host trigger files'), FileservFileType(id=1, name='Firewall trigger files'), ...] >>> fs.list(FileservFile, ftype=FileservArea.SNMP_MIB) [FileservFile(name=b'PACKETLOGIC-HW-MIB', size=607), ...] >>> fs.list(FileservFile, ftype=6) [FileservFile(name=b'PACKETLOGIC-HW-MIB', size=607), ...] >>> fs.list(FileservFile, ftype='SNMP') [FileservFile(name=b'PACKETLOGIC-HW-MIB', size=607), ...] ``` -------------------------------- ### GET /list_search Source: https://python.applogicnetworks.com/python3/current/statsfs.html Searches for statistics nodes within a specific date range and path. ```APIDOC ## GET /list_search ### Description Searches for statistics nodes between two dates for a given path and pattern. ### Parameters #### Query Parameters - **start** (string) - Required - Start date in YYYY-MM-DD format - **end** (string) - Required - End date in YYYY-MM-DD format - **path** (string) - Required - The statistics path to search - **pathtype** (integer) - Optional - Value path type - **matchstr** (string) - Optional - Match string - **max_nodes** (integer) - Optional - Maximum number of nodes to return (0 for all) - **recursiondepth** (integer) - Optional - Max depth of Statistics tree to search - **replymask** (integer) - Optional - Mask for returned fields (requires firmware v14.0+) ### Response #### Success Response (200) - **result** (list/dict) - Returns a list of items if max_nodes=0, otherwise a dictionary of top lists for each field. ``` -------------------------------- ### Initialize Liveview View with SSL Source: https://python.applogicnetworks.com/python3/current/view.html Initializes a Liveview View object with a websocket address using SSL. Requires an ssl.SSLContext object for secure connections, especially with self-signed certificates. ```python import ssl ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) ssl_context.load_verify_locations("/path/to/certificate.pem") v = View("wss://172.21.91.128:8000/view", ssl_context) ``` -------------------------------- ### GET /subscriber_count_list Source: https://python.applogicnetworks.com/python3/current/statsfs.html Lists the subscriber count for each node for a requested path between two dates. ```APIDOC ## GET /subscriber_count_list ### Description Lists the subscriber count for each node for a requested path between two dates. ### Method GET ### Endpoint /subscriber_count_list ### Parameters #### Query Parameters - **start** (string) - Required - Start date in the format YYYY-MM-DD - **end** (string) - Required - End date in the format YYYY-MM-DD - **path** (string) - Required - The statistics path to list e.g. / - **pathtype** (integer) - Optional - Value path type. Defaults to 0. ### Response #### Success Response (200) - Returns a list of dictionaries, where each dictionary represents a node and its subscriber count. - **node_id** (string) - Identifier for the node. - **subscriber_count** (integer) - The number of subscribers for that node. ``` -------------------------------- ### Initialize Liveview View Source: https://python.applogicnetworks.com/python3/current/view.html Initializes a Liveview View object with a websocket address. Use this for basic connections. ```python v = View("ws://172.21.91.128:8000/view") ``` -------------------------------- ### GET /get_values Source: https://python.applogicnetworks.com/python3/current/sysdiag.html Retrieves the value tree for a specific value within a given zone. ```APIDOC ## GET /get_values ### Description Retrieves the value tree for a value within a given zone. ### Parameters #### Query Parameters - **zone_oid** (SysDiagZone or str) - Required - The zone or oid of the zone where the value belongs. - **value_id** (int) - Required - The id of the value from which to get the value tree. ### Response #### Success Response (200) - **List[SysDiagValue]** - A list of value tree objects. ### Errors - **KeyError**: Zone oid was not found. - **PLDBError**: Zone oid does not contain given value id. ``` -------------------------------- ### List Log Files and Facilities Source: https://python.applogicnetworks.com/python3/current/logs.html Retrieve lists of available log files or log facilities from the system. ```python >>> c.list(LogFile) [LogFile(name='Communication Daemon (PLCOMMD)', size=1410), ...] >>> c.list(LogFacility) [LogFacility(name='Ruleset', level=), ...] ``` -------------------------------- ### Create a PortObjectRangeItem Source: https://python.applogicnetworks.com/python3/current/port_object.html Define a range of ports using a starting and ending port number. ```python >>> PortObjectRangeItem(6667, 6669) ``` -------------------------------- ### GET /list_search Source: https://python.applogicnetworks.com/python3/current/statsfs.html List top N values matching a search string between two dates. ```APIDOC ## GET /list_search ### Description List top N values matching a search string between two dates. ### Parameters #### Query Parameters - **start** (string) - Required - Start date in the format YYYY-MM-DD or YYYY-MM-DD HH:MM:SS - **end** (string) - Required - End date in the format YYYY-MM-DD or YYYY-MM-DD HH:MM:SS - **path** (string) - Required - The statistics path to list e.g. /NetObjects - **searchstr** (string) - Required - The search string to match on. - **pathtype** (integer) - Optional - Value path type. - **max_nodes** (integer) - Optional - Maximum number of nodes to output. - **recursiondepth** (integer) - Optional - Recursion depth for search. - **replymask** (integer) - Optional - Reply mask for filtering fields. ``` -------------------------------- ### Create and Add AppNameObject Source: https://python.applogicnetworks.com/python3/current/appname_object.html Instantiate an AppNameObject with items and add it to a ruleset. Ensure AppNameObjectItem is correctly configured with value and itype. ```python >>> obj = rs.add(AppNameObject("appnameobj", items=[AppNameObjectItem("Video", 1), AppNameObjectItem("YouTube", 0)])) ``` -------------------------------- ### Manage Host Triggers Lifecycle Source: https://python.applogicnetworks.com/python3/current/hosttriggers.html Demonstrates the full lifecycle of a host trigger including connection, creation, listing, updating, and removal. ```python >>> import activelogic as api >>> conn = api.sync_connect(, , ) >>> ht = conn.hosttriggers() >>> ht.add(api.HostTrigger(name='test', script='filename')) 45 >>> ht.list(api.HostTrigger) [HostTrigger(name='test', id=45)] >>> t = ht.list(api.HostTriggers)[0] >>> t.in_bw 0 >>> ht.update(t, in_bw=7) >>> t = ht.list(api.HostTriggers)[0] >>> t.in_bw 7 >>> ht.list(api.HostTrigger) [HostTrigger(name='test', id=45)] >>> ht.remove(45) >>> ht.list(api.HostTrigger) [] >>> ``` -------------------------------- ### GET /subscriber_count Source: https://python.applogicnetworks.com/python3/current/statsfs.html Counts the number of subscribers for a given path within a specified date range. ```APIDOC ## GET /subscriber_count ### Description Counts the number of subscribers for a requested path between two dates. ### Method GET ### Endpoint /subscriber_count ### Parameters #### Query Parameters - **start** (string) - Required - Start date in the format YYYY-MM-DD - **end** (string) - Required - End date in the format YYYY-MM-DD - **path** (string) - Required - The statistics path to list e.g. / - **pathtype** (integer) - Optional - Value path type. Defaults to 0. ### Response #### Success Response (200) - **count** (integer) - The total number of subscribers for the specified path and date range. ``` -------------------------------- ### Connect to ActiveLogic System Source: https://python.applogicnetworks.com/python3/current/_sources/quickstart.rst.txt Establish a synchronous connection to an ActiveLogic system and initialize the system diagnostic interface. ```python import activelogic as api conn = api.sync_connect("192.168.1.25", "admin", "password") sd = conn.sysdiag() ``` -------------------------------- ### GET /sysdiag/list Source: https://python.applogicnetworks.com/python3/current/sysdiag.html Retrieves a list of diagnostic data based on the specified object type (cls). ```APIDOC ## GET /sysdiag/list ### Description Generic list function to retrieve various types of diagnostic data from the system. ### Method GET ### Parameters #### Query Parameters - **cls** (string) - Required - The object type to retrieve (SysDiagZone, SysDiagAlert, SysDiagLogEntry, SysDiagMallocUsageZone). - **only_new** (bool) - Optional - Used with SysDiagLogEntry to list only unacked logs. - **min_id** (int) - Optional - Used with SysDiagLogEntry to list logs starting from a specific ID. ### Response #### Success Response (200) - **data** (list) - A list of objects matching the requested dataclass type. ``` -------------------------------- ### GET /system_information Source: https://python.applogicnetworks.com/python3/current/system_overview.html Retrieves hierarchical system information objects containing machine details and status. ```APIDOC ## GET /system_information ### Description Retrieves information about a system in the SystemOverview. This returns a list of SystemInformation objects which may contain nested children. ### Response #### Success Response (200) - **name** (str) - SystemID or MachineID. - **value** (str) - The value associated with the system attribute. - **children** (List[SystemInformation]) - Additional nested values for the system. ``` -------------------------------- ### Create New Backup Source: https://python.applogicnetworks.com/python3/current/backup.html Creates a new backup of the system or a specified resource. If no name is provided, a name is generated automatically. If no resource_name is specified, all resources are included. ```python >>> b = conn.backup() >>> b.create_new(resource_name='System Diagnostics') 20210622-04.48.plb ``` -------------------------------- ### Initialize ProtocolObject Source: https://python.applogicnetworks.com/python3/current/protocol_object.html Create a new ProtocolObject instance by adding it to a ruleset with specified items. ```python >>> po = rs.add(ProtocolObject('MyProtocolObject', items=[1, "UDP"])) >>> po = rs.add(ProtocolObject('MyProtocolObject', items=[ProtocolObjectItem(1)])) ``` -------------------------------- ### Get Firmware Version Source: https://python.applogicnetworks.com/python3/current/connection.html Retrieve the firmware version of the connected system. Raises ValueError if not connected. ```python conn.distversion ``` -------------------------------- ### Update and Add Channel Bond Labels Source: https://python.applogicnetworks.com/python3/current/channels.html Demonstrates initializing channel connections, updating channel roles, and adding a new bond label with specific IPv4 configurations. ```python >>> ch = conn.channels() >>> ch.update_channel(1500, role=ChannelRole.BOND_LAYER3) >>> ch.add_bond_label(name="My bond label", primary_channel=1500, int_ipv4_address='192.0.2.1/24',ext_ipv4_address='192.0.3.1/24') ``` -------------------------------- ### Get Machine ID Source: https://python.applogicnetworks.com/python3/current/connection.html Access the machine ID of the connected system. Raises ValueError if not connected. ```python conn.machineid ``` -------------------------------- ### Download files using Fileserv Source: https://python.applogicnetworks.com/python3/current/fileserv.html Demonstrates downloading files using either a file object or a destination path. ```python >>> fs = conn.fileserv() >>> with open('testfile', 'wb+') as testfile: ... fs.download(FileservArea.SNMP_MIB, 'PACKETLOGIC-HW-MIB', ofile_obj=testfile) >>> fs.download(FileservArea.SNMP_MIB, 'PACKETLOGIC-HW-MIB', dest_path='temp_file') ``` ```python >>> f = io.BytesIO() >>> fs.download(FileservArea.PCAP_1, 'capture.pcap', ofile_obj=f) >>> f.close() ```