NetscoutAED

Use the Netscout Arbor Edge Defense integration to detect and stop both inbound threats and outbound malicious communication from compromised internal devices.

Network Security · Netscout Arbor Edge Defense - AED

Details

IDNetscoutAED
ProviderNetscout Systems
CategoryNetwork Security
From Version5.5.0
Docker Imagedemisto/python3:3.12.13.10116658
Supported ModulesAgentix XSIAM

README

The Netscout Arbor Edge Defense (AED) integration enables you to block and allow outbound and inbound traffic.

What does this pack do?

Using the Netscout AED integration you can:

  • Get, add, and remove hosts, countries, domains, and URLs from the inbound block list.
  • Get, add, and remove hosts from the inbound allow list.
  • Get, add, and remove hosts and countries from the outbound blaock list.
  • Get, add, and remove hosts from the outbound all.
  • Get and update the protection group (the IPv4 or IPv6 hosts that you need to protect).

Configure NetscoutAED in Cortex

Parameter Required  
Server URL True  
API Token If using 6.0.2 or lower version, put your API Key in the Password field, leave the User field empty. False
Trust any certificate (not secure) False  
Use system proxy settings False  

Commands

You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

na-ed-outbound-blacklisted-countries-list


Gets the countries on the outbound block list. By default, 10 block listed countries are returned.

Base Command

na-ed-country-code-list


Gets a country or list of countries (country name and ISO-standardized country code).

Base Command

na-ed-country-code-list

Input

Argument Name Description Required
query Search strings, separated by “+” to filter the results. (For example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit The maximum number of results returned per page. Default: 10. Optional

Context Output

Path Type Description
NetscoutAED.Country.country_name String The country’s name.
NetscoutAED.Country.iso_code String The ISO-standardized country code.

Command Example

!na-ed-country-code-list limit=5

Context Example

{
    "NetscoutAED": {
        "Country": [
            {
                "country_name": "6to4 Relay Anycast",
                "iso_code": "XF"
            },
            {
                "country_name": "Afghanistan",
                "iso_code": "AF"
            },
            {
                "country_name": "Aland Islands",
                "iso_code": "AX"
            },
            {
                "country_name": "Albania",
                "iso_code": "AL"
            },
            {
                "country_name": "Algeria",
                "iso_code": "DZ"
            }
        ]
    }
}

Human Readable Output

Netscout AED Countries List

Country Name Iso Code
6to4 Relay Anycast XF
Afghanistan AF
Aland Islands AX
Albania AL
Algeria DZ

na-ed-outbound-blacklisted-countries-list

Input

Argument Name Description Required
country An ISO-standardized country code to get a specific country in the results. Can be retrieved by running the “na-ed-country-code-list” command. Optional
query Search strings, separated by “+” to filter the results. (For example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit The maximum number of results returned per page. Default: 10. Optional

Context Output

Path Type Description
NetscoutAED.OutboundBlacklistCountry.annotation String A message associated with each country in the outbound block list.
NetscoutAED.OutboundBlacklistCountry.country String An ISO-standardized country code.
NetscoutAED.OutboundBlacklistCountry.update_time Date The time that the country code was added to the list.

Command Example


#### Context Example

```json
{
    "NetscoutAED": {
        "OutboundBlacklistCountry": [
            {
                "annotation": "example1",
                "country": "AZ",
                "update_time": "2021-04-13T13:06:43.000Z"
            },
            {
                "annotation": "example2",
                "country": "IS",
                "update_time": "2021-04-19T15:28:13.000Z"
            }
        ]
    }
}

Human Readable Output

Blacklisted Countries

Country Update Time Annotation
AZ 2021-04-13T13:06:43.000Z example1
IS 2021-04-19T15:28:13.000Z example2

na-ed-outbound-blacklisted-countries-add


Adds one or more countries to the outbound block list.

Base Command

na-ed-outbound-blacklisted-countries-add

Input

Argument Name Description Required
country An ISO-standardized country code or a comma-separated list of country codes. Can be retrieved by running the “na-ed-country-code-list” command. Required
annotation A message to associate with each country that you add to the outbound block list. Optional

Context Output

Path Type Description
NetscoutAED.OutboundBlacklistCountry.annotation String A message associated with each country in the outbound block list.
NetscoutAED.OutboundBlacklistCountry.country String An ISO-standardized country code.
NetscoutAED.OutboundBlacklistCountry.update_time Date The time that the country code was added to the list.

Command Example

!na-ed-outbound-blacklisted-countries-add country=AU

Context Example

{
    "NetscoutAED": {
        "OutboundBlacklistCountry": {
            "annotation": null,
            "country": "AU",
            "update_time": "2021-05-24T08:58:03.000Z"
        }
    }
}

Human Readable Output

Countries were successfully added to the outbound block listed list

Added Countries

Country Update Time
AU 2021-05-24T08:58:03.000Z

na-ed-outbound-blacklisted-countries-remove


Removes one or more countries from the outbound block list.

Base Command

na-ed-outbound-blacklisted-countries-remove

Input

Argument Name Description Required
country An ISO-standardized country code or a comma-separated list of ISO-standardized country codes to remove. Can be retrieved by running the “na-ed-country-code-list” command. Required

Context Output

There is no context output for this command.

Command Example

!na-ed-outbound-blacklisted-countries-remove country=AU

Human Readable Output

Countries were successfully removed from the outbound block listed list

na-ed-inbound-blacklisted-countries-list


Gets the inbound block listed countries. By default, 10 block listed countries are returned. To return block listed countries for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects countries that are globally block listed.

Base Command

na-ed-inbound-blacklisted-countries-list

Input

Argument Name Description Required
cid A comma-separated list of central configuration IDs. Cannot be used with the pgid parameter. Optional
pgid A comma-separated list of protection group IDs. Cannot be used with the cid parameter. Optional
country An ISO-standardized country code to get a specific country in the results. Can be retrieved by running the “na-ed-country-code-list” command. Optional
query Search strings, separated by “+” to filter the results. (For example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit The maximum number of results returned per page. Default: 10. Optional

Context Output

Path Type Description
NetscoutAED.InboundBlacklistCountry.annotation Unknown List of messages associated with each country in the inbound block list.
NetscoutAED.InboundBlacklistCountry.cid Unknown List of central configuration IDs.
NetscoutAED.InboundBlacklistCountry.country String An ISO-standardized country code.
NetscoutAED.InboundBlacklistCountry.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistCountry.update_time Date The time that the country code was added to the list.

Command Example

!na-ed-inbound-blacklisted-countries-list country=AM

Context Example

{
    "NetscoutAED": {
        "InboundBlacklistCountry": {
            "annotation": [
                "example1"
            ],
            "cid": [],
            "country": "AM",
            "pgid": [
                52
            ],
            "update_time": "2021-04-19T15:36:00.000Z"
        }
    }
}

Human Readable Output

Blacklisted Countries

Country Update Time Annotation Pgid
AM 2021-04-19T15:36:00.000Z example1 52

na-ed-inbound-blacklisted-countries-add


Adds one or more countries to the inbound block list by pgid or cid.

Base Command

na-ed-inbound-blacklisted-countries-add

Input

Argument Name Description Required
cid A specific central configuration ID or -1 for global. Cannot be used with the pgid parameter. Optional
pgid A specific protection group ID or -1 for global. Cannot be used with the cid parameter. Optional
annotation A message to associate with each country that you add to the block list. Optional
country ISO-standardized country code or a comma-separated list of country codes. Can be retrieved by running the “na-ed-country-code-list” command. Required

Context Output

Path Type Description
NetscoutAED.InboundBlacklistCountry.annotation Unknown List of messages associated with each country in the outbound block list.
NetscoutAED.InboundBlacklistCountry.cid Unknown List of central configuration IDs.
NetscoutAED.InboundBlacklistCountry.country String An ISO-standardized country code.
NetscoutAED.InboundBlacklistCountry.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistCountry.update_time Date The time that the country code was added to the list.

Command Example

!na-ed-inbound-blacklisted-countries-add country=AU

Context Example

{
    "NetscoutAED": {
        "InboundBlacklistCountry": {
            "annotation": [],
            "cid": [
                -1
            ],
            "country": "AU",
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:57:58.000Z"
        }
    }
}

Human Readable Output

Countries were successfully added to the inbound block listed list

Added Countries

Country Cid Pgid Update Time
AU -1 -1 2021-05-24T08:57:58.000Z

na-ed-inbound-blacklisted-countries-remove


Removes one or more countries from the block list for a specific protection group or for all protection groups.

Base Command

na-ed-inbound-blacklisted-countries-remove

Input

Argument Name Description Required
cid A specific central configuration ID or -1 for global. Cannot be used with the pgid parameter. Optional
pgid A specific protection group ID or -1 for global. Cannot be used with the cid parameter. Optional
country ISO-standardized country code or a comma-separated list of country codes. Can be retrieved by running the “na-ed-country-code-list” command. Required

Context Output

There is no context output for this command.

Command Example

!na-ed-inbound-blacklisted-countries-remove country=AU

Human Readable Output

Countries were successfully removed from the inbound block listed list

na-ed-outbound-blacklisted-hosts-list


Gets the outbound block listed hosts. By default, 10 block listed hosts are returned.

Base Command

na-ed-outbound-blacklisted-hosts-list

Input

Argument Name Description Required
host_address Comma-separated list of IPv4 host addresses or CIDRs. Optional
query Search strings, separated by “+” to filter the results. (example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
NetscoutAED.OutboundBlacklistHost.annotation String A description of the host.
NetscoutAED.OutboundBlacklistHost.host_address String IPv4 host address or CIDRs.
NetscoutAED.OutboundBlacklistHost.update_time Date The time the host was last updated/set.

Command Example


#### Context Example

```json
{
    "NetscoutAED": {
        "OutboundBlacklistHost": [
            {
              "annotation": "",
              "host_address": "1.1.1.1",
              "update_time": "2021-05-24T08:58:07.000Z"
            },
            {
              "annotation": "",
              "host_address": "2.2.2.2",
              "update_time": "2021-05-24T08:58:07.000Z"
            }
        ]
    }
}

Human Readable Output

Blacklisted Hosts

Host Address Update Time
1.1.1.1 2021-05-24T08:58:07.000Z
2.2.2.2 2021-05-24T08:58:07.000Z

na-ed-outbound-blacklisted-hosts-add


Adds one or more hosts to the outbound block list.

Base Command

na-ed-outbound-blacklisted-hosts-add

Input

Argument Name Description Required
host_address A single IPv4 host address or CIDR or a comma-separated list of IPv4 host addresses or CIDRs. Required
annotation A single description that applies to all of the specified hosts or a comma-separated list of descriptions, each of which applies to a specific host. Optional

Context Output

Path Type Description
NetscoutAED.OutboundBlacklistHost.annotation String A description of the host.
NetscoutAED.OutboundBlacklistHost.host_address String IPv4 host address or CIDRs.
NetscoutAED.OutboundBlacklistHost.update_time Date The time the host was last updated/set

Command Example

!na-ed-outbound-blacklisted-hosts-add host_address=1.2.3.4

Context Example

{
    "NetscoutAED": {
        "OutboundBlacklistHost": {
            "annotation": "",
            "host_address": "1.2.3.4",
            "update_time": "2021-05-24T08:58:07.000Z"
        }
    }
}

Human Readable Output

Hosts were successfully added to the outbound block list list

New Hosts

Host Address Update Time
1.2.3.4 2021-05-24T08:58:07.000Z

na-ed-outbound-blacklisted-hosts-replace


Replaces all the hosts on the outbound block listed list.

Base Command

na-ed-outbound-blacklisted-hosts-replace

Input

Argument Name Description Required
host_address A single IPv4 host address or CIDR or a comma-separated list of IPv4 host addresses or CIDRs. Required
annotation A single description that applies to all of the specified hosts or a comma-separated list of descriptions, each of which applies to a specific host. Optional

Context Output

Path Type Description
NetscoutAED.OutboundBlacklistHost.annotation String A description of the host.
NetscoutAED.OutboundBlacklistHost.host_address String IPv4 host address or CIDRs.
NetscoutAED.OutboundBlacklistHost.update_time Date The time the host was last updated/set.

Command Example

!na-ed-outbound-blacklisted-hosts-replace host_address=5.2.3.4

Context Example

{
    "NetscoutAED": {
        "OutboundBlacklistHost": {
            "annotation": "",
            "host_address": "5.2.3.4",
            "update_time": "2021-05-24T08:58:08.000Z"
        }
    }
}

Human Readable Output

Hosts were successfully replaced in the outbound block list list

New Hosts

Host Address Update Time
5.2.3.4 2021-05-24T08:58:08.000Z

na-ed-outbound-blacklisted-hosts-remove


Removes one or more hosts or CIDRS from the outbound block list.

Base Command

na-ed-outbound-blacklisted-hosts-remove

Input

Argument Name Description Required
host_address A single IPv4 host address or CIDR to remove, or a comma-separated list of IPv4 host addresses or CIDRs to remove. Required

Context Output

There is no context output for this command.

Command Example

!na-ed-outbound-blacklisted-hosts-remove host_address=5.2.3.4

Human Readable Output

Hosts were successfully removed from the outbound block list list

na-ed-outbound-whitelisted-hosts-list


Gets the outbound allow listed hosts. By default, 10 hosts on allow list are returned.

Base Command

na-ed-outbound-whitelisted-hosts-list

Input

Argument Name Description Required
host_address Comma-separated list of IPv4 host addresses or CIDRs. Optional
query Search strings, separated by “+” to filter the results. (example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit Maximal number of results to retrieve. Also sets the size of the returned page. Optional

Context Output

Path Type Description
NetscoutAED.OutboundWhitelistHost.annotation String A description of the host.
NetscoutAED.OutboundWhitelistHost.host_address String IPv4 host address or CIDRs.
NetscoutAED.OutboundWhitelistHost.update_time Date The time the host was last updated/set.

Command Example


#### Context Example

```json
{
    "NetscoutAED": {
        "OutboundWhitelistHost": {
            "annotation": "",
            "host_address": "4.4.4.4",
            "update_time": "2021-05-24T08:53:20.000Z"
        }
    }
}

Human Readable Output

Whitelisted Hosts

Host Address Update Time
4.4.4.4 2021-05-24T08:53:20.000Z

na-ed-outbound-whitelisted-hosts-add


Adds one or more hosts to the outbound allow listed list.

Base Command

na-ed-outbound-whitelisted-hosts-add

Input

Argument Name Description Required
host_address A single IPv4 host address or CIDR or a comma-separated list of IPv4 host addresses or CIDRs to add. Required
annotation A single description that applies to all of the specified hosts or a comma-separated list of descriptions, each of which applies to a specific host. Optional

Context Output

Path Type Description
NetscoutAED.OutboundWhitelistHost.annotation String A description of the host.
NetscoutAED.OutboundWhitelistHost.host_address String IPv4 host address or CIDRs.
NetscoutAED.OutboundWhitelistHost.update_time Date The time the host was last updated/set.

Command Example

!na-ed-outbound-whitelisted-hosts-add host_address=3.3.3.3

Context Example

{
    "NetscoutAED": {
        "OutboundWhitelistHost": {
            "annotation": "",
            "host_address": "3.3.3.3",
            "update_time": "2021-05-24T08:58:19.000Z"
        }
    }
}

Human Readable Output

Hosts were successfully added to the outbound allow list list

New Hosts

Host Address Update Time
3.3.3.3 2021-05-24T08:58:19.000Z

na-ed-outbound-whitelisted-hosts-replace


Replaces all the hosts on the outbound allow listed list.

Base Command

na-ed-outbound-whitelisted-hosts-replace

Input

Argument Name Description Required
host_address A single IPv4 host address or CIDR or a comma-separated list of IPv4 host addresses or CIDRs to update. Required
annotation A single description that applies to all of the specified hosts or a comma-separated list of descriptions, each of which applies to a specific host. Optional

Context Output

Path Type Description
NetscoutAED.OutboundWhitelistHost.annotation String A description of the host.
NetscoutAED.OutboundWhitelistHost.host_address String IPv4 host address or CIDRs.
NetscoutAED.OutboundWhitelistHost.update_time Date The time the host was last updated/set.

Command Example

!na-ed-outbound-whitelisted-hosts-replace host_address=3.3.3.3,4.4.4.4

Context Example

{
    "NetscoutAED": {
        "OutboundWhitelistHost": [
            {
                "annotation": "",
                "host_address": "3.3.3.3",
                "update_time": "2021-05-24T08:58:21.000Z"
            },
            {
                "annotation": "",
                "host_address": "4.4.4.4",
                "update_time": "2021-05-24T08:58:21.000Z"
            }
        ]
    }
}

Human Readable Output

Hosts were successfully replaced in the outbound allow list list

New Hosts

Host Address Update Time
3.3.3.3 2021-05-24T08:58:21.000Z
4.4.4.4 2021-05-24T08:58:21.000Z

na-ed-protection-groups-update


Updates the settings for one or more protection groups.

Base Command

na-ed-protection-groups-update

Input

Argument Name Description Required
pgid List of protection group IDs. Required
active Set the protection group mode to active (true) or inactive (false). Default: true. Possible values are: true, false. Optional
protection_level The protection level (None = use the global protection level, low, medium, high). Default: low. Possible values are: None, low, medium, high. Optional
profiling Turn traffic profiling on (true) or off (false) for one or more of the protection groups. Possible values are: true, false. Optional
profiling_duration Required when profiling is set to true. Specify the number of days, from 1 to 14, over which profiling will run. Possible values are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14. Optional

Context Output

Path Type Description
NetscoutAED.ProtectionGroup.active Boolean True if the protection group mode is active, false if inactive.
NetscoutAED.ProtectionGroup.bps_dropped Number Number of dropped bps.
NetscoutAED.ProtectionGroup.bps_passed Number Number of passed bps.
NetscoutAED.ProtectionGroup.bytes_dropped Number Number of dropped bytes.
NetscoutAED.ProtectionGroup.bytes_passed Unknown Number of passed bytes.
NetscoutAED.ProtectionGroup.description String Description of the protection group.
NetscoutAED.ProtectionGroup.name String Protection group name.
NetscoutAED.ProtectionGroup.packets_dropped Number Number of dropped packets.
NetscoutAED.ProtectionGroup.packets_passed Number Number of passed packets.
NetscoutAED.ProtectionGroup.pgid Number Protection group identifier.
NetscoutAED.ProtectionGroup.pps_passed Number Number of passed pps.
NetscoutAED.ProtectionGroup.pps_dropped Number Number of dropped pps.
NetscoutAED.ProtectionGroup.prefixes Unknown List of ‘,’ delimited prefixes belonging to the protection group.
NetscoutAED.ProtectionGroup.profiling Boolean A traffic profile capture for a protection group’s rate-based protection settings is running (true) or not (false).
NetscoutAED.ProtectionGroup.profiling_duration Number The duration, in days, of an active traffic profile capture. A 0 indicates that profiling is not active.
NetscoutAED.ProtectionGroup.profiling_start Date A UNIX epoch timestamp that indicates when a traffic profile capture began. A 0 indicates that profiling was never started.
NetscoutAED.ProtectionGroup.protection_level Unknown The protection level (None = use the global protection level, low, medium, high).
NetscoutAED.ProtectionGroup.server_name String The protection group’s server name.
NetscoutAED.ProtectionGroup.server_type Number The protection group’s server type.
NetscoutAED.ProtectionGroup.time_created Date The time when the protection group was created.

Command Example

!na-ed-protection-groups-update pgid=52 active=false

Context Example

{
    "NetscoutAED": {
        "ProtectionGroup": {
            "active": false,
            "bps_dropped": 0,
            "bps_passed": 0,
            "bytes_dropped": 0,
            "bytes_passed": 0,
            "description": "",
            "name": "test2",
            "packets_dropped": 0,
            "packets_passed": 0,
            "pgid": 52,
            "pps_dropped": 0,
            "pps_passed": 0,
            "prefixes": [
                "1.1.1.1/32"
            ],
            "profiling": false,
            "profiling_duration": 0,
            "profiling_start": 0,
            "protection_level": "global protection level",
            "server_name": "test2",
            "server_type": 35,
            "time_created": "2021-04-13T14:41:23.000Z"
        }
    }
}

Human Readable Output

Successfully updated the protection group object with protection group id: 52

Protection Groups

Name Pgid Protection Level Active Server Name Profiling Profiling Duration Time Created
test2 52 global protection level false test2 false 0 2021-04-13T14:41:23.000Z

na-ed-protection-groups-list


Gets a list of the protection groups.

Base Command

na-ed-protection-groups-list

Input

Argument Name Description Required
pgid Protection group identifier. Optional
name Protection group name. Optional
active Whether the protection group is active or not. Possible values are: true, false. Optional
query Search strings, separated by “+” to filter the results. (For example: “AZ+BS”). Optional

Context Output

Path Type Description
NetscoutAED.ProtectionGroup.active Boolean True if the protection group mode is active, false if inactive.
NetscoutAED.ProtectionGroup.bps_dropped Number Number of dropped bps.
NetscoutAED.ProtectionGroup.bps_passed Number Number of passed bps.
NetscoutAED.ProtectionGroup.bytes_dropped Number Number of dropped bytes.
NetscoutAED.ProtectionGroup.bytes_passed Unknown Number of passed bytes.
NetscoutAED.ProtectionGroup.description String Description of the protection group.
NetscoutAED.ProtectionGroup.name String Protection group name.
NetscoutAED.ProtectionGroup.packets_dropped Number Number of dropped packets.
NetscoutAED.ProtectionGroup.packets_passed Number Number of passed packets.
NetscoutAED.ProtectionGroup.pgid Number Protection group identifier.
NetscoutAED.ProtectionGroup.pps_passed Number Number of passed pps.
NetscoutAED.ProtectionGroup.pps_dropped Number Number of dropped pps.
NetscoutAED.ProtectionGroup.prefixes Unknown Comma-separated list of prefixes belonging to the protection group.
NetscoutAED.ProtectionGroup.profiling Boolean A traffic profile capture for a protection group’s rate-based protection settings is running (true) or not (false).
NetscoutAED.ProtectionGroup.profiling_duration Number The duration, in days, of an active traffic profile capture. A 0 indicates that profiling is not active.
NetscoutAED.ProtectionGroup.profiling_start Date A UNIX epoch timestamp that indicates when a traffic profile capture began. A 0 indicats that profiling was never started.
NetscoutAED.ProtectionGroup.protection_level Unknown The protection level (None = use the global protection level, low, medium, high).
NetscoutAED.ProtectionGroup.server_name String The protection group’s server name.
NetscoutAED.ProtectionGroup.server_type Number The protection group’s server type.
NetscoutAED.ProtectionGroup.time_created Date The time when the protection group was created.
NetscoutAED.ProtectionGroup.cid Number Central configuration ID.

Command Example

!na-ed-protection-groups-list active=true

Context Example

{
    "NetscoutAED": {
        "ProtectionGroup": {
            "active": false,
            "bps_dropped": 0,
            "bps_passed": 0,
            "bytes_dropped": 0,
            "bytes_passed": 0,
            "description": "",
            "name": "test2",
            "packets_dropped": 0,
            "packets_passed": 0,
            "pgid": 52,
            "pps_dropped": 0,
            "pps_passed": 0,
            "prefixes": [
                "1.1.1.1/32"
            ],
            "profiling": true,
            "profiling_duration": 0,
            "profiling_start": 0,
            "protection_level": "global protection level",
            "server_name": "test2",
            "server_type": 35,
            "time_created": "2021-04-13T14:41:23.000Z"
        }
    }
}

Human Readable Output

Protection Groups

Name Pgid Protection Level Active Server Name Profiling Profiling Duration Time Created
test2 52 global protection level true test2 false 0 2021-04-13T14:41:23.000Z

na-ed-inbound-blacklisted-hosts-list


Gets the inbound block listed hosts. By default, 10 block listed hosts are returned. To return block listed hosts for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects hosts that are globally block listed.

Base Command

na-ed-inbound-blacklisted-hosts-list

Input

Argument Name Description Required
host_address List of ‘,’ delimited IPv4 host addresses or CIDRs. Optional
query Search strings, separated by “+” to filter the results. (For example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
NetscoutAED.InboundBlacklistHost.annotation Unknown List of messages associated with each host in the inbound block list.
NetscoutAED.InboundBlacklistHost.cid Unknown List of central configuration IDs.
NetscoutAED.InboundBlacklistHost.host_address String IPv4 host addresses or CIDRs.
NetscoutAED.InboundBlacklistHost.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistHost.update_time Date The time that the host address was added to the list.

Command Example


#### Context Example

```json
{
    "NetscoutAED": {
        "InboundBlacklistHost": {
            "annotation": [
                ""
            ],
            "cid": [
                -1
            ],
            "host_address": "1.1.1.1",
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:58:13.000Z"
        }
    }
}

Human Readable Output

Blacklisted Hosts

Host Address Pgid Cid Update Time Annotation
1.1.1.1 -1 -1 2021-05-24T08:58:13.000Z  

na-ed-inbound-blacklisted-hosts-add


Adds one or more hosts to the inbound block listed list.

Base Command

na-ed-inbound-blacklisted-hosts-add

Input

Argument Name Description Required
host_address A single IPv4 or IPv6 host address or CIDR or a comma-separated list of host addresses or CIDRs. Required
annotation A single description that applies to all of the specified hosts or a comma-separated list of descriptions, each of which applies to a specific host. Optional

Context Output

Path Type Description
NetscoutAED.InboundBlacklistHost.annotation Unknown List of messages associated with each host in the inbound block list.
NetscoutAED.InboundBlacklistHost.cid Unknown List of central configuration IDs
NetscoutAED.InboundBlacklistHost.host_address String IPv4 host addresses or CIDRs.
NetscoutAED.InboundBlacklistHost.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistHostupdate_time Date The time that the host address was added to the list.

Command Example

!na-ed-inbound-blacklisted-hosts-add host_address=1.2.3.4

Context Example

{
    "NetscoutAED": {
        "InboundBlacklistHost": {
            "annotation": [
                ""
            ],
            "cid": [
                -1
            ],
            "host_address": "1.2.3.4",
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:58:13.000Z"
        }
    }
}

Human Readable Output

Hosts were successfully added to the inbound block list list

New Hosts

Host Address Pgid Cid Update Time Annotation
1.2.3.4 -1 -1 2021-05-24T08:58:13.000Z  

na-ed-inbound-blacklisted-hosts-replace


Replaces all the hosts on the inbound block list.

Base Command

na-ed-inbound-blacklisted-hosts-replace

Input

Argument Name Description Required
host_address A single IPv4 or IPv6 host address or CIDR or a comma-separated list of host addresses or CIDRs. Required
annotation A single description that applies to all of the specified hosts or a comma-separated list of descriptions, each of which applies to a specific host. Optional

Context Output

Path Type Description
NetscoutAED.InboundBlacklistHost.annotation Unknown List of messages associated with each host in the inbound block list.
NetscoutAED.InboundBlacklistHost.cid Unknown List of central configuration IDs
NetscoutAED.InboundBlacklistHost.host_address String IPv4 host addresses or CIDRs.
NetscoutAED.InboundBlacklistHost.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistHost.update_time Date The time that the host address was added to the list.

Command Example

!na-ed-inbound-blacklisted-hosts-replace host_address=5.2.3.4

Context Example

{
    "NetscoutAED": {
        "InboundBlacklistHost": {
            "annotation": [
                ""
            ],
            "cid": [
                -1
            ],
            "host_address": "5.2.3.4",
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:58:15.000Z"
        }
    }
}

Human Readable Output

Hosts were successfully replaced in the inbound block list list

New Hosts

Host Address Pgid Cid Update Time Annotation
5.2.3.4 -1 -1 2021-05-24T08:58:15.000Z  

na-ed-inbound-blacklisted-hosts-remove


Removes one or more hosts or CIDRs from the block list for a specific protection group or for all protection groups.

Base Command

na-ed-inbound-blacklisted-hosts-remove

Input

Argument Name Description Required
host_address A single IPv4 or IPv6 host address or CIDR, or a comma-separated list of host addresses or CIDRs. Required

Context Output

There is no context output for this command.

Command Example

!na-ed-inbound-blacklisted-hosts-remove host_address=5.2.3.4

Human Readable Output

Hosts were successfully removed from the inbound block list list

na-ed-inbound-whitelisted-hosts-list


Get the hosts on allow list. By default, 10 hosts on allow list are returned. To return hosts on allow list for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects hosts that are globally on allow list.

Base Command

na-ed-inbound-whitelisted-hosts-list

Input

Argument Name Description Required
host_address Comma-separated list of IPv4 or IPv6 host addresses or CIDRs. Optional
query Search strings, separated by “+” to filter the results. (example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
NetscoutAED.InboundWhitelistHost.annotation Unknown List of messages associated with each host in the inbound allow listed list.
NetscoutAED.InboundWhitelistHost.cid Unknown List of central configuration IDs
NetscoutAED.InboundWhitelistHost.host_address String IPv4 host addresses or CIDRs.
NetscoutAED.InboundWhitelistHost.pgid Unknown List of protection group ID.
NetscoutAED.InboundWhitelistHost.update_time Date The time that the host address was added to the list.

Command Example


```json
{
    "NetscoutAED": {
        "InboundWhitelistHost": {
            "annotation": [
                ""
            ],
            "cid": [
                -1
            ],
            "host_address": "2.2.2.2",
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:58:25.000Z"
        }
    }
}

Human Readable Output

Whitelisted Hosts

Host Address Pgid Cid Update Time Annotation
2.2.2.2 -1 -1 2021-05-24T08:58:25.000Z  

na-ed-inbound-whitelisted-hosts-add


Adds one or more hosts to the inbound allow listed list.

Base Command

na-ed-inbound-whitelisted-hosts-add

Input

Argument Name Description Required
host_address A single IPv4 or IPv6 host address or CIDR or a comma-separated list of host addresses or CIDRs to add. Required
annotation A single description that applies to all of the specified hosts or a comma-separated list of descriptions, each of which applies to a specific host. Optional

Context Output

Path Type Description
NetscoutAED.InboundWhitelistHost.annotation Unknown List of messages associated with each host in the inbound allow listed list.
NetscoutAED.InboundWhitelistHost.cid Unknown List of central configuration IDs
NetscoutAED.InboundWhitelistHost.host_address String IPv4 host addresses or CIDRs.
NetscoutAED.InboundWhitelistHost.pgid Unknown List of protection group ID.
NetscoutAED.InboundWhitelistHost.update_time Date The time that the host address was added to the list.

Command Example

!na-ed-inbound-whitelisted-hosts-add host_address=1.2.3.4

Context Example

{
    "NetscoutAED": {
        "InboundWhitelistHost": {
            "annotation": [
                ""
            ],
            "cid": [
                -1
            ],
            "host_address": "1.2.3.4",
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:58:25.000Z"
        }
    }
}

Human Readable Output

Hosts were successfully added to the inbound allow list list

New Hosts

Host Address Pgid Cid Update Time Annotation
1.2.3.4 -1 -1 2021-05-24T08:58:25.000Z  

na-ed-inbound-whitelisted-hosts-replace


Replaces all the hosts on the inbound allow list.

Base Command

na-ed-inbound-whitelisted-hosts-replace

Input

Argument Name Description Required
host_address A single IPv4 or IPv6 host address or CIDR or a comma-separated list of host addresses or CIDRs to update. Required
annotation A single description that applies to all of the specified hosts or a comma-separated list of descriptions, each of which applies to a specific host. Optional

Context Output

Path Type Description
NetscoutAED.InboundWhitelistHost.annotation Unknown List of messages associated with each host in the inbound allow listed list.
NetscoutAED.InboundWhitelistHost.cid Unknown List of central configuration IDs
NetscoutAED.InboundWhitelistHost.host_address String IPv4 host addresses or CIDRs.
NetscoutAED.InboundWhitelistHost.pgid Unknown List of protection group ID.
NetscoutAED.InboundWhitelistHost.update_time Date The time that the host address was added to the list.

Command Example

!na-ed-inbound-whitelisted-hosts-replace host_address=5.2.3.4

Context Example

{
    "NetscoutAED": {
        "InboundWhitelistHost": {
            "annotation": [
                ""
            ],
            "cid": [
                -1
            ],
            "host_address": "5.2.3.4",
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:58:26.000Z"
        }
    }
}

Human Readable Output

Hosts were successfully replaced in the inbound allow list list

New Hosts

Host Address Pgid Cid Update Time Annotation
5.2.3.4 -1 -1 2021-05-24T08:58:26.000Z  

na-ed-inbound-whitelisted-hosts-remove


Removes one or more hosts or CIDRs from the allow list for a specific protection group or for all protection groups.

Base Command

na-ed-inbound-whitelisted-hosts-remove

Input

Argument Name Description Required
host_address A single IPv4 or IPv6 host address or CIDR, or a comma-separated list of host addresses or CIDRs to remove. Required

Context Output

There is no context output for this command.

Command Example

!na-ed-inbound-whitelisted-hosts-remove host_address=5.2.3.4

Human Readable Output

Hosts were successfully removed from the inbound whitelist list

na-ed-inbound-blacklisted-domains-list


Gets the block listed domains. By default, 10 block listed domains are returned. To return block listed domains for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects domains that are globally block listed.

Base Command

na-ed-inbound-blacklisted-domains-list

Input

Argument Name Description Required
cid Comma-separated list of central configuration IDs. Cannot be used with the pgid parameter. Optional
pgid Comma-separated list of protection group IDs. Cannot be used with the cid parameter. Optional
domain Comma-separated list of domains. Optional
query Search strings, separated by “+” to filter the results. (example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
NetscoutAED.InboundBlacklistDomain.annotation Unknown List of messages associated with each domain in the inbound block list.
NetscoutAED.InboundBlacklistDomain.cid Unknown List of central configuration IDs.
NetscoutAED.InboundBlacklistDomain.domain String Domain name.
NetscoutAED.InboundBlacklistDomain.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistDomain.update_time Date The time that the domain was added to the list.

Command Example


#### Context Example

```json
{
    "NetscoutAED": {
        "InboundBlacklistDomain": [
            {
                "annotation": [
                    "try1"
                ],
                "cid": [
                    -1
                ],
                "domain": "sport.co.il",
                "pgid": [
                    -1
                ],
                "update_time": "2021-03-15T16:00:24.000Z"
            },
            {
                "annotation": [],
                "cid": [
                    -1
                ],
                "domain": "sport.com",
                "pgid": [
                    -1
                ],
                "update_time": "2021-03-18T17:25:26.000Z"
            },
            {
                "annotation": [],
                "cid": [
                    -1
                ],
                "domain": "ynet.com",
                "pgid": [
                    -1
                ],
                "update_time": "2021-03-18T16:49:50.000Z"
            }
        ]
    }
}

Human Readable Output

Blacklisted Domains

Domain Pgid Cid Update Time Annotation
sport.co.il -1 -1 2021-03-15T16:00:24.000Z try1
sport.com -1 -1 2021-03-18T17:25:26.000Z  
ynet.com -1 -1 2021-03-18T16:49:50.000Z  

na-ed-inbound-blacklisted-domains-add


Adds one or more domains to the block list by pgid or cid.

Base Command

na-ed-inbound-blacklisted-domains-add

Input

Argument Name Description Required
cid A specific central configuration ID or -1 for global. Cannot be used with the pgid parameter. Optional
pgid A specific protection group ID or -1 for global. Cannot be used with the cid parameter. Optional
domain Domain name or a comma-separated list of domain names. Required
annotation A message to associate with each domain that you add to the block list. Optional

Context Output

Path Type Description
NetscoutAED.InboundBlacklistDomain.annotation Unknown List of messages associated with each domain in the inbound blaok list.
NetscoutAED.InboundBlacklistDomain.cid Unknown List of central configuration IDs.
NetscoutAED.InboundBlacklistDomain.domain String Domain name.
NetscoutAED.InboundBlacklistDomain.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistDomain.update_time Unknown The time that the domain was added to the list.

Command Example

!na-ed-inbound-blacklisted-domains-add domain=goo.com

Context Example

{
    "NetscoutAED": {
        "InboundBlacklistDomain": {
            "annotation": [],
            "cid": [
                -1
            ],
            "domain": "goo.com",
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:58:34.000Z"
        }
    }
}

Human Readable Output

Domains were successfully added to the inbound block listed list

Added Domains

Domain Pgid Cid Update Time
goo.com -1 -1 2021-05-24T08:58:34.000Z

na-ed-inbound-blacklisted-domains-remove


Removes one or more domains from the block list for a specific protection group or for all protection groups.

Base Command

na-ed-inbound-blacklisted-domains-remove

Input

Argument Name Description Required
domain Domain name or a comma-separated list of domain names. Required

Context Output

There is no context output for this command.

Command Example

!na-ed-inbound-blacklisted-domains-remove domain=goo.com

Human Readable Output

Domains were successfully removed from the inbound block listed list

na-ed-inbound-blacklisted-urls-list


Gets the block listed URLs. By default, 10 block listed URLs are returned. To return block listed URLs for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects URLs that are globally block listed.

Base Command

na-ed-inbound-blacklisted-urls-list

Input

Argument Name Description Required
cid Comma-separated list of central configuration IDs. Cannot be used with the pgid parameter. Optional
pgid Comma-separated list of protection group IDs. Cannot be used with the cid parameter. Optional
url Comma-separated list of URLs. Optional
query Search strings, separated by “+” to filter the results. (example: “AZ+BS”). Optional
page The page of the results to return. Optional
limit Maximum number of results to retrieve. Optional

Context Output

Path Type Description
NetscoutAED.InboundBlacklistUrl.annotation Unknown List of messages associated with each URL in the inbound block list.
NetscoutAED.InboundBlacklistUrl.cid Unknown List of central configuration ID.s
NetscoutAED.InboundBlacklistUrl.url String URL address.
NetscoutAED.InboundBlacklistUrl.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistUrl.update_time Date The time that the domain was added to the list.

Command Example

!na-ed-inbound-blacklisted-urls-list limit=3

Context Example

{
    "NetscoutAED": {
        "InboundBlacklistUrl": [
            {
                "annotation": [],
                "cid": [
                    -1
                ],
                "pgid": [
                    -1
                ],
                "update_time": "2021-03-18T16:52:26.000Z",
                "url": "google.com"
            },
            {
                "annotation": [
                    "Google Maps"
                ],
                "cid": [
                    -1
                ],
                "pgid": [
                    -1
                ],
                "update_time": "2021-03-18T18:08:39.000Z",
                "url": "maps.google.com"
            },
            {
                "annotation": [
                    "Google Maps"
                ],
                "cid": [
                    -1
                ],
                "pgid": [
                    -1
                ],
                "update_time": "2021-03-18T18:08:27.000Z",
                "url": "maps.google.com/sport.com"
            }
        ]
    }
}

Human Readable Output

Blacklisted URLs

Url Pgid Cid Update Time Annotation
google.com -1 -1 2021-03-18T16:52:26.000Z  
maps.google.com -1 -1 2021-03-18T18:08:39.000Z Google Maps
maps.google.com/sport.com -1 -1 2021-03-18T18:08:27.000Z Google Maps

na-ed-inbound-blacklisted-urls-add


Adds one or more URLs to the block list by pgid or cid.

Base Command

na-ed-inbound-blacklisted-urls-add

Input

Argument Name Description Required
cid A specific central configuration ID or -1 for global. Cannot be used with the pgid parameter. Optional
pgid A specific protection group ID or -1 for global. Cannot be used with the cid parameter. Optional
url URL or a comma-separated list of URLs to add. Required
annotation A message to associate with each URL that you add to the block list. Optional

Context Output

Path Type Description
NetscoutAED.InboundBlacklistUrl.annotation Unknown List of messages associated with each url in the inbound block list.
NetscoutAED.InboundBlacklistUrl.cid Unknown List of central configuration IDs
NetscoutAED.InboundBlacklistUrl.url String URL address.
NetscoutAED.InboundBlacklistUrl.pgid Unknown List of protection group ID.
NetscoutAED.InboundBlacklistUrl.update_time Date The time that the domain was added to the list.

Command Example

!na-ed-inbound-blacklisted-urls-add url=www.goo.com

Context Example

{
    "NetscoutAED": {
        "InboundBlacklistUrl": {
            "annotation": [],
            "cid": [
                -1
            ],
            "pgid": [
                -1
            ],
            "update_time": "2021-05-24T08:58:39.000Z",
            "url": "www.goo.com"
        }
    }
}

Human Readable Output

Urls were successfully added to the inbound block listed list

Added Urls

Url Pgid Cid Update Time
www.goo.com -1 -1 2021-05-24T08:58:39.000Z

na-ed-inbound-blacklisted-urls-remove


Removes one or more URLs from the block list for a specific protection group or for all protection groups.

Base Command

na-ed-inbound-blacklisted-urls-remove

Input

Argument Name Description Required
url URL or a comma-separated list of URLs. Required

Context Output

There is no context output for this command.

Command Example

!na-ed-inbound-blacklisted-urls-remove url=www.goo.com

Human Readable Output

Urls were successfully removed from the inbound block listed list

na-ed-outbound-whitelisted-hosts-remove


Removes one or more hosts or CIDRs from the outbound allow list.

Base Command

na-ed-outbound-whitelisted-hosts-remove

Input

Argument Name Description Required
host_address A single IPv4 host address or CIDR, or a comma-separated list of IPv4 host addresses or CIDRs to remove. Required

Context Output

There is no context output for this command.

Command Example

!na-ed-outbound-whitelisted-hosts-remove host_address=3.3.3.3

Human Readable Output

Hosts were successfully removed from the outbound allow list list

Configuration parameters

  • base_url — Server URL (required)
  • insecure — Trust any certificate (not secure)
  • proxy — Use system proxy settings
  • User

Commands (31)

  • na-ed-country-code-list

    Gets a country or list of countries (country name and ISO-standardized country code).

  • na-ed-inbound-blacklisted-countries-add

    Adds one or more countries to the inbound block list by pgid or cid.

  • na-ed-inbound-blacklisted-countries-list

    Gets the inbound block listed countries. By default, 10 block listed countries are returned. To return block listed countries for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects countries that are globally block listed.

  • na-ed-inbound-blacklisted-countries-remove

    Removes one or more countries from the block list for a specific protection group or for all protection groups.

  • na-ed-inbound-blacklisted-domains-add

    Adds one or more domains to the block list by pgid or cid.

  • na-ed-inbound-blacklisted-domains-list

    Gets the block listed domains. By default, 10 block listed domains are returned. To return block listed domains for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects domains that are globally block listed.

  • na-ed-inbound-blacklisted-domains-remove

    Removes one or more domains from the block list for a specific protection group or for all protection groups.

  • na-ed-inbound-blacklisted-hosts-add

    Adds one or more hosts to the inbound block listed list.

  • na-ed-inbound-blacklisted-hosts-list

    Gets the inbound block listed hosts. By default, 10 block listed hosts are returned. To return block listed hosts for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects hosts that are globally block listed.

  • na-ed-inbound-blacklisted-hosts-remove

    Removes one or more hosts or CIDRs from the block list for a specific protection group or for all protection groups.

  • na-ed-inbound-blacklisted-hosts-replace

    Replaces all the hosts on the inbound block list.

  • na-ed-inbound-blacklisted-urls-add

    Adds one or more URLs to the block list by pgid or cid.

  • na-ed-inbound-blacklisted-urls-list

    Gets the block listed URLs. By default, 10 block listed URLs are returned. To return block listed URLs for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects URLs that are globally block listed.

  • na-ed-inbound-blacklisted-urls-remove

    Removes one or more URLs from the block list for a specific protection group or for all protection groups.

  • na-ed-inbound-whitelisted-hosts-add

    Adds one or more hosts to the inbound allow listed list.

  • na-ed-inbound-whitelisted-hosts-list

    Get the hosts on allow list. By default, 10 hosts on allow list are returned. To return hosts on allow list for specific protection groups, specify a list of protection group IDs or central configuration IDs. An ID of -1 selects hosts that are globally on allow list.

  • na-ed-inbound-whitelisted-hosts-remove

    Removes one or more hosts or CIDRs from the allow list for a specific protection group or for all protection groups.

  • na-ed-inbound-whitelisted-hosts-replace

    Replaces all the hosts on the inbound allow list.

  • na-ed-outbound-blacklisted-countries-add

    Adds one or more countries to the outbound block list.

  • na-ed-outbound-blacklisted-countries-list

    Gets the countries on the outbound block list. By default, 10 block listed countries are returned.

  • na-ed-outbound-blacklisted-countries-remove

    Removes one or more countries from the outbound block list.

  • na-ed-outbound-blacklisted-hosts-add

    Adds one or more hosts to the outbound block list.

  • na-ed-outbound-blacklisted-hosts-list

    Gets the outbound block listed hosts. By default, 10 block listed hosts are returned.

  • na-ed-outbound-blacklisted-hosts-remove

    Removes one or more hosts or CIDRS from the outbound block list.

  • na-ed-outbound-blacklisted-hosts-replace

    Replaces all the hosts on the outbound block listed list.

  • na-ed-outbound-whitelisted-hosts-add

    Adds one or more hosts to the outbound whitelisted list.

  • na-ed-outbound-whitelisted-hosts-list

    Gets the outbound hosts on allow list. By default, 10 hosts on allow list are returned.

  • na-ed-outbound-whitelisted-hosts-remove

    Removes one or more hosts or CIDRs from the outbound allow list.

  • na-ed-outbound-whitelisted-hosts-replace

    Replaces all the hosts on the outbound allow listed list.

  • na-ed-protection-groups-list

    Gets a list of the protection groups.

  • na-ed-protection-groups-update

    Updates the settings for one or more protection groups.

import copy

import demistomock as demisto
import requests
import urllib3
from CommonServerPython import *  # noqa # pylint: disable=unused-wildcard-import

from CommonServerUserPython import *  # noqa

# Disable insecure warnings
urllib3.disable_warnings()  # pylint: disable=no-member

""" CONSTANTS """

DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"  # ISO8601 format with UTC, default in XSOAR

""" CLIENT CLASS """


@logger
class Client(BaseClient):
    """
    Client class to interact with the service API
    This Client implements API calls, and does not contain any XSOAR logic.
    Should only do requests and return data.
    """

    def __init__(self, base_url, verify, api_token, proxy):
        headers = {"X-Arbux-APIToken": api_token}
        super().__init__(base_url=base_url, verify=verify, headers=headers, proxy=proxy)

    # countries
    def country_code_list_command(self, args: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/countries/", params=args)

    def outbound_blacklisted_country_list_command(self, args: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/otf/blacklisted-countries/", params=args)

    def inbound_blacklisted_country_list_command(self, args: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/protection-groups/blacklisted-countries/", params=args)

    def outbound_blacklisted_country_add_command(self, body: dict) -> list:
        return list(self._http_request(method="POST", url_suffix="/otf/blacklisted-countries/", params=body))

    def inbound_blacklisted_country_add_command(self, body: dict) -> dict:
        return self._http_request(method="POST", url_suffix="/protection-groups/blacklisted-countries/", params=body)

    def outbound_blacklisted_country_delete_command(self, body: dict) -> requests.Response:
        return self._http_request(
            method="DELETE", url_suffix="/otf/blacklisted-countries/", params=body, return_empty_response=True
        )

    def inbound_blacklisted_country_delete_command(self, body: dict) -> requests.Response:
        return self._http_request(
            method="DELETE", url_suffix="/protection-groups/blacklisted-countries/", params=body, return_empty_response=True
        )

    # host lists handlers

    def outbound_blacklisted_host_list_command(self, body: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/otf/blacklisted-hosts/", params=body)

    def outbound_whitelisted_host_list_command(self, body: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/otf/whitelisted-hosts/", params=body)

    def inbound_blacklisted_host_list_command(self, body: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/protection-groups/blacklisted-hosts/", params=body)

    def inbound_whitelisted_host_list_command(self, body: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/protection-groups/whitelisted-hosts/", params=body)

    # host addition/updates handlers

    def outbound_blacklisted_host_add_update_command(self, body: dict, http_method: str) -> dict:
        return self._http_request(
            method=http_method,
            url_suffix="/otf/blacklisted-hosts/",
            json_data=body,
            headers=merge_dicts(self._headers, {"Content-Type": "application/json"}),
        )

    def outbound_whitelisted_host_add_update_command(self, body: dict, http_method: str) -> dict:
        return self._http_request(
            method=http_method,
            url_suffix="/otf/whitelisted-hosts/",
            json_data=body,
            headers=merge_dicts(self._headers, {"Content-Type": "application/json"}),
        )

    def inbound_blacklisted_host_add_update_command(self, body: dict, http_method: str) -> dict:
        return self._http_request(
            method=http_method,
            url_suffix="/protection-groups/blacklisted-hosts/",
            json_data=body,
            headers=merge_dicts(self._headers, {"Content-Type": "application/json"}),
        )

    def inbound_whitelisted_host_add_update_command(self, body: dict, http_method: str) -> dict:
        return self._http_request(
            method=http_method,
            url_suffix="/protection-groups/whitelisted-hosts/",
            json_data=body,
            headers=merge_dicts(self._headers, {"Content-Type": "application/json"}),
        )

    # host deletion handlers

    def outbound_blacklisted_host_remove_command(self, body: dict) -> requests.Response:
        return self._http_request(method="DELETE", url_suffix="/otf/blacklisted-hosts/", params=body, return_empty_response=True)

    def outbound_whitelisted_host_remove_command(self, body: dict) -> requests.Response:
        return self._http_request(method="DELETE", url_suffix="/otf/whitelisted-hosts/", params=body, return_empty_response=True)

    def inbound_blacklisted_host_remove_command(self, body: dict) -> requests.Response:
        return self._http_request(
            method="DELETE", url_suffix="/protection-groups/blacklisted-hosts/", params=body, return_empty_response=True
        )

    def inbound_whitelisted_host_remove_command(self, body: dict) -> requests.Response:
        return self._http_request(
            method="DELETE", url_suffix="/protection-groups/whitelisted-hosts/", params=body, return_empty_response=True
        )

    # domain handlers

    def inbound_blacklisted_domain_list_command(self, body: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/protection-groups/blacklisted-domains/", params=body)

    def inbound_blacklisted_domain_add_command(self, body: dict) -> dict:
        return self._http_request(method="POST", url_suffix="/protection-groups/blacklisted-domains/", params=body)

    def inbound_blacklisted_domain_remove_command(self, body: dict) -> requests.Response:
        return self._http_request(
            method="DELETE", url_suffix="/protection-groups/blacklisted-domains/", params=body, return_empty_response=True
        )

    # url handlers

    def inbound_blacklisted_url_list_command(self, body: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/protection-groups/blacklisted-urls/", params=body)

    def inbound_blacklisted_url_add_command(self, body: dict) -> dict:
        return self._http_request(method="POST", url_suffix="/protection-groups/blacklisted-urls/", params=body)

    def inbound_blacklisted_url_remove_command(self, body: dict) -> requests.Response:
        return self._http_request(
            method="DELETE", url_suffix="/protection-groups/blacklisted-urls/", params=body, return_empty_response=True
        )

    # protection group handlers

    def protection_group_list_command(self, body: dict) -> dict:
        return self._http_request(method="GET", url_suffix="/protection-groups/", params=body)

    def protection_group_patch_command(self, body: dict) -> dict:
        return self._http_request(method="PATCH", url_suffix="/protection-groups/", params=body)


""" HELPER FUNCTIONS """


def merge_dicts(dict1: dict, dict2: dict) -> dict:
    """
    Merges two dictionaries into one dictionary.

    :type dict1: ``dict``
    :param dict1: The first dictionary.

    :type dict2: ``dict``
    :param dict2: The second dictionary.

    :return: The merged dictionary.
    :rtype: ``dict``
    """
    return {**dict1, **dict2}


def handle_args(demisto_args: dict) -> dict:
    """
    Converts the demisto server arguments into arguments which the API accepts.

    :type demisto_args: ``dict``
    :param demisto_args: The Demisto arguments dictionary.

    :return: The arguments dictionary which the API accepts.
    :rtype: ``dict``
    """
    for key in demisto_args:
        val = demisto_args[key]
        if val in ["true", "false"]:
            demisto_args[key] = argToBoolean(val)
    query = demisto_args.pop("query", None)
    if query:
        demisto_args["q"] = query
    limit = demisto_args.pop("limit", None)
    if limit:
        demisto_args["per_page"] = limit
    remove_nulls_from_dictionary(demisto_args)
    return camelize(demisto_args, "_", upper_camel=False)


def init_commands_dict() -> dict:
    """
    Initializes the legal commands dictionary.

    :return: The commands dictionary.
    :rtype: ``dict``
    """

    inbound_blacklisted = {"direction": "inbound", "list_color": "blacklist"}
    inbound_whitelisted = {"direction": "inbound", "list_color": "whitelist"}
    outbound_blacklisted = {"direction": "outbound", "list_color": "blacklist"}
    outbound_whitelisted = {"direction": "outbound", "list_color": "whitelist"}

    return {
        # test module
        "test-module": {"func": test_module},
        # countries code list
        "na-ed-country-code-list": {"func": country_code_list_command},
        # outbound blacklisted countries
        "na-ed-outbound-blacklisted-countries-list": {"func": handle_country_list_commands, "meta_data": outbound_blacklisted},
        "na-ed-outbound-blacklisted-countries-add": {"func": handle_country_addition_commands, "meta_data": outbound_blacklisted},
        "na-ed-outbound-blacklisted-countries-remove": {
            "func": handle_country_deletion_commands,
            "meta_data": outbound_blacklisted,
        },
        # inbound blacklisted countries
        "na-ed-inbound-blacklisted-countries-list": {"func": handle_country_list_commands, "meta_data": inbound_blacklisted},
        "na-ed-inbound-blacklisted-countries-add": {"func": handle_country_addition_commands, "meta_data": inbound_blacklisted},
        "na-ed-inbound-blacklisted-countries-remove": {
            "func": handle_country_deletion_commands,
            "meta_data": inbound_blacklisted,
        },
        # outbound blacklisted hosts
        "na-ed-outbound-blacklisted-hosts-list": {"func": handle_host_list_commands, "meta_data": outbound_blacklisted},
        "na-ed-outbound-blacklisted-hosts-add": {
            "func": handle_host_addition_and_replacement_commands,
            "meta_data": merge_dicts(outbound_blacklisted, {"http_method": "POST"}),
        },
        "na-ed-outbound-blacklisted-hosts-replace": {
            "func": handle_host_addition_and_replacement_commands,
            "meta_data": merge_dicts(outbound_blacklisted, {"http_method": "PUT"}),
        },
        "na-ed-outbound-blacklisted-hosts-remove": {"func": handle_host_deletion_commands, "meta_data": outbound_blacklisted},
        # inbound blacklisted hosts
        "na-ed-inbound-blacklisted-hosts-list": {"func": handle_host_list_commands, "meta_data": inbound_blacklisted},
        "na-ed-inbound-blacklisted-hosts-add": {
            "func": handle_host_addition_and_replacement_commands,
            "meta_data": merge_dicts(inbound_blacklisted, {"http_method": "POST"}),
        },
        "na-ed-inbound-blacklisted-hosts-replace": {
            "func": handle_host_addition_and_replacement_commands,
            "meta_data": merge_dicts(inbound_blacklisted, {"http_method": "PUT"}),
        },
        "na-ed-inbound-blacklisted-hosts-remove": {"func": handle_host_deletion_commands, "meta_data": inbound_blacklisted},
        # outbound whitelisted hosts
        "na-ed-outbound-whitelisted-hosts-list": {"func": handle_host_list_commands, "meta_data": outbound_whitelisted},
        "na-ed-outbound-whitelisted-hosts-add": {
            "func": handle_host_addition_and_replacement_commands,
            "meta_data": merge_dicts(outbound_whitelisted, {"http_method": "POST"}),
        },
        "na-ed-outbound-whitelisted-hosts-replace": {
            "func": handle_host_addition_and_replacement_commands,
            "meta_data": merge_dicts(outbound_whitelisted, {"http_method": "PUT"}),
        },
        "na-ed-outbound-whitelisted-hosts-remove": {"func": handle_host_deletion_commands, "meta_data": outbound_whitelisted},
        # inbound whitelisted hosts
        "na-ed-inbound-whitelisted-hosts-list": {"func": handle_host_list_commands, "meta_data": inbound_whitelisted},
        "na-ed-inbound-whitelisted-hosts-add": {
            "func": handle_host_addition_and_replacement_commands,
            "meta_data": merge_dicts(inbound_whitelisted, {"http_method": "POST"}),
        },
        "na-ed-inbound-whitelisted-hosts-replace": {
            "func": handle_host_addition_and_replacement_commands,
            "meta_data": merge_dicts(inbound_whitelisted, {"http_method": "PUT"}),
        },
        "na-ed-inbound-whitelisted-hosts-remove": {"func": handle_host_deletion_commands, "meta_data": inbound_whitelisted},
        # inbound blacklisted domains
        "na-ed-inbound-blacklisted-domains-list": {"func": handle_domain_list_commands},
        "na-ed-inbound-blacklisted-domains-add": {"func": handle_domain_addition_commands},
        "na-ed-inbound-blacklisted-domains-remove": {"func": handle_domain_deletion_commands},
        # inbound blacklisted URLs
        "na-ed-inbound-blacklisted-urls-list": {"func": handle_url_list_commands},
        "na-ed-inbound-blacklisted-urls-add": {"func": handle_url_addition_commands},
        "na-ed-inbound-blacklisted-urls-remove": {"func": handle_url_deletion_commands},
        # protection groups
        "na-ed-protection-groups-list": {"func": handle_protection_groups_list_commands},
        "na-ed-protection-groups-update": {"func": handle_protection_groups_update_commands},
    }


def objects_time_to_readable_time(list_of_objects: list, time_key: str) -> None:
    """

     Gets a list of objects with "time" key and
     Replaces the value of the field with a readable format and
     Convert all keys of a dictionary to snake_case.

    :type list_of_objects: ``list``
    :param list_of_objects: The list of objects to iterate.

    :type time_key: ``str``
    :param time_key: The time key field to change to date.

    :return: No data returned.
    :rtype: ``None``

    """
    for i, item in enumerate(list_of_objects):
        timestamp = item.get(time_key)
        if not timestamp:
            raise DemistoException("'time_key' argument is not valid")
        item[time_key] = timestamp_to_datestring(timestamp * 1000)
        list_of_objects[i] = snakify(item)


def deserialize_protection_groups(list_of_protection_groups: list) -> None:
    """

    Gets a list of objects (which represents the protection groups)
    deserializes them to a more human readable format.

    :type list_of_protection_groups: ``list``
    :param list_of_protection_groups: The list of protection groups to iterate.

    :return: No data returned.
    :rtype: ``None``

    """
    for item in list_of_protection_groups:
        active = item.get("active")
        if active is None:
            continue

        item["active"] = active == 1
        protection_level = item.get("protectionLevel")
        if protection_level:
            if protection_level == 1:
                item["protectionLevel"] = "low"
            elif protection_level == 2:
                item["protectionLevel"] = "medium"
            elif protection_level == 3:
                item["protectionLevel"] = "high"


def serialize_protection_groups(protection_group: dict) -> None:
    """

    Gets a protection group
    serializes it to the format which the api expects.

    :type protection_group: ``dict``
    :param protection_group: The protection group to serialize.

    :return: No data returned.
    :rtype: ``None``

    """
    active = protection_group.get("active")
    if active:
        protection_group["active"] = 1 if active else 0
    protection_level = protection_group.get("protectionLevel")
    if protection_level:
        if protection_level == "low":
            protection_group["protectionLevel"] = 1
        elif protection_level == "medium":
            protection_group["protectionLevel"] = 2
        elif protection_level == "high":
            protection_group["protectionLevel"] = 3
    profiling = protection_group.get("profiling")
    if profiling:
        protection_group["profiling"] = 1 if profiling else 0


""" COMMAND FUNCTIONS """


def test_module(client: Client, demisto_args: dict) -> str:
    """

    Tests API connectivity and authentication'
    Returning 'ok' indicates that the integration works like it is supposed to.
    Raises exceptions if something goes wrong.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: 'ok' if test passed, anything else will fail the test.
    :rtype: ``str``

    """
    try:
        client.country_code_list_command(demisto_args)
    except DemistoException as e:
        demisto.debug(f"Error: {e!s}")
        if "UNAUTHORIZED" in str(e) or "invalidAuthToken" in str(e):
            raise DemistoException("Test failed, make sure API Key is correctly set.", exception=e)
        elif "Error in API call" in str(e):
            raise DemistoException(f"Test failed, Error in API call [{e.res.status_code}] {e.res.reason}", exception=e)
    except Exception as e:
        demisto.debug(f"Error: {e!s}")
        raise DemistoException(f"Test failed, Please check your parameters. \n{e!s}", exception=e)
    return "ok"


def country_code_list_command(client: Client, demisto_args: dict) -> CommandResults:
    """

    Gets the countries codes and names.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: The command results which contains a dict of the countries codes and names.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    raw_result = client.country_code_list_command(demisto_args)
    countries_list = [
        {"country_name": item.get("name"), "iso_code": item.get("country")} for item in raw_result.get("countries", [])
    ]
    readable_output = tableToMarkdown(
        "Netscout AED Countries List", countries_list, removeNull=True, headerTransform=string_to_table_header
    )
    return CommandResults(
        outputs_prefix="NetscoutAED.Country",
        outputs_key_field="country_name",
        outputs=countries_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_country_list_commands(client: Client, demisto_args: dict, meta_data: dict) -> CommandResults:
    """

    Gets the countries from the inbound/outbound blacklisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :type meta_data: ``dict``
    :param meta_data: The meta data which determines if the countries list is outbound or inbound.

    :return: The command results which contains a dict of the outbound/inbound blacklisted countries.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    direction = meta_data.get("direction")
    if direction == "outbound":
        raw_result = client.outbound_blacklisted_country_list_command(demisto_args)
    else:  # inbound
        raw_result = client.inbound_blacklisted_country_list_command(demisto_args)

    name = list(raw_result.keys())[0]
    countries_list = copy.deepcopy(raw_result.get(name, []))
    objects_time_to_readable_time(countries_list, "updateTime")
    table_header = string_to_table_header(name.replace("-", " "))

    readable_output = tableToMarkdown(
        table_header,
        countries_list,
        headers=["country", "update_time", "annotation", "pgid", "cid"],
        headerTransform=string_to_table_header,
        removeNull=True,
    )

    return CommandResults(
        outputs_prefix=f"NetscoutAED.{camelize_string(direction)}BlacklistCountry",
        outputs_key_field="country",
        outputs=countries_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_country_addition_commands(client: Client, demisto_args: dict, meta_data: dict) -> CommandResults:
    """

    Adds a country to the inbound/outbound blacklisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :type meta_data: ``dict``
    :param meta_data: The meta data which determines if the countries list is outbound or inbound.

    :return: The command results which contains a dict of the added outbound/inbound blacklisted countries.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    direction = meta_data.get("direction")
    countries_to_add = demisto_args.get("country")

    if not countries_to_add:
        raise DemistoException(f"A country code must be provided in order to add it to the {direction} blacklisted list.")

    demisto_args["country"] = ",".join(argToList(countries_to_add))

    if direction == "outbound":
        raw_result: Union[dict, list] = client.outbound_blacklisted_country_add_command(demisto_args)
        countries_list = list(copy.deepcopy(raw_result))

    else:  # inbound
        raw_result = client.inbound_blacklisted_country_add_command(demisto_args)
        countries_list = copy.deepcopy(raw_result.get("countries", [raw_result]))

    objects_time_to_readable_time(countries_list, "updateTime")

    msg = f"Countries were successfully added to the {direction} blacklisted list.\n"

    readable_output = msg + tableToMarkdown(
        "Added Countries",
        countries_list,
        headers=["country", "cid", "pgid", "update_time", "annotation"],
        headerTransform=string_to_table_header,
        removeNull=True,
    )
    return CommandResults(
        outputs_prefix=f"NetscoutAED.{camelize_string(direction)}BlacklistCountry",
        outputs_key_field="country",
        outputs=countries_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_country_deletion_commands(client: Client, demisto_args: dict, meta_data: dict) -> str:
    """

    Removes a country from the inbound/outbound blacklistd list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :type meta_data: ``dict``
    :param meta_data: The meta data which determines if the countries list is outbound or inbound.

    :return: A message which says that the countries were successfully deleted from the list.
    :rtype: ``str``

    """
    demisto_args = handle_args(demisto_args)
    direction = meta_data.get("direction")
    countries_to_delete = demisto_args.get("country")
    if not countries_to_delete:
        raise DemistoException(f"A country code must be provided in order to add it to the {direction} blacklisted list.")

    demisto_args["country"] = ",".join(argToList(countries_to_delete))

    if direction == "outbound":
        raw_result = client.outbound_blacklisted_country_delete_command(demisto_args)

    else:  # inbound
        raw_result = client.inbound_blacklisted_country_delete_command(demisto_args)

    if raw_result.status_code != 204:
        raise DemistoException(f"Failed to remove the countries from the {direction} blacklisted list [{raw_result.status_code}]")

    return f"Countries were successfully removed from the {direction} blacklisted list."


def handle_host_list_commands(client: Client, demisto_args: dict, meta_data: dict) -> CommandResults:
    """

    Gets the hosts from the inbound/outbound blacklisted/whitelisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :type meta_data: ``dict``
    :param meta_data: The meta data which determines if the host list is
                      (outbound or inbound) and (blacklisted or whitelisted).

    :return: The command results which contains a dict of the outbound/inbound blacklisted/whitelisted hosts.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    direction = meta_data.get("direction")
    list_color = meta_data.get("list_color")

    if direction == "outbound":
        if list_color == "blacklist":
            raw_result = client.outbound_blacklisted_host_list_command(demisto_args)
        else:  # whitelist
            raw_result = client.outbound_whitelisted_host_list_command(demisto_args)

    else:  # inbound
        if list_color == "blacklist":
            raw_result = client.inbound_blacklisted_host_list_command(demisto_args)
        else:
            raw_result = client.inbound_whitelisted_host_list_command(demisto_args)

    name = list(raw_result.keys())[0]
    hosts_list = copy.deepcopy(raw_result.get(name, []))
    objects_time_to_readable_time(hosts_list, "updateTime")
    table_header = string_to_table_header(name.replace("-", " "))
    readable_output = tableToMarkdown(
        table_header,
        hosts_list,
        headers=["host_address", "cid", "pgid", "update_time", "annotation"],
        headerTransform=string_to_table_header,
        removeNull=True,
    )

    return CommandResults(
        outputs_prefix=f"NetscoutAED.{camelize_string(direction)}{camelize_string(list_color)}Host",
        outputs_key_field="host_address",
        outputs=hosts_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_host_addition_and_replacement_commands(client: Client, demisto_args: dict, meta_data: dict) -> CommandResults:
    """

    Adds hosts to the inbound/outbound blacklisted/whitelisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :type meta_data: ``dict``
    :param meta_data: The meta data which determines if the host list is
                      (outbound or inbound) and (blacklist or whitelist).

    :return: The command results which contains a dict of the added/replaced hosts in the
             outbound/inbound blacklisted/whitelisted list.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    direction = meta_data.get("direction")
    list_color = meta_data.get("list_color")
    http_method = str(meta_data.get("http_method"))

    host_address = demisto_args.get("hostAddress")
    if not host_address:
        raise DemistoException(f"A host address must be provided in order to add/update it in the {direction} {list_color} list.")

    demisto_args["hostAddress"] = argToList(host_address)

    if direction == "outbound":
        if list_color == "blacklist":
            raw_result = client.outbound_blacklisted_host_add_update_command(demisto_args, http_method)
        else:  # whitelist
            raw_result = client.outbound_whitelisted_host_add_update_command(demisto_args, http_method)

    else:  # inbound
        if list_color == "blacklist":
            raw_result = client.inbound_blacklisted_host_add_update_command(demisto_args, http_method)
        else:
            raw_result = client.inbound_whitelisted_host_add_update_command(demisto_args, http_method)

    hosts_list = copy.deepcopy(raw_result.get("hosts", [raw_result]))

    msg_method = "added to" if http_method == "POST" else "replaced in"

    msg = f"Hosts were successfully {msg_method} the {direction} {list_color} list\n"

    objects_time_to_readable_time(hosts_list, "updateTime")

    readable_output = msg + tableToMarkdown(
        "New Hosts",
        hosts_list,
        headers=[
            "host_address",
            "pgid",
            "cid",
            "update_time",
            "annotation",
        ],
        headerTransform=string_to_table_header,
        removeNull=True,
    )

    return CommandResults(
        outputs_prefix=f"NetscoutAED.{camelize_string(direction)}{camelize_string(list_color)}Host",
        outputs_key_field="host_address",
        outputs=hosts_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_host_deletion_commands(client: Client, demisto_args: dict, meta_data: dict) -> str:
    """

    Removes hosts from the inbound/outbound blacklisted/whitelisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :type meta_data: ``dict``
    :param meta_data: The meta data which determines if the host list is
                      (outbound or inbound) and (blacklist or whitelist).

    :return: A message which says that the hosts were successfully deleted from the list.
    :rtype: ``str``

    """
    demisto_args = handle_args(demisto_args)
    direction = meta_data.get("direction")
    list_color = meta_data.get("list_color")
    host_address = demisto_args.get("hostAddress")

    if not host_address:
        raise DemistoException(f"A host address must be provided in order to remove it from the {direction} {list_color} list.")

    demisto_args["hostAddress"] = ",".join(argToList(host_address))

    if direction == "outbound":
        if list_color == "blacklist":
            raw_result = client.outbound_blacklisted_host_remove_command(demisto_args)
        else:
            raw_result = client.outbound_whitelisted_host_remove_command(demisto_args)

    else:  # inbound
        if list_color == "blacklist":
            raw_result = client.inbound_blacklisted_host_remove_command(demisto_args)
        else:
            raw_result = client.inbound_whitelisted_host_remove_command(demisto_args)

    if raw_result.status_code != 204:
        raise DemistoException(f"Failed to remove the hosts from the {direction} {list_color} list [{raw_result.status_code}]")

    return f"Hosts were successfully removed from the {direction} {list_color} list"


def handle_protection_groups_list_commands(client: Client, demisto_args: dict) -> CommandResults:
    """

    Gets the list of protections groups.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: The command results which contains a list of the protection groups.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    serialize_protection_groups(demisto_args)
    raw_result = client.protection_group_list_command(demisto_args)
    protection_group_list = copy.deepcopy(raw_result.get("protection-groups", []))
    deserialize_protection_groups(protection_group_list)
    objects_time_to_readable_time(protection_group_list, "timeCreated")

    headers = [
        "name",
        "pgid",
        "protection_level",
        "active",
        "server_name",
        "profiling",
        "profiling_duration",
        "time_created",
        "description",
    ]

    readable_output = tableToMarkdown(
        "Protection Groups", protection_group_list, headers=headers, headerTransform=string_to_table_header, removeNull=True
    )

    return CommandResults(
        outputs_prefix="NetscoutAED.ProtectionGroup",
        outputs_key_field="pgid",
        outputs=protection_group_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_protection_groups_update_commands(client: Client, demisto_args: dict) -> CommandResults:
    """

    Updates the settings for one or more protection groups (pgid is required).

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: The command results which contains a dict of updated protection groups.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    pgid = demisto_args.get("pgid")
    if not pgid:
        raise DemistoException("A pgid must be provided in order to update the protection group.")
    if demisto_args.get("profiling") and not demisto_args.get("profiling_duration"):
        raise DemistoException("A profiling duration must be provided when profiling is set to true.")

    serialize_protection_groups(demisto_args)
    raw_result = client.protection_group_patch_command(demisto_args)
    protection_groups_list = copy.deepcopy(raw_result.get("protection-groups", [raw_result]))
    deserialize_protection_groups(protection_groups_list)
    objects_time_to_readable_time(protection_groups_list, "timeCreated")
    headers = [
        "name",
        "pgid",
        "protection_level",
        "active",
        "server_name",
        "profiling",
        "profiling_duration",
        "time_created",
        "description",
    ]
    msg = f"Successfully updated the protection group object with protection group id: {pgid}\n"

    readable_output = msg + tableToMarkdown(
        "Protection Groups", protection_groups_list, headers=headers, headerTransform=string_to_table_header, removeNull=True
    )

    return CommandResults(
        outputs_prefix="NetscoutAED.ProtectionGroup",
        outputs_key_field="pgid",
        outputs=protection_groups_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_domain_list_commands(client: Client, demisto_args: dict) -> CommandResults:
    """

    Gets the domains from the inbound blacklisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: The command results which contains a list of the inbound blacklisted domains.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    raw_result = client.inbound_blacklisted_domain_list_command(demisto_args)

    domains_list = copy.deepcopy(raw_result.get("blacklisted-domains", []))
    objects_time_to_readable_time(domains_list, "updateTime")

    readable_output = tableToMarkdown(
        "Blacklisted Domains",
        domains_list,
        headers=["domain", "pgid", "cid", "update_time", "annotation"],
        headerTransform=string_to_table_header,
        removeNull=True,
    )

    return CommandResults(
        outputs_prefix="NetscoutAED.InboundBlacklistDomain",
        outputs_key_field="domain",
        outputs=domains_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_domain_addition_commands(client: Client, demisto_args: dict) -> CommandResults:
    """

    Adds the domains to the inbound blacklisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: The command results which contains the added domains to the inbound blacklisted list.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    domain = demisto_args.get("domain")
    if not domain:
        raise DemistoException("A domain must be provided in order to add it to the inbound blacklisted list.")

    demisto_args["domain"] = ",".join(argToList(domain))

    raw_result = client.inbound_blacklisted_domain_add_command(demisto_args)
    domains_list = copy.deepcopy(raw_result.get("domains", [raw_result]))

    msg = "Domains were successfully added to the inbound blacklisted list\n"

    objects_time_to_readable_time(domains_list, "updateTime")

    readable_output = msg + tableToMarkdown(
        "Added Domains",
        domains_list,
        headers=["domain", "pgid", "cid", "update_time", "annotation"],
        headerTransform=string_to_table_header,
        removeNull=True,
    )

    return CommandResults(
        outputs_prefix="NetscoutAED.InboundBlacklistDomain",
        outputs_key_field="domain",
        outputs=domains_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_domain_deletion_commands(client: Client, demisto_args: dict) -> str:
    """

    Removes domains from the inbound blacklisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: A message which says that the domains were successfully deleted from the list.
    :rtype: ``str``

    """
    demisto_args = handle_args(demisto_args)
    domain = demisto_args.get("domain")
    if not domain:
        raise DemistoException("A domain must be provided in order to remove it from the inbound blacklisted list.")

    demisto_args["domain"] = ",".join(argToList(domain))

    raw_result = client.inbound_blacklisted_domain_remove_command(demisto_args)
    if raw_result.status_code != 204:
        raise DemistoException(f"Failed to remove the Domains from the inbound blacklisted list [{raw_result.status_code}]")

    return "Domains were successfully removed from the inbound blacklisted list"


def handle_url_list_commands(client: Client, demisto_args: dict) -> CommandResults:
    """

    Gets the URLs from the inbound blacklisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: The command results which contains a list of the inbound blacklisted URLs.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    raw_result = client.inbound_blacklisted_url_list_command(demisto_args)

    urls_list = copy.deepcopy(raw_result.get("blacklisted-urls", []))
    objects_time_to_readable_time(urls_list, "updateTime")

    readable_output = tableToMarkdown(
        "Blacklisted URLs",
        urls_list,
        headers=["url", "pgid", "cid", "update_time", "annotation"],
        headerTransform=string_to_table_header,
        removeNull=True,
    )

    return CommandResults(
        outputs_prefix="NetscoutAED.InboundBlacklistUrl",
        outputs_key_field="url",
        outputs=urls_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_url_addition_commands(client: Client, demisto_args: dict) -> CommandResults:
    """

    Adds the URLs to the inbound blacklisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: The command results which contains the added URLs to the inbound blacklisted list.
    :rtype: ``CommandResults``

    """
    demisto_args = handle_args(demisto_args)
    url = demisto_args.get("url")
    if not url:
        raise DemistoException("A URL must be provided in order to add it to the inbound blacklisted list.")

    demisto_args["url"] = ",".join(argToList(url))

    raw_result = client.inbound_blacklisted_url_add_command(demisto_args)
    urls_list = copy.deepcopy(raw_result.get("urls", [raw_result]))
    msg = "Urls were successfully added to the inbound blacklisted list\n"

    objects_time_to_readable_time(urls_list, "updateTime")

    readable_output = msg + tableToMarkdown(
        "Added Urls",
        urls_list,
        headers=["url", "pgid", "cid", "update_time", "annotation"],
        headerTransform=string_to_table_header,
        removeNull=True,
    )

    return CommandResults(
        outputs_prefix="NetscoutAED.InboundBlacklistUrl",
        outputs_key_field="url",
        outputs=urls_list,
        raw_response=raw_result,
        readable_output=readable_output,
    )


def handle_url_deletion_commands(client: Client, demisto_args: dict) -> str:
    """

    Removes URLs from the inbound blacklisted list.

    :type client: ``Client``
    :param client: Client to use.

    :type demisto_args: ``dict``
    :param demisto_args: The demisto arguments.

    :return: A message which says that the URLs were successfully deleted from the list.
    :rtype: ``str``

    """
    demisto_args = handle_args(demisto_args)
    url = demisto_args.get("url")
    if not url:
        raise DemistoException("A URL must be provided in order to remove it from the inbound blacklisted list.")

    demisto_args["url"] = ",".join(argToList(url))
    raw_result = client.inbound_blacklisted_url_remove_command(demisto_args)
    if raw_result.status_code != 204:
        raise DemistoException(f"Failed to remove the URLs from the inbound blacklisted list [{raw_result.status_code}]")

    return "URLs were successfully removed from the inbound blacklisted list"


""" MAIN FUNCTION """


def main() -> None:
    params = demisto.params()
    demisto_command = demisto.command()
    demisto_args = demisto.args()
    try:
        base_url: str = urljoin(params.get("base_url", "").rstrip("/"), "/api/aed/v2")
        verify_certificate: bool = not params.get("insecure", False)
        proxy: bool = params.get("proxy", False)
        if not params.get("User") or not (api_token := params.get("User", {}).get("password")):
            raise DemistoException("Missing API Key. Please fill in a valid key in the integration configuration.")
        commands = init_commands_dict()
        handle_proxy()
        client = Client(base_url=base_url, verify=verify_certificate, api_token=api_token, proxy=proxy)

        if not demisto_command or demisto_command not in commands:
            raise NotImplementedError(f"Command {demisto_command} is not implemented.")

        demisto.debug(f"Command being called is {demisto_command}")
        func_to_execute = dict_safe_get(commands, [demisto_command, "func"])
        meta_data = dict_safe_get(commands, [demisto_command, "meta_data"])
        results = func_to_execute(client, demisto_args, meta_data) if meta_data else func_to_execute(client, demisto_args)
        return_results(results)

    # Log exceptions
    except Exception as e:
        return_error(f"Failed to execute {demisto.command()} command. Error: {e!s}", error=e)


""" ENTRY POINT """

if __name__ in ("__main__", "__builtin__", "builtins"):
    main()