VersaDirector

Versa Director is a virtualization and service creation platform that simplifies the design, automation, and delivery of SASE services. Versa Director provides the essential management, monitoring, and orchestration capabilities needed to deliver all of the networking and security capabilities within Versa SASE.

Network Security · VersaDirector

Details

IDVersaDirector
ProviderVersa Networks
CategoryNetwork Security
From Version6.5.0
Docker Imagedemisto/python3:3.12.13.10116658
Supported ModulesAgentix XSIAM

README

Versa Director is a virtualization and service creation platform that simplifies the design, automation, and delivery of SASE services. Versa Director provides the essential management, monitoring and orchestration capabilities needed to deliver all of the networking and security capabilities within Versa SASE.
This integration was integrated and tested with version 1.0.0 of VersaDirector

Configure Versa Director in Cortex

Parameter Description Required
Your server URL   True
Organization Name Used by any command that requires organization argument. should be passed as parameter in configuration or as command argument. False
Username Username parameter is used for Basic Authentication. False
Password Password parameter is used for Basic Authentication. False
Use Basic Authentication Check this checkbox to use the basic authentication method. Auth Token authentication will be used by default. To use basic authentication method, please enter Username and Password parameters. False
Client ID The Client ID parameter is used for Auth authentication. Used together with Client Secret parameter. False
Client Secret The Client Secret parameter is used for Auth authentication. Used together with Client ID parameter. False
Auth Token The Auth Token parameter is used for Auth authentication.
An Auth Token passed as a parameter take priority over an Auth Token saved in the integration context by default.
If a Refresh Token is available, a new Auth Token is generated when an existing Auth Token expires, and it is then updated in the integration context.
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.

vd-auth-start


Obtain an access token from the API client. If Client ID and Client Secret were not passed as parameters or arguments, a new Auth Client will be created.

Base Command

vd-auth-start

Input

Argument Name Description Required
auth_client_name Name of Auth Client. If an excised token name will be given as argument, an error might occur. Optional
description Description of the access token. Optional
client_id Client ID for Token Authentication. If already passed as a parameter it will be prioritized by default. Optional
client_secret Client Secret for Token Authentication. If already passed as a parameter it will be prioritized by default. Optional

Context Output

Path Type Description
VersaDirector.AuthClient String Auth Client Credentials.

Command example

!vd-auth-start auth_client_name=example_client description="example client"

Context Example

{
    "VersaDirector": {
        "AuthClient": {
            "client_id": "example_client_id",
            "client_name": "example_client"
        }
    }
}

Human Readable Output

Auth Client Created Successfully.
Client ID: example_client_id, Auth Client Name: example_client.

Authentication request was successful, Auth Token was created and saved in the Integration Context.
Please uncheck the ‘Use Basic Authentication’ in the configuration screen.
To ensure the authentication is valid, run the ‘vd-auth-test’ command.

vd-auth-test


Run a connectivity test to verify that the OAuth process worked.

Base Command

vd-auth-test

Input

There are no input arguments for this command.

Context Output

There is no context output for this command.

Command example


#### Human Readable Output

>Auth Token Authentication method connectivity verified.

### vd-predefined-application-list

***
List all user predefined application objects.

#### Base Command

`vd-predefined-application-list`

#### Input

| **Argument Name** | **Description** | **Required** |
| --- | --- | --- |
| family | Group type of application. Possible values are: business-system, collaboration, general-internet, media, networking. | Optional |
| risks | Risks threshold. This value must be equal to or higher than the input. | Optional |
| tags | A comma-separated list of tags. | Optional |
| page | The page number of the results to retrieve. | Optional |
| page_size | The maximum number of objects to retrieve per page. Default is 0. | Optional |
| limit | The maximum number of results. | Optional |

#### Context Output

| **Path** | **Type** | **Description** |
| --- | --- | --- |
| VersaDirector.PredefinedApplication.name | string | A comma-separated list of predefined applications's name. |
| VersaDirector.PredefinedApplication.family | string | A comma-separated list of predefined applications family type. |
| VersaDirector.PredefinedApplication.subfamily | string | Predefined sub-group family application type. |
| VersaDirector.PredefinedApplication.description | string | A comma-separated list of predefined applications description. |
| VersaDirector.PredefinedApplication.risk | string | A comma-separated list of predefined applications risks threshold. This value is equal to or higher than the input. |
| VersaDirector.PredefinedApplication.productivity | string | A comma-separated list of predefined applications productivity. |
| VersaDirector.PredefinedApplication.tag | string | A comma-separated list of predefined applications tag. |

#### Command example

```!vd-predefined-application-list limit=1```

#### Context Example

```json
{
    "File": {
        "Comment": "Return result too large, uploaded as a file",
        "EntryID": "EXAMPLE_HASH",
        "Info": "text/plain",
        "MD5": "EXAMPLE_HASH",
        "Name": "Result file",
        "SHA1": "EXAMPLE_HASH",
        "SHA256": "EXAMPLE_HASH",
        "SHA512": "EXAMPLE_HASH",
        "SSDeep": "EXAMPLE_HASH",
        "Size": 10000,
        "Type": "ASCII text, with very long lines (499)"
    },
    "VersaDirector": {
        "PredefinedApplication": [
            {
                "bandwidth": "1000",
                "deprecated": "0",
                "family": "general-internet",
                "flexvnf": "N/A",
                "ips": "0",
                "subfamily": "web",
                "tag": [
                    "tag1",
                    "tag2"
                ],
            },
        ]
    }
}

Human Readable Output

Return result too large, uploaded as a file

vd-appliance-user-modified-application-list


List all user modified predefined application objects associated with a specific organization and appliance (device).

Base Command

vd-appliance-user-modified-application-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results. Optional

Context Output

Path Type Description
VersaDirector.ApplianceUserModifiedApplication.app-specific-option-list.app-name string Appliance user modified application name.
VersaDirector.ApplianceUserModifiedApplication.app-specific-option-list.app-risk string Appliance user modified application risk threshold.
VersaDirector.ApplianceUserModifiedApplication.app-specific-option-list.app-productivity string Appliance user modified application productivity.
VersaDirector.ApplianceUserModifiedApplication.app-specific-option-list.app-timeout string Appliance user modified application timeout.
VersaDirector.ApplianceUserModifiedApplication.app-specific-option-list.app-final-with-endpoint string Appliance user modified application final endpoint.

Command example

!vd-appliance-user-modified-application-list appliance_name=EXAMPLE_BRANCH limit=3

Human Readable Output

Empty response has returned from vd-appliance-user-modified-application-list command.
Message:
Error in API call [204]

vd-template-user-modified-application-list


List all user modified predefined application objects associated with a specific organization and template.

Base Command

vd-template-user-modified-application-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results. Optional

Context Output

Path Type Description
VersaDirector.TemplateUserModifiedApplication.app-specific-option-list.app-name string Template user modified application name.
VersaDirector.TemplateUserModifiedApplication.app-specific-option-list.app-risk string Template user modified application risk threshold.
VersaDirector.TemplateUserModifiedApplication.app-specific-option-list.app-productivity string Template user modified application productivity.
VersaDirector.TemplateUserModifiedApplication.app-specific-option-list.app-timeout string Template user modified application timeout.
VersaDirector.TemplateUserModifiedApplication.app-specific-option-list.app-final-with-endpoint string Template user modified application final endpoint.

Command example

!vd-template-user-mod-Default-Application limit=3

Context Example

{
    "VersaDirector": {
        "TemplateUserModifiedApplication": {
            "app-final-with-endpoint": "false",
            "app-name": "NAME",
            "app-productivity": "3",
            "app-risk": "3",
            "app-timeout": "300"
        }
    }
}

Human Readable Output

User modified predefined application objects associated with EXAMPLE_CLIENT

App - Name App - Risk App - Productivity App - Timeout App - Final - With - Endpoint
TEST 3 3 300 false

vd-appliance-user-defined-application-list


List all user defined application objects associated with a specific organization and appliance (device).

Base Command

vd-appliance-user-defined-application-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results. Optional

Context Output

Path Type Description
VersaDirector.ApplianceUserDefinedApplication.user-defined-application.app-name string Appliance user defined application name.
VersaDirector.ApplianceUserDefinedApplication.user-defined-application.description string Appliance user defined application description.
VersaDirector.ApplianceUserDefinedApplication.user-defined-application.precedence string Appliance user defined application precedence.
VersaDirector.ApplianceUserDefinedApplication.user-defined-application.tag string Appliance user defined application tag.
VersaDirector.ApplianceUserDefinedApplication.user-defined-application.risk string Appliance user defined application risk threshold.
VersaDirector.ApplianceUserDefinedApplication.user-defined-application.family string Appliance user defined application family.

Command example

!vd-appliance-user-defined-application-list appliance_name=EXAMPLE_BRANCH limit=3

Human Readable Output

Empty response has returned from vd-appliance-user-defined-application-list command.
Message:
Error in API call [204]

vd-template-user-defined-application-list


List all user defined application objects associated with a specific organization and template.

Base Command

vd-template-user-defined-application-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results. Optional

Context Output

Path Type Description
VersaDirector.TemplateUserDefinedApplication.user-defined-application.app-name string Template user defined application name.
VersaDirector.TemplateUserDefinedApplication.user-defined-application.description string Template user defined application description.
VersaDirector.TemplateUserDefinedApplication.user-defined-application.precedence string Template user defined application precedence.
VersaDirector.TemplateUserDefinedApplication.user-defined-application.tag string Template user defined application tag.
VersaDirector.TemplateUserDefinedApplication.user-defined-application.risk string Template user defined application risk threshold.
VersaDirector.TemplateUserDefinedApplication.user-defined-application.family string Template user defined application family.

Command example

!vd-template-user-defined-application-list template_name=EXAMPLE_CLIENT-Default-Application limit=3

Context Example

{
    "VersaDirector": {
        "TemplateUserDefinedApplication": [
            {
                "app-match-ips": "false",
                "app-name": "TestApplication",
                "description": "This is a test from UI",
                "family": "collaboration",
                "precedence": "65",
                "productivity": "3",
                "risk": "3",
                "subfamily": "custom",
                "tag": [
                    "tag1",
                    "tag2",
                ]
            },
            {
                "app-match-ips": "false",
                "app-match-rules": {
                    "rule-name": null
                },
                "app-name": "TestCustomApp",
                "app-timeout": "300",
                "description": "Test custom app creation from API",
                "family": null,
                "precedence": "95",
                "productivity": "5",
                "risk": "5",
                "subfamily": null,
                "tag": "tag3"
            }
        ]
    }
}

Human Readable Output

A comma-separated list of user defined applications objects associated with EXAMPLE_CLIENT

App - Name Description Precedence Tag Risk Family
TestApplication This is a test from UI 65 values: tag2, v_cloud, vs_evasive 3 collaboration
TestCustomApp Test custom app creation from API 95 tag2 5  

vd-appliance-address-object-delete


Delete an address object associated with a specific organization and appliance (device).

Base Command

vd-appliance-address-object-delete

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
object_name Address object name. Required

Context Output

There is no context output for this command.

Command example

!vd-appliance-address-object-delete object_name=Bad-Address appliance_name=EXAMPLE_BRANCH

Human Readable Output

Command run successfully.

vd-appliance-address-object-edit


Edit an address object associated with a specific organization and appliance (device).

Base Command

vd-appliance-address-object-edit

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
object_name Address object name. Required
description Address object description. Optional
tags A comma-separated list of tags. Optional
address_object_type Address object type. Possible values are: ipv4-prefix, ipv4-range, ipv4-wildcard-mask, ipv6-prefix, fqdn, dynamic-address. Required
object_value Object value. Required

Context Output

Path Type Description
VersaDirector.TemplateAddressObject.name string Template address object name.
VersaDirector.TemplateAddressObject.tag string Template Address object tag.
VersaDirector.TemplateAddressObject.description string Template address object description.
VersaDirector.TemplateAddressObject.ipv4-prefix string Template address object IPv4 prefix
VersaDirector.TemplateAddressObject.ipv4-range string Template address object IPv4 range.
VersaDirector.TemplateAddressObject.ipv4-wildcard-mask string Template address object IPv4 wildcard mask.
VersaDirector.TemplateAddressObject.ipv6-prefix string Template address object IPv6 prefix.
VersaDirector.TemplateAddressObject.fqdn string Template address object FQDN.
VersaDirector.TemplateAddressObject.dynamic-address string Template address object dynamic address.

Command example

!vd-appliance-address-object-edit appliance_name=EXAMPLE_BRANCH address_object_type=fqdn object_value=test1.com,test2.com object_name=Bad-Address description="changed"

Human Readable Output

Command run successfully.
Request Body:

{‘address’: {‘name’: ‘Bad-Address’, ‘description’: ‘changed’, ‘tag’: [], ‘fqdn’: ‘test1.com,test2.com’}}

vd-appliance-address-object-create


Create an address object associated with a specific organization and appliance (device).

Base Command

vd-appliance-address-object-create

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
object_name Address object name. Required
description Address object description. Required
tags A comma-separated list of tags. Optional
address_object_type Address object type. Possible values are: ipv4-prefix, ipv4-range, ipv4-wildcard-mask, ipv6-prefix, fqdn, dynamic-address. Required
object_value Object value. Required

Context Output

Path Type Description
VersaDirector.TemplateAddressObject.name string Template address object name.
VersaDirector.TemplateAddressObject.tag string Template Address object tag.
VersaDirector.TemplateAddressObject.description string Template address object description.
VersaDirector.TemplateAddressObject.ipv4-prefix string Template address object IPv4 prefix
VersaDirector.TemplateAddressObject.ipv4-range string Template address object IPv4 range.
VersaDirector.TemplateAddressObject.ipv4-wildcard-mask string Template address object IPv4 wildcard mask.
VersaDirector.TemplateAddressObject.ipv6-prefix string Template address object IPv6 prefix.
VersaDirector.TemplateAddressObject.fqdn string Template address object FQDN.
VersaDirector.TemplateAddressObject.dynamic-address string Template address object dynamic address.

Command example

!vd-appliance-address-object-create appliance_name=EXAMPLE_BRANCH address_object_type=fqdn object_value=test1.com,test2.com object_name=Bad-Address description="test"

Human Readable Output

Command run successfully.
Request Body:

{‘address’: {‘name’: ‘Bad-Address’, ‘description’: ‘test’, ‘tag’: [], ‘fqdn’: ‘test1.com,test2.com’}}

vd-appliance-address-object-list


List all address objects associated with a specific organization and appliance (device).

Base Command

vd-appliance-address-object-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.ApplianceAddressObject.name string Appliance address object name.
VersaDirector.ApplianceAddressObject.description string Appliance address object description.
VersaDirector.ApplianceAddressObject.tag string Appliance address object tag.
VersaDirector.ApplianceAddressObject.ipv4-prefix string Appliance address object ipv4-prefix.
VersaDirector.ApplianceAddressObject.fqdn string Appliance address object FQDN.

Command example

!vd-appliance-address-object-list appliance_name=EXAMPLE_BRANCH limit=3

Context Example

{
    "VersaDirector": {
        "ApplianceAddressObject": [
            {
                "ipv4-prefix": "EXAMPLE_URL/32",
                "name": "Bad-Address-1",
                "tag": "test"
            },
            {
                "fqdn": "test1.com",
                "name": "Bad-Address-2"
            },
            {
                "ipv4-prefix": "EXAMPLE_URL/32",
                "name": "Bad-Address-4"
            }
        ]
    }
}

Human Readable Output

Address objects associated with EXAMPLE_CLIENT

Name Tag Ipv 4- Prefix Fqdn
Bad-Address-1 test EXAMPLE_URL/32  
Bad-Address-2     test1.com
Bad-Address-4   EXAMPLE_URL/32  

vd-template-address-object-delete


Delete an address object associated with a specific organization and template.

Base Command

vd-template-address-object-delete

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
object_name Address object name. Required

Context Output

There is no context output for this command.

Command example

!vd-template-address-object-delete template_name=EXAMPLE_CLIENT-Default-Application object_name=Bad-Address

Human Readable Output

Command run successfully.

vd-template-address-object-edit


Create an address object associated with a specific organization and template.

Base Command

vd-template-address-object-edit

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
object_name Address object name. Required
description Address object description. Optional
tags A comma-separated list of tags. Optional
address_object_type Address object type. Possible values are: ipv4-prefix, ipv4-range, ipv4-wildcard-mask, ipv6-prefix, fqdn, dynamic-address. Required
object_value Object value. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.TemplateAddressObject.name string Template address object name.
VersaDirector.TemplateAddressObject.tag string Template Address object tag.
VersaDirector.TemplateAddressObject.description string Template address object description.
VersaDirector.TemplateAddressObject.ipv4-prefix string Template address object IPv4 prefix
VersaDirector.TemplateAddressObject.ipv4-range string Template address object IPv4 range.
VersaDirector.TemplateAddressObject.ipv4-wildcard-mask string Template address object IPv4 wildcard mask.
VersaDirector.TemplateAddressObject.ipv6-prefix string Template address object IPv6 prefix.
VersaDirector.TemplateAddressObject.fqdn string Template address object FQDN.
VersaDirector.TemplateAddressObject.dynamic-address string Template address object dynamic address.

Command example

!vd-template-address-object-edit template_name=EXAMPLE_CLIENT-Default-Application address_object_type=fqdn object_value=test.com object_name=Bad-Address description="changed"

Human Readable Output

Command run successfully.
Request Body:

{‘address’: {‘name’: ‘Bad-Address’, ‘description’: ‘changed’, ‘tag’: [], ‘fqdn’: ‘test.com’}}

vd-template-address-object-create


Create an address object associated with a specific organization and template.

Base Command

vd-template-address-object-create

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
object_name Address object name. Required
description Address object description. Optional
tags A comma-separated list of tags. Optional
address_object_type Address object type. Possible values are: ipv4-prefix, ipv4-range, ipv4-wildcard-mask, ipv6-prefix, fqdn, dynamic-address. Required
object_value Object value. Required

Context Output

Path Type Description
VersaDirector.TemplateAddressObject.name string Template address object name.
VersaDirector.TemplateAddressObject.tag string Template Address object tag.
VersaDirector.TemplateAddressObject.description string Template address object description.
VersaDirector.TemplateAddressObject.ipv4-prefix string Template address object IPv4 prefix
VersaDirector.TemplateAddressObject.ipv4-range string Template address object IPv4 range.
VersaDirector.TemplateAddressObject.ipv4-wildcard-mask string Template address object IPv4 wildcard mask.
VersaDirector.TemplateAddressObject.ipv6-prefix string Template address object IPv6 prefix.
VersaDirector.TemplateAddressObject.fqdn string Template address object FQDN.
VersaDirector.TemplateAddressObject.dynamic-address string Template address object dynamic address.

Command example

!vd-template-address-object-create template_name=EXAMPLE_CLIENT-Default-Application address_object_type=fqdn object_value=test.com object_name=Bad-Address description="test"

Human Readable Output

Command run successfully.
Request Body:

{‘address’: {‘name’: ‘Bad-Address’, ‘description’: ‘test’, ‘tag’: [], ‘fqdn’: ‘test.com’}}

vd-template-address-object-list


List all address objects associated with a specific organization and template.

Base Command

vd-template-address-object-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.TemplateAddressObject.name string Template address object name.
VersaDirector.TemplateAddressObject.description string Template address object description.
VersaDirector.TemplateAddressObject.tag string Template Address object tag.
VersaDirector.TemplateAddressObject.ipv4-prefix string Template address object IPv4 prefix
VersaDirector.TemplateAddressObject.fqdn string Template address object FQDN.

Command example

!vd-template-address-object-list template_name=EXAMPLE_CLIENT-Default-Application limit=3

Context Example

{
    "VersaDirector": {
        "TemplateAddressObject": [
            {
                "description": "None",
                "ipv4-wildcard-mask": "MASK",
                "name": "Bad-Address-2",
                "tag": "['badAddress,veryBadAddress']"
            },
            {
                "description": "None",
                "ipv4-prefix": "1.1.1.1",
                "name": "Bad-Address-1",
                "tag": "[]"
            },
            {
                "description": "test bad addrees 4",
                "fqdn": "test4.com",
                "name": "Bad-Address-4",
                "tag": "[]"
            }
        ]
    }
}

Human Readable Output

Address objects associated with EXAMPLE_CLIENT

Name Description Tag Ipv 4- Prefix Fqdn Ipv 4- Wildcard - Mask
Bad-Address-2 None [‘badAddress,veryBadAddress’]     MASK
Bad-Address-1 None [] 1.1.1.1    
Bad-Address-4 test bad addrees 4 []   test4.com  

vd-appliance-sdwan-policy-rule-delete


Delete an SDWAN policy rule associated with a specific appliance (device).

Base Command

vd-appliance-sdwan-policy-rule-delete

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
sdwan_policy_name Name of the SDWAN policy. Required
rule_name Name of the rule. Required

Context Output

There is no context output for this command.

Command example

!vd-appliance-sdwan-policy-rule-delete appliance_name=EXAMPLE_BRANCH rule_name=test_rule sdwan_policy_name=Default-Policy

Human Readable Output

Command run successfully.

vd-appliance-sdwan-policy-rule-edit


Edit an SDWAN policy rule associated with a specific appliance (device).

Base Command

vd-appliance-sdwan-policy-rule-edit

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
sdwan_policy_name Name of the SDWAN policy. Required
custom_rule_json Allows the use of the Custom SDWAN Rule JSON template. All of the arguments listed below will be overridden. For an example, see the integration documentation. Optional
rule_name Name of the rule. Required
description SDWAN policy description. Optional
tags A comma-separated list of tags. Optional
source_address_objects A comma-separated list of source address objects. Optional
destination_address_objects A comma-separated list of destination address objects. Optional
url_reputation A comma-separated list of URL reputations. Optional
custom_url_categories A comma-separated list of custom URL categories. Optional
forwarding_action Forwarding action. Possible values are: allow, deny. Required
nexthop_ip Nexthop IP. Optional
routing_instance Routing instance. Optional
forwarding_profile Forwarding profile. Optional
predefined_application A comma-separated list of predefined applications. Optional
user_defined_application A comma-separated list of user defined applications. Optional

Context Output

There is no context output for this command.

vd-appliance-sdwan-policy-rule-create


Create an SDWAN policy rule associated with a specific appliance (device).

Base Command

vd-appliance-sdwan-policy-rule-create

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
sdwan_policy_name Name of the SDWAN policy. Required
custom_rule_json Allows the use of the Custom SDWAN Rule JSON template. All of the arguments listed below will be overridden. For an example, see the integration documentation. Optional
rule_name Name of the rule. Required
description SDWAN policy description. Optional
tags A comma-separated list of tags. Optional
source_address_objects A comma-separated list of source address objects. Optional
destination_address_objects A comma-separated list of destination address objects. Optional
url_reputation A comma-separated list of URL reputations. Optional
custom_url_categories A comma-separated list of custom URL categories. Optional
forwarding_action Forwarding action. Possible values are: allow, deny. Required
nexthop_ip Nexthop IP. Optional
routing_instance Routing instance. Optional
forwarding_profile Forwarding profile. Optional
predefined_application A comma-separated list of predefined applications. Optional
user_defined_application A comma-separated list of user defined applications. Optional

Context Output

There is no context output for this command.

Command example

!vd-appliance-sdwan-policy-rule-create appliance_name=EXAMPLE_BRANCH sdwan_policy_name=Default-Policy rule_name=test_rule forwarding_action=deny description="test"

Human Readable Output

Command run successfully.
Request Body:

{‘rule’: {‘name’: ‘test_rule’, ‘description’: ‘test’, ‘tag’: [], ‘rule-disable’: ‘false’, ‘match’: {‘source’: {‘zone’: {}, ‘address’: {‘address-list’: []}, ‘user’: {‘user-type’: ‘any’, ‘local-database’: {‘status’: ‘disabled’}, ‘external-database’: {‘status’: ‘disabled’}}}, ‘destination’: {‘zone’: {}, ‘address’: {‘address-list’: []}}, ‘application’: {‘predefined-application-list’: [], ‘user-defined-application-list’: []}, ‘url-category’: {‘user-defined’: []}, ‘url-reputation’: {‘predefined’: []}, ‘ttl’: {}}, ‘set’: {‘lef’: {‘event’: ‘never’, ‘profile-default’: ‘true’, ‘rate-limit’: ‘10’}, ‘action’: ‘deny’, ‘tcp-optimization’: {}}, ‘monitor’: {}}}

vd-appliance-sdwan-policy-rule-list


List all SDWAN policy rules associated with a specific appliance (device).

Base Command

vd-appliance-sdwan-policy-rule-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
sdwan_policy_name Name of the SDWAN policy. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of objects to return. Optional

Context Output

Path Type Description
VersaDirector.ApplianceSdwanPolicyRule.name string Policy rule name
VersaDirector.ApplianceSdwanPolicyRule.description string Policy rule description
VersaDirector.ApplianceSdwanPolicyRule.rule-disable string Rule is disabled
VersaDirector.ApplianceSdwanPolicyRule.set.action string Rule action

Command example

!vd-appliance-sdwan-policy-rule-list appliance_name=EXAMPLE_BRANCH sdwan_policy_name=Default-Policy limit=3

Context Example

{
    "VersaDirector": {
        "ApplianceSdwanPolicyRule": [
            {
                "match": {
                    "source": {
                        "user": {
                            "external-database": {
                                "status": "disabled"
                            },
                            "local-database": {
                                "status": "disabled"
                            },
                            "user-type": "any"
                        }
                    },
                    "url-category": {
                        "user-defined": "Test_Cat"
                    }
                },
                "name": "Test",
                "rule-disable": "false",
                "set": {
                    "action": "deny",
                    "lef": {
                        "event": "never",
                        "rate-limit": "10"
                    }
                }
            },
            {
                "match": {
                    "source": {
                        "user": {
                            "external-database": {
                                "status": "disabled"
                            },
                            "local-database": {
                                "status": "disabled"
                            },
                            "user-type": "any"
                        }
                    },
                    "url-category": {
                        "user-defined": "Test_Cat"
                    }
                },
                "name": "Block-custom-URL-category-rule",
                "rule-disable": "false",
                "set": {
                    "action": "deny",
                    "lef": {
                        "event": "never",
                        "rate-limit": "10"
                    }
                }
            }
        ]
    }
}

Human Readable Output

SD-WAN policy rules associated with EXAMPLE_CLIENT

Name Rule - Disable
Tesrt false
Block-custom-URL-category-rule false

vd-appliance-sdwan-policy-list


List all SDWAN policies associated with a specific organization and appliance (device).

Base Command

vd-appliance-sdwan-policy-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.ApplianceSdwanPolicy.address string Appliance SDWAN policy address.
VersaDirector.ApplianceSdwanPolicy.rule-disable string Appliance Sdwan policy Rule disabled.
VersaDirector.ApplianceSdwanPolicy.match string Appliance SDWAN policy set Matching objects.
VersaDirector.ApplianceSdwanPolicy.set string Appliance SDWAN policy set.

Command example

!vd-appliance-sdwan-policy-list appliance_name=EXAMPLE_BRANCH limit=3

Context Example

{
    "VersaDirector": {
        "ApplianceSdwanPolicy": {
            "name": "Default-Policy",
            "rules": {
                "rule": [
                    {
                        "name": "TEST"
                    },
                    {
                        "name": "Block-custom-URL-category-rule"
                    }
                ]
            }
        }
    }
}

Human Readable Output

SD-WAN policies associated with EXAMPLE_CLIENT

Name Rules
Default-Policy rule:
- name: TEST
- name: Block-custom-URL-category-rule

vd-template-sdwan-policy-rule-delete


Delete an SDWAN policy rule associated with a specific template.

Base Command

vd-template-sdwan-policy-rule-delete

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
sdwan_policy_name Name of the SDWAN policy. Required
rule_name Name of the rule. Required

Context Output

There is no context output for this command.

Command example

!vd-template-sdwan-policy-rule-delete template_name=EXAMPLE_CLIENT-Default-Application sdwan_policy_name=Default-Policy rule_name=test_rule

Human Readable Output

Command run successfully.

vd-template-sdwan-policy-rule-edit


Edit an SDWAN policy rule associated with a specific appliance (device).

Base Command

vd-template-sdwan-policy-rule-edit

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
sdwan_policy_name Name of the SDWAN policy. Required
custom_rule_json Allows the use of the Custom SDWAN Rule JSON template. All of the arguments listed below will be overridden. For an example, see the integration documentation. Optional
rule_name Name of the rule. Required
description SDWAN policy description. Optional
tags A comma-separated list of tags. Optional
source_address_objects A comma-separated list of source address objects. Optional
destination_address_objects A comma-separated list of destination address objects. Optional
url_reputation A comma-separated list of URL reputations. Optional
custom_url_categories A comma-separated list of custom URL categories. Optional
forwarding_action Forwarding action. Possible values are: allow, deny. Required
nexthop_ip Nexthop IP. Optional
routing_instance Routing instance. Optional
forwarding_profile Forwarding profile. Optional
predefined_application A comma-separated list of predefined applications. Optional
user_defined_application A comma-separated list of user defined applications. Optional

Context Output

There is no context output for this command.

vd-template-sdwan-policy-rule-create


Create an SDWAN policy rule associated with a specific template.

Base Command

vd-template-sdwan-policy-rule-create

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
sdwan_policy_name Name of the SDWAN policy. Required
custom_rule_json Allows the use of the Custom SDWAN Rule JSON template. All of the arguments listed below will be overridden. For an example, see the integration documentation. Optional
rule_name Name of the rule. Required
description SDWAN policy description. Optional
tags A comma-separated list of tags. Optional
source_address_objects A comma-separated list of source address objects. Optional
destination_address_objects A comma-separated list of destination address objects. Optional
url_reputation A comma-separated list of URL reputations. Optional
custom_url_categories A comma-separated list of custom URL categories. Optional
forwarding_action Forwarding action. Possible values are: allow, deny. Required
nexthop_ip Nexthop IP. Optional
routing_instance Routing instance. Optional
forwarding_profile Forwarding profile. Optional
predefined_application A comma-separated list of predefined applications. Optional
user_defined_application A comma-separated list of user defined applications. Optional

Context Output

There is no context output for this command.

Command example

!vd-template-sdwan-policy-rule-create template_name=EXAMPLE_CLIENT-Default-Application sdwan_policy_name=Default-Policy rule_name=test_rule forwarding_action=deny

Human Readable Output

Command run successfully.
Request Body:

{‘rule’: {‘name’: ‘test_rule’, ‘description’: ‘’, ‘tag’: [], ‘rule-disable’: ‘false’, ‘match’: {‘source’: {‘zone’: {}, ‘address’: {‘address-list’: []}, ‘user’: {‘user-type’: ‘any’, ‘local-database’: {‘status’: ‘disabled’}, ‘external-database’: {‘status’: ‘disabled’}}}, ‘destination’: {‘zone’: {}, ‘address’: {‘address-list’: []}}, ‘application’: {‘predefined-application-list’: [], ‘user-defined-application-list’: []}, ‘url-category’: {‘user-defined’: []}, ‘url-reputation’: {‘predefined’: []}, ‘ttl’: {}}, ‘set’: {‘lef’: {‘event’: ‘never’, ‘profile-default’: ‘true’, ‘rate-limit’: ‘10’}, ‘action’: ‘deny’, ‘tcp-optimization’: {}}, ‘monitor’: {}}}

Command example

!vd-template-sdwan-policy-rule-create template_name=EXAMPLE_CLIENT-Default-Application sdwan_policy_name=Default-Policy rule_name=test_rule forwarding_action=deny

Human Readable Output

Object already exists.
Request Body:

(None, ‘Not available.’)

vd-template-sdwan-policy-rule-list


List all SDWAN policy rules associated with a specific template.

Base Command

vd-template-sdwan-policy-rule-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
sdwan_policy_name Name of the SDWAN policy. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results. Optional

Context Output

Path Type Description
VersaDirector.TemplateSdwanPolicy.sdwan-policy-group.name string Template SDWAN policy group name
VersaDirector.TemplateSdwanPolicy.sdwan-policy-group.rules string Template SDWAN policy group rules

Command example

!vd-template-sdwan-policy-rule-list template_name=EXAMPLE_CLIENT-Default-Application sdwan_policy_name=Default-Policy limit=3

Context Example

{
    "VersaDirector": {
        "TemplateSdwanPolicyRule": [
            {
                "match": {
                    "application": {
                        "predefined-filter-list": "VOIP"
                    }
                },
                "name": "Voice",
                "set": {
                    "action": "allow",
                    "forwarding-profile": "Rule-Voice-FP"
                }
            },
            {
                "match": {
                    "application": {
                        "predefined-filter-list": "Audio-Video-Streaming"
                    }
                },
                "name": "Audio-Video-Streaming",
                "set": {
                    "action": "allow",
                    "forwarding-profile": "Rule-Audio-Video-Streaming-FP"
                }
            },
            {
                "match": {
                    "application": {
                        "predefined-group-list": "ADP-Apps"
                    }
                },
                "name": "ADP-Apps",
                "set": {
                    "action": "allow",
                    "forwarding-profile": "Rule-ADP-Apps-FP"
                }
            }
        ]
    }
}

Human Readable Output

SD-WAN policy rules associated with EXAMPLE_CLIENT

Name Match Set
Voice application:
predefined-filter-list: VOIP
action: allow
forwarding-profile: Rule-Voice-FP
Audio-Video-Streaming application:
predefined-filter-list: Audio-Video-Streaming
action: allow
forwarding-profile: Rule-Audio-Video-Streaming-FP
ADP-Apps application:
predefined-group-list: ADP-Apps
action: allow
forwarding-profile: Rule-ADP-Apps-FP

vd-template-sdwan-policy-list


List all SDWAN policies associated with a specific organization and template.

Base Command

vd-template-sdwan-policy-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results. Optional

Context Output

Path Type Description
VersaDirector.TemplateSdwanPolicy.sdwan-policy-group.name string Template SDWAN policy group name
VersaDirector.TemplateSdwanPolicy.sdwan-policy-group.rules string Template SDWAN policy group rules

Command example

!vd-template-sdwan-policy-list template_name=EXAMPLE_CLIENT-Default-Application limit=3

Context Example

{
    "VersaDirector": {
        "TemplateSdwanPolicy": {
            "collection": {
                "sdwan-policy-group": {
                    "name": "Default-Policy",
                    "rules": {
                        "rule": [
                            {
                                "name": "Voice"
                            },
                            {
                                "name": "Audio-Video-Streaming"
                            },
                            {
                                "name": "ADP-Apps"
                            },
                            {
                                "name": "Amazon-Apps"
                            },
                            {
                                "name": "Box-Apps"
                            },
                            {
                                "name": "Citrix-Apps"
                            },
                            {
                                "name": "Concur-Apps"
                            },
                            {
                                "name": "Docusign-Apps"
                            },
                            {
                                "name": "Dropbox-Apps"
                            },
                            {
                                "name": "IBM-Apps"
                            },
                            {
                                "name": "Intuit-Apps"
                            },
                            {
                                "name": "Jira-Apps"
                            },
                            {
                                "name": "Office365-Apps"
                            },
                            {
                                "name": "Oracle-Apps"
                            },
                            {
                                "name": "SAP-Apps"
                            },
                            {
                                "name": "Salesforce-Apps"
                            },
                            {
                                "name": "Zendesk-Apps"
                            },
                            {
                                "name": "Zoho-Apps"
                            },
                            {
                                "name": "SaaS-Applications"
                            },
                            {
                                "name": "Database"
                            },
                            {
                                "name": "Business-Traffic"
                            },
                            {
                                "name": "Google-Apps"
                            },
                            {
                                "name": "Conferencing-Apps"
                            },
                            {
                                "name": "SoftwareUpdates"
                            },
                            {
                                "name": "File-Transfer"
                            },
                            {
                                "name": "Adobe-Apps"
                            },
                            {
                                "name": "Advertising"
                            },
                            {
                                "name": "Gaming"
                            },
                            {
                                "name": "P2P"
                            },
                            {
                                "name": "Social-Media"
                            },
                            {
                                "name": "Block-custom-URL-category-rule"
                            },
                        ]
                    }
                }
            }
        }
    }
}

Human Readable Output

SD-WAN policies associated with EXAMPLE_CLIENT

Name Rules
Default-Policy rule:
- name: Voice
- name: Audio-Video-Streaming
- name: ADP-Apps
- name: Amazon-Apps
- name: Box-Apps
- name: Citrix-Apps
- name: Concur-Apps
- name: Docusign-Apps
- name: Dropbox-Apps
- name: IBM-Apps
- name: Intuit-Apps
- name: Jira-Apps
- name: Office365-Apps
- name: Oracle-Apps
- name: SAP-Apps
- name: Salesforce-Apps
- name: Zendesk-Apps
- name: Zoho-Apps
- name: SaaS-Applications
- name: Database
- name: Business-Traffic
- name: Google-Apps
- name: Conferencing-Apps
- name: SoftwareUpdates
- name: File-Transfer
- name: Adobe-Apps
- name: Advertising
- name: Gaming
- name: P2P
- name: Social-Media
- name: Block-custom-URL-category-rule

vd-appliance-access-policy-rule-delete


Delete an access policy configuration (NGFW) rule associated with a specific appliance (device).

Base Command

vd-appliance-access-policy-rule-delete

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
access_policy_name Access policy name. Required
rule_name Name of the rule. Required

Context Output

There is no context output for this command.

Command example

!vd-appliance-access-policy-rule-delete rule_name=test_rule_new1 appliance_name=EXAMPLE_BRANCH access_policy_name=Test_Policy

Human Readable Output

Command run successfully.

vd-appliance-access-policy-rule-edit


Edit access policy configuration (NGFW) rule associated with a specific appliance (device). Important note - the data provided in the request overwrites the existing rule settings.

Base Command

vd-appliance-access-policy-rule-edit

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
access_policy_name Access policy name. Required
custom_rule_json Allows the use of the Custom Access policy rule JSON template. All of the arguments listed below will be overridden. For an example, see the integration documentation. Optional
rule_name Name of the rule. Required
description SDWAN policy description. Optional
tags A comma-separated list of tags. Optional
source_address_objects A comma-separated list of source address objects. Optional
destination_address_objects A comma-separated list of destination address objects. Optional
url_reputation A comma-separated list of URL reputations. Optional
predefined_application A comma-separated list of predefined applications. Optional
user_defined_application A comma-separated list of user defined applications. Optional

Context Output

There is no context output for this command.

Command example

!vd-appliance-access-policy-rule-edit rule_name=test_rule_new1 appliance_name=EXAMPLE_BRANCH access_policy_name=Test_Policy description="test rule changed" source_address_objects="Bad-Address-1" destination_address_objects="Bad-Address-2"

Human Readable Output

Command run successfully.
Request Body:

{‘access-policy’: {‘name’: ‘test_rule_new1’, ‘description’: ‘test rule changed’, ‘rule-disable’: ‘false’, ‘tag’: [], ‘match’: {‘source’: {‘zone’: {}, ‘address’: {‘address-list’: [‘Bad-Address-1’], ‘negate’: ‘’}, ‘site-name’: [], ‘user’: {‘user-type’: ‘any’, ‘local-database’: {‘status’: ‘disabled’}, ‘external-database’: {‘status’: ‘disabled’}}}, ‘destination’: {‘zone’: {}, ‘address’: {‘address-list’: [‘Bad-Address-2’], ‘negate’: ‘’}, ‘site-name’: []}, ‘application’: {‘predefined-application-list’: [], ‘user-defined-application-list’: []}, ‘url-category’: {‘user-defined’: []}, ‘url-reputation’: {‘predefined’: []}, ‘ttl’: {}}, ‘set’: {‘lef’: {‘event’: ‘never’, ‘options’: {‘send-pcap-data’: {‘enable’: False}}}, ‘action’: ‘deny’, ‘tcp-session-keepalive’: ‘disabled’}}}

vd-appliance-access-policy-rule-create


Create an access policy configuration (NGFW) rule associated with a specific appliance (device).

Base Command

vd-appliance-access-policy-rule-create

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
access_policy_name Access policy name. Required
custom_rule_json Allows the use of the Custom Access policy rule JSON template. All of the arguments listed below will be overridden. For an example, see the integration documentation. Optional
rule_name Name of the rule. Required
description SDWAN policy description. Required
tags A comma-separated list of tags. Optional
source_address_objects A comma-separated list of source address objects. Required
destination_address_objects A comma-separated list of destination address objects. Required
url_reputation A comma-separated list of URL reputations. Optional
predefined_application A comma-separated list of predefined applications. Optional
user_defined_application A comma-separated list of user defined applications. Optional

Context Output

There is no context output for this command.

Command example

!vd-appliance-access-policy-rule-create rule_name=test_rule_new1 appliance_name=EXAMPLE_BRANCH access_policy_name=Test_Policy description="test rule" source_address_objects="Bad-Address-1" destination_address_objects="Bad-Address-2"

Human Readable Output

Command run successfully.
Request Body:

{‘access-policy’: {‘name’: ‘test_rule_new1’, ‘description’: ‘test rule’, ‘rule-disable’: ‘false’, ‘tag’: [], ‘match’: {‘source’: {‘zone’: {}, ‘address’: {‘address-list’: [‘Bad-Address-1’], ‘negate’: ‘’}, ‘site-name’: [], ‘user’: {‘user-type’: ‘any’, ‘local-database’: {‘status’: ‘disabled’}, ‘external-database’: {‘status’: ‘disabled’}}}, ‘destination’: {‘zone’: {}, ‘address’: {‘address-list’: [‘Bad-Address-2’], ‘negate’: ‘’}, ‘site-name’: []}, ‘application’: {‘predefined-application-list’: [], ‘user-defined-application-list’: []}, ‘url-category’: {‘user-defined’: []}, ‘url-reputation’: {‘predefined’: []}, ‘ttl’: {}}, ‘set’: {‘lef’: {‘event’: ‘never’, ‘options’: {‘send-pcap-data’: {‘enable’: False}}}, ‘action’: ‘deny’, ‘tcp-session-keepalive’: ‘disabled’}}}

vd-appliance-access-policy-rule-list


List all access policy configuration (NGFW) rules associated with a specific appliance.

Base Command

vd-appliance-access-policy-rule-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
access_policy_name Access policy name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.ApplianceAccessPolicyRule.name string Appliance access policy rule name
VersaDirector.ApplianceAccessPolicyRule.description string Appliance access policy rule description
VersaDirector.ApplianceAccessPolicyRule.tag string Appliance access policy rule tag
VersaDirector.ApplianceAccessPolicyRule.rule-disable string Appliance access policy rule disabled

Command example

!vd-appliance-access-policy-rule-list appliance_name=EXAMPLE_BRANCH access_policy_name=Test_Policy limit=3

Context Example

{
    "VersaDirector": {
        "ApplianceAccessPolicyRule": {
            "collection": {
                "access-policy": [
                    {
                        "description": "test rule",
                        "match": {
                            "destination": {
                                "address": {
                                    "address-list": "Bad-Address-2",
                                    "negate": null
                                }
                            },
                            "source": {
                                "address": {
                                    "address-list": "Bad-Address-1",
                                    "negate": null
                                },
                                "user": {
                                    "external-database": {
                                        "status": "disabled"
                                    },
                                    "local-database": {
                                        "status": "disabled"
                                    },
                                    "user-type": "any"
                                }
                            }
                        },
                        "name": "Test_Rule",
                        "rule-disable": "false",
                        "set": {
                            "action": "deny",
                            "lef": {
                                "event": "never",
                                "options": {
                                    "send-pcap-data": {
                                        "enable": "false"
                                    }
                                }
                            },
                            "tcp-session-keepalive": "disabled"
                        }
                    },
                    {
                        "match": {
                            "destination": {
                                "address": {
                                    "address-list": "Bad-Address-2",
                                    "negate": null
                                }
                            },
                            "source": {
                                "address": {
                                    "address-list": [
                                        "Bad-Address-1",
                                        "Bad-Address-2"
                                    ],
                                    "negate": null
                                },
                                "user": {
                                    "external-database": {
                                        "status": "disabled"
                                    },
                                    "local-database": {
                                        "status": "disabled"
                                    },
                                    "user-type": "any"
                                }
                            },
                            "url-category": {
                                "user-defined": "Test_Cat"
                            },
                            "url-reputation": {
                                "predefined": "high_risk"
                            }
                        },
                        "name": "Block-custom-URL-category-rulethree",
                        "rule-disable": "false",
                        "set": {
                            "action": "deny",
                            "lef": {
                                "event": "never",
                                "options": {
                                    "send-pcap-data": {
                                        "enable": "false"
                                    }
                                }
                            },
                            "tcp-session-keepalive": "disabled"
                        },
                        "tag": [
                            "API",
                            "test"
                        ]
                    }
                ]
            }
        }
    }
}

Human Readable Output

Access policies associated with EXAMPLE_CLIENT

Name Description Tag Rule - Disable
Test_Rule test rule   false
Block-custom-URL-category-rulethree   values: API, test false

vd-appliance-access-policy-list


List all access policies associated with a specific organization and appliance (device).

Base Command

vd-appliance-access-policy-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.ApplianceAccessPolicy.name string Access policy name.
VersaDirector.ApplianceAccessPolicy.rules string Access policy rules

Command example

!vd-appliance-access-policy-list appliance_name=EXAMPLE_BRANCH limit=3

Context Example

{
    "VersaDirector": {
        "ApplianceAccessPolicy": {
            "collection": {
                "access-policy-group": {
                    "description": "This is a test",
                    "name": "Test_Policy",
                    "rules": {
                        "access-policy": [
                            {
                                "name": "Test_Rule"
                            },
                            {
                                "name": "Block-custom-URL-category-rulethree"
                            }
                        ]
                    }
                }
            }
        }
    }
}

Human Readable Output

Access policies associated with EXAMPLE_CLIENT

Name Rules
Test_Policy access-policy:
- name: Test_Rule
- name: Block-custom-URL-category-rulethree

vd-template-access-policy-rule-delete


Delete an access policy configuration (NGFW) rule associated with a specific template.

Base Command

vd-template-access-policy-rule-delete

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
access_policy_name Access policy name. Required
rule_name Name of the rule. Required

Context Output

There is no context output for this command.

Command example

!vd-template-access-policy-rule-delete rule_name=test_rule template_name=EXAMPLE_CLIENT-Test-NGFW access_policy_name=Default-Policy

Human Readable Output

Command run successfully.

vd-template-access-policy-rule-edit


Edit access policy configuration (NGFW) rule associated with a specific template. Important note - the data provided in the request overwrites the existing rule settings.

Base Command

vd-template-access-policy-rule-edit

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
access_policy_name Access policy name. Required
custom_rule_json Allows the use of the Custom Access policy rule JSON template. All of the arguments listed below will be overridden. For an example, see the integration documentation. Optional
rule_name Name of the rule. Required
description SDWAN policy description. Optional
tags A comma-separated list of tags. Optional
source_address_objects A comma-separated list of source address objects. Optional
destination_address_objects A comma-separated list of destination address objects. Optional
url_reputation A comma-separated list of URL reputations. Optional
predefined_application A comma-separated list of predefined applications. Optional
user_defined_application A comma-separated list of user defined applications. Optional

Context Output

There is no context output for this command.

Command example

!vd-template-access-policy-rule-edit template_name=EXAMPLE_CLIENT-Test-NGFW rule_name=test_rule access_policy_name=Default-Policy

Human Readable Output

Command run successfully.
Request Body:

{‘access-policy’: {‘name’: ‘test_rule’, ‘description’: ‘’, ‘rule-disable’: ‘false’, ‘tag’: [], ‘match’: {‘source’: {‘zone’: {}, ‘address’: {‘address-list’: [], ‘negate’: ‘’}, ‘site-name’: [], ‘user’: {‘user-type’: ‘any’, ‘local-database’: {‘status’: ‘disabled’}, ‘external-database’: {‘status’: ‘disabled’}}}, ‘destination’: {‘zone’: {}, ‘address’: {‘address-list’: [], ‘negate’: ‘’}, ‘site-name’: []}, ‘application’: {‘predefined-application-list’: [], ‘user-defined-application-list’: []}, ‘url-category’: {‘user-defined’: []}, ‘url-reputation’: {‘predefined’: []}, ‘ttl’: {}}, ‘set’: {‘lef’: {‘event’: ‘never’, ‘options’: {‘send-pcap-data’: {‘enable’: False}}}, ‘action’: ‘deny’, ‘tcp-session-keepalive’: ‘disabled’}}}

vd-template-access-policy-rule-create


Create an access policy configuration (NGFW) rule associated with a specific template.

Base Command

vd-template-access-policy-rule-create

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
access_policy_name Access policy name. Required
custom_rule_json Allows the use of the Custom Access policy rule JSON template. All of the arguments listed below will be overridden. For an example, see the integration documentation. Optional
rule_name Name of the rule. Required
description Access policy description. Optional
tags A comma-separated list of tags. Optional
source_address_objects A comma-separated list of source address objects. Optional
destination_address_objects A comma-separated list of destination address objects. Optional
url_reputation A comma-separated list of URL reputations. Optional
predefined_application A comma-separated list of predefined applications. Optional
user_defined_application A comma-separated list of user defined applications. Optional

Context Output

There is no context output for this command.

Command example

!vd-template-access-policy-rule-create template_name=EXAMPLE_CLIENT-Test-NGFW rule_name=test_rule access_policy_name=Default-Policy

Human Readable Output

Command run successfully.
Request Body:

{‘access-policy’: {‘name’: ‘test_rule’, ‘description’: ‘’, ‘rule-disable’: ‘false’, ‘tag’: [], ‘match’: {‘source’: {‘zone’: {}, ‘address’: {‘address-list’: [], ‘negate’: ‘’}, ‘site-name’: [], ‘user’: {‘user-type’: ‘any’, ‘local-database’: {‘status’: ‘disabled’}, ‘external-database’: {‘status’: ‘disabled’}}}, ‘destination’: {‘zone’: {}, ‘address’: {‘address-list’: [], ‘negate’: ‘’}, ‘site-name’: []}, ‘application’: {‘predefined-application-list’: [], ‘user-defined-application-list’: []}, ‘url-category’: {‘user-defined’: []}, ‘url-reputation’: {‘predefined’: []}, ‘ttl’: {}}, ‘set’: {‘lef’: {‘event’: ‘never’, ‘options’: {‘send-pcap-data’: {‘enable’: False}}}, ‘action’: ‘deny’, ‘tcp-session-keepalive’: ‘disabled’}}}

vd-template-access-policy-rule-list


List all access policy configuration (NGFW) rules associated with a specific template.

Base Command

vd-template-access-policy-rule-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
access_policy_name Access policy name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.TemplateAccessPolicy.name string Template access policy name
VersaDirector.TemplateAccessPolicy.description string Template access policy description
VersaDirector.TemplateAccessPolicy.tag string Template access policy tag
VersaDirector.TemplateAccessPolicy.rule-disable string Template access policy disabled

Command example

!vd-template-access-policy-rule-list template_name=EXAMPLE_CLIENT-Test-NGFW access_policy_name=Default-Policy limit=3

Context Example

{
    "VersaDirector": {
        "TemplateAccessPolicyRule": {
            "collection": {
                "access-policy": [
                    {
                        "match": {
                            "source": {
                                "user": {
                                    "external-database": {
                                        "status": "disabled"
                                    },
                                    "local-database": {
                                        "status": "disabled"
                                    },
                                    "user-type": "any"
                                }
                            },
                            "url-category": {
                                "user-defined": [
                                    "Danil_Test_API_again",
                                    "Danil_Test_Three"
                                ]
                            }
                        },
                        "name": "Block-custom-URL-category-rule two",
                        "rule-disable": "false",
                        "set": {
                            "action": "deny",
                            "lef": {
                                "event": "never",
                                "options": {
                                    "send-pcap-data": {
                                        "enable": "false"
                                    }
                                }
                            },
                            "tcp-session-keepalive": "disabled"
                        }
                    },
                    {
                        "description": "Some description",
                        "match": {
                            "application": {
                                "predefined-group-list": "Box-Apps"
                            },
                            "destination": {
                                "address": {
                                    "negate": null
                                }
                            },
                            "source": {
                                "address": {
                                    "address-list": [
                                        "Bad-Address-1",
                                        "Bad-Address-2"
                                    ],
                                    "negate": null
                                },
                                "user": {
                                    "external-database": {
                                        "status": "disabled"
                                    },
                                    "local-database": {
                                        "status": "disabled"
                                    },
                                    "user-type": "any"
                                }
                            },
                            "url-category": {
                                "user-defined": "Danil_Test_API_again"
                            },
                            "url-reputation": {
                                "predefined": "high_risk"
                            }
                        },
                        "name": "test_rule_UI",
                        "rule-disable": "false",
                        "set": {
                            "action": "allow",
                            "lef": {
                                "event": "never",
                                "options": {
                                    "send-pcap-data": {
                                        "enable": "false"
                                    }
                                }
                            },
                            "tcp-session-keepalive": "disabled"
                        },
                        "tag": "test"
                    },
                    {
                        "description": null,
                        "match": {
                            "application": {
                                "predefined-application-list": "[]",
                                "user-defined-application-list": "[]"
                            },
                            "destination": {
                                "address": {
                                    "address-list": "[]",
                                    "negate": null
                                }
                            },
                            "source": {
                                "address": {
                                    "address-list": "[]",
                                    "negate": null
                                },
                                "user": {
                                    "external-database": {
                                        "status": "disabled"
                                    },
                                    "local-database": {
                                        "status": "disabled"
                                    },
                                    "user-type": "any"
                                }
                            },
                            "url-category": {
                                "user-defined": "[]"
                            },
                            "url-reputation": {
                                "predefined": "[]"
                            }
                        },
                        "name": "rule",
                        "rule-disable": "false",
                        "set": {
                            "action": "deny",
                            "lef": {
                                "event": "never",
                                "options": {
                                    "send-pcap-data": {
                                        "enable": "false"
                                    }
                                }
                            },
                            "tcp-session-keepalive": "disabled"
                        },
                        "tag": "[]"
                    }
                ]
            }
        }
    }
}

Human Readable Output

Access policies associated with EXAMPLE_CLIENT

Name Description Tag Rule - Disable
Block-custom-URL-category-rule two     false
test_rule_UI Some description test false
rule   [] false

vd-template-access-policy-list


List all access policies associated with a specific organization and template.

Base Command

vd-template-access-policy-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.TemplateAccessPolicy.name string Template access policy name
VersaDirector.TemplateAccessPolicy.rules string Access policy rules

Command example

!vd-template-access-policy-list template_name="EXAMPLE_CLIENT-Test-NGFW" limit=3

Context Example

{
    "VersaDirector": {
        "TemplateAccessPolicy": {
            "collection": {
                "access-policy-group": {
                    "name": "Default-Policy",
                    "rules": {
                        "access-policy": [
                            {
                                "name": "Block-custom-URL-category-rule two"
                            },
                            {
                                "name": "test_rule_UI"
                            },
                            {
                                "name": "rule"
                            },
                            {
                                "name": "Block-custom-URL-category-rule 555"
                            },
                            {
                                "name": "Block-custom-URL-category-rule three"
                            }
                        ]
                    }
                }
            }
        }
    }
}

Human Readable Output

Access policies associated with EXAMPLE_CLIENT

Name Rules
Default-Policy access-policy:
- name: Block-custom-URL-category-rule two
- name: test_rule_UI
- name: rule
- name: Block-custom-URL-category-rule 555
- name: Block-custom-URL-category-rule three

vd-appliance-custom-url-category-delete


Delete a custom URL category associated with a specific appliance (device).

Base Command

vd-appliance-custom-url-category-delete

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
url_category_name URL category name. Required

Context Output

Path Type Description
VersaDirector.ApplianceCustomUrlCategory.category-name string Appliance custom URL category category name.
VersaDirector.ApplianceCustomUrlCategory.category-description string Appliance custom URL category description.
VersaDirector.ApplianceCustomUrlCategory.content.confidence number Appliance custom URL category confidence threshold.
VersaDirector.ApplianceCustomUrlCategory.content.urls string Appliance custom URL category A comma-separated list of URLs.

Command example

!vd-appliance-custom-url-category-delete appliance_name=EXAMPLE_BRANCH url_category_name="category_example"

Human Readable Output

Command run successfully.

vd-appliance-custom-url-category-edit


Edit a custom URL category associated with a specific appliance (device). Important note - the data provided in the request overwrites the existing object.

Base Command

vd-appliance-custom-url-category-edit

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
url_category_name URL category name. Required
description Custom URL category description. Required
confidence Confidence threshold. Required
urls A comma-separated list of URLs. Optional
url_reputation A comma-separated list of URL reputations. Optional
patterns A comma-separated list of patterns. Optional
pattern_reputation A comma-separated list of pattern reputations. Optional

Context Output

Path Type Description
VersaDirector.ApplianceCustomUrlCategory.category-name string Appliance custom URL category category name.
VersaDirector.ApplianceCustomUrlCategory.category-description string Appliance custom URL category description.
VersaDirector.ApplianceCustomUrlCategory.content.confidence number Appliance custom URL category confidence threshold.
VersaDirector.ApplianceCustomUrlCategory.content.urls string Appliance custom URL category A comma-separated list of URLs.

vd-appliance-custom-url-category-create


Create a custom URL category associated with a specific appliance (device).

Base Command

vd-appliance-custom-url-category-create

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
url_category_name URL category name. Required
description Custom URL category description. Required
confidence Confidence threshold. Required
urls A comma-separated list of URLs. Optional
url_reputation A comma-separated list of URL reputations. Optional
patterns A comma-separated list of patterns. Optional
pattern_reputation A comma-separated list of pattern reputations. Optional

Context Output

Path Type Description
VersaDirector.ApplianceCustomUrlCategory.content.category-name string Appliance custom url category name.
VersaDirector.ApplianceCustomUrlCategory.content.category-description string Appliance custom URL category description.
VersaDirector.ApplianceCustomUrlCategory.content.confidence number Appliance custom URL category confidence threshold.
VersaDirector.ApplianceCustomUrlCategory.content.urls string Appliance custom URL category A comma-separated list of URLs.

Command example

!vd-appliance-custom-url-category-create appliance_name=EXAMPLE_BRANCH description="description example" url_category_name="category_example" confidence=80

Human Readable Output

Command run successfully.
Request Body:

{‘url-category’: {‘category-name’: ‘category_example’, ‘category-description’: ‘description example’, ‘confidence’: ‘80’, ‘urls’: {‘strings’: [], ‘patterns’: []}}}

Command example

!vd-appliance-custom-url-category-create appliance_name=EXAMPLE_BRANCH description="description example" url_category_name="category_example" confidence=90

Human Readable Output

Object already exists.
Request Body:

(None, ‘Not available.’)

vd-appliance-custom-url-category-list


List all custom URL categories associated with a specific appliance or get a specific custom URL category.

Base Command

vd-appliance-custom-url-category-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
appliance_name Appliance name. Required
url_category_name URL category name. Optional
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.ApplianceCustomUrlCategory.category-name string Appliance custom url category name.
VersaDirector.ApplianceCustomUrlCategory.content.category-description string Appliance custom URL category description.
VersaDirector.ApplianceCustomUrlCategory.content.confidence number Appliance custom URL category confidence threshold.
VersaDirector.ApplianceCustomUrlCategory.content.urls string Appliance custom URL category A comma-separated list of URLs.

Command example

!vd-appliance-custom-url-category-list appliance_name=EXAMPLE_BRANCH limit=3

Context Example

{
    "VersaDirector": {
        "ApplianceCustomUrlCategory": {
            "collection": {
                "url-category": {
                    "category-description": "Test",
                    "category-name": "Test_Cat",
                    "confidence": "95",
                    "urls": {
                        "patterns": {
                            "pattern-value": "%.test2.ru"
                        },
                        "strings": {
                            "string-value": "hxxps://test1.ru"
                        }
                    }
                }
            }
        }
    }
}

Human Readable Output

Application Service Appliances associated with EXAMPLE_CLIENT

Category - Name Category - Description Confidence Urls
Test_Cat Test 95 strings:
string-value: hxxps://test1.ru
patterns:
pattern-value: %.test2.ru

vd-template-custom-url-category-delete


Delete a custom URL category associated with a specific template.

Base Command

vd-template-custom-url-category-delete

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
url_category_name URL category name. Required

Context Output

Path Type Description
VersaDirector.TemplateCustomUrlCategory.category-name string Template custom URL category name.
VersaDirector.TemplateCustomUrlCategory.category-description string Template custom URL category description.
VersaDirector.TemplateCustomUrlCategory.content.confidence number Template custom URL category confidence threshold.
VersaDirector.TemplateCustomUrlCategory.content.urls string Template custom URL category A comma-separated list of URLs.

Command example

!vd-template-custom-url-category-delete template_name=EXAMPLE_CLIENT-Default-Application url_category_name="category_example"

Human Readable Output

Command run successfully.

vd-template-custom-url-category-edit


Edit a custom URL category associated with a specific template. Important note - the data provided in the request overwrites the existing object.

Base Command

vd-template-custom-url-category-edit

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
url_category_name URL category name. Required
description Custom URL category description. Required
confidence Confidence threshold. Required
urls A comma-separated list of URLs. Optional
url_reputation A comma-separated list of URL reputations. Optional
patterns A comma-separated list of patterns. Optional
pattern_reputation A comma-separated list of pattern reputations. Optional

Context Output

Path Type Description
VersaDirector.TemplateCustomUrlCategory.category-name string Template custom URL category name.
VersaDirector.ApplicationServiceTemplate.content.category-description string Template custom URL category description.
VersaDirector.ApplicationServiceTemplate.content.confidence number Template custom URL category confidence threshold.
VersaDirector.ApplicationServiceTemplate.content.urls string Template custom URL category URLs.

Command example

!vd-template-custom-url-category-edit template_name=EXAMPLE_CLIENT-Default-Application description="description example" url_category_name="category_example" confidence=90

Human Readable Output

Command run successfully.
Request Body:

{‘url-category’: {‘category-name’: ‘category_example’, ‘category-description’: ‘description example’, ‘confidence’: ‘90’, ‘urls’: {‘strings’: [], ‘patterns’: []}}}

vd-template-custom-url-category-create


Create a custom URL category associated with a specific template.

Base Command

vd-template-custom-url-category-create

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
url_category_name URL category name. Required
description Custom URL category description. Required
confidence Confidence threshold. Required
urls A comma-separated list of URLs. Optional
url_reputation A comma-separated list of URL reputations. Optional
patterns A comma-separated list of patterns. Optional
pattern_reputation A comma-separated list of pattern reputations. Optional

Context Output

Path Type Description
VersaDirector.TemplateCustomUrlCategory.category-name string Template custom URL category name.
VersaDirector.ApplicationServiceTemplate.content.category-description string Template custom url category category description.
VersaDirector.ApplicationServiceTemplate.content.confidence number Template custom URL category confidence threshold.
VersaDirector.ApplicationServiceTemplate.content.urls string Template custom URL category URLs.

Command example

!vd-template-custom-url-category-create template_name=EXAMPLE_CLIENT-Default-Application description="description example" url_category_name="category_example" confidence=80

Human Readable Output

Object created successfully.

vd-template-custom-url-category-list


List all custom URL categories associated with a specific template or get a specific custom URL category.

Base Command

vd-template-custom-url-category-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
template_name Template name. Required
url_category_name URL category name. Optional
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
url_category_name URL category name. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.TemplateCustomUrlCategory.category-name string Template custom URL category name.
VersaDirector.ApplicationServiceTemplate.content.category-description string Template custom url category category description.
VersaDirector.ApplicationServiceTemplate.content.confidence number Template custom URL category confidence threshold.
VersaDirector.ApplicationServiceTemplate.content.urls string Template custom URL category URLs.

Command example

!vd-template-custom-url-category-list template_name=EXAMPLE_CLIENT-Default-Application limit=3

Context Example

{
    "VersaDirector": {
        "TemplateCustomUrlCategory": {
            "collection": {
                "url-category": [
                    {
                        "category-description": "Some description for testing, and now editing",
                        "category-name": "category example1",
                        "confidence": "90",
                        "urls": {
                            "patterns": {
                                "pattern-value": ".*.testurl.com"
                            },
                            "strings": {
                                "string-value": "hxxps://test.ru"
                            }
                        }
                    },
                    {
                        "category-description": "Some description for testing, and now editing",
                        "category-name": "category example2",
                        "confidence": "5",
                        "urls": {
                            "patterns": [
                                {
                                    "pattern-value": ".*.testurl.com"
                                },
                                {
                                    "pattern-value": ".*.testurl2.com"
                                }
                            ],
                            "strings": [
                                {
                                    "string-value": "hxxps://test1.ru"
                                },
                                {
                                    "string-value": "hxxps://test2.ru"
                                }
                            ]
                        }
                    },
                    {
                        "category-description": "description example",
                        "category-name": "category example9",
                        "confidence": "80",
                        "urls": {
                            "patterns": {
                                "pattern-value": "[]"
                            },
                            "strings": {
                                "string-value": "[]"
                            }
                        }
                    }
                ]
            }
        }
    }
}

Human Readable Output

Application Service Templates associated with EXAMPLE_CLIENT

Category - Name Category - Description Confidence Urls
category example1 Some description for testing, and now editing 90 strings:
string-value: hxxps://test.ru
patterns:
pattern-value: .*.testurl.com
category example2 Some description for testing, and now editing 5 strings:
- string-value: hxxps://test1.ru
- string-value: hxxps://test2.ru
patterns:
- pattern-value: ..testurl.com
- *pattern-value
: .*.testurl2.com
category example9 description example 80 strings:
string-value: []
patterns:
pattern-value: []

vd-template-change-commit


Commit a specific template change to an appliance/s (devices). This will trigger a task to make the commit, and then it will be polled to retrieve the status until complete, and the status will be presented.

Base Command

vd-template-change-commit

Input

Argument Name Description Required
template_name New template name for the device. Required
appliances A comma-separated list of devices the change will be committed to. Required
mode Commit mode to specified devices. Possible values are: overwrite, merge, forced_merge. Required
task_id Task ID. Optional
hide_polling_output Whether to hide the polling result (automatically filled by polling). Optional
reboot Reboot devices after change is committed (true/false). Required

Context Output

Path Type Description
VersaDirector.Commit.versa-tasks.id string Task ID.
VersaDirector.Commit.versa-tasks.task-description string Task description.
VersaDirector.Commit.versa-tasks.user string Task user.
VersaDirector.Commit.task-status string Task status.
VersaDirector.Commit.versa-tasks.progressmessage string Task progress message.

Command example

!vd-template-change-commit template_name=EXAMPLE_CLIENT-Test-NGFW appliances=EXAMPLE_BRANCH mode=merge reboot=false

Human Readable Output

Fetching Results:

vd-application-service-template-list


List all application service templates. Can be filtered by organization or a keyword search.

Base Command

vd-application-service-template-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
keyword Keyword by which to search. Optional
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.ApplicationServiceTemplate.createDate string Date the application service template was created.
VersaDirector.ApplicationServiceTemplate.modifyDate string Date the application service template was modified.
VersaDirector.ApplicationServiceTemplate.content.lastUpdatedBy string By whom the application service template was last updated.
VersaDirector.ApplicationServiceTemplate.content.name string Application service template content name.
VersaDirector.ApplicationServiceTemplate.content.organization string Application service template associated organization.
VersaDirector.ApplicationServiceTemplate.content.status string Application service template status.

Command example

!vd-application-service-template-list limit=3

Context Example

{
    "VersaDirector": {
        "ApplicationServiceTemplate": {
            "content": [
                {
                    "createDate": "2021-08-26 18:02:44",
                    "lastUpdatedBy": "EXAMPLE_USER",
                    "modifyDate": "2021-08-26 18:02:48",
                    "name": "EXAMPLE_CLIENT-Default-Application",
                    "organization": "EXAMPLE_CLIENT",
                    "status": "DEPLOYED"
                }
            ],
            "empty": false,
            "first": true,
            "last": true,
            "number": 0,
            "numberOfElements": 1,
            "pageable": {
                "offset": 0,
                "pageNumber": 0,
                "pageSize": 3,
                "paged": true,
                "sort": {
                    "empty": false,
                    "sorted": true,
                    "unsorted": false
                },
                "unpaged": false
            },
            "size": 3,
            "sort": {
                "empty": false,
                "sorted": true,
                "unsorted": false
            },
            "totalElements": 1,
            "totalPages": 1
        }
    }
}

Human Readable Output

Application Service Templates associated with EXAMPLE_CLIENT

Create Date Modify Date Last Updated By Name Organization Status
2021-08-26 18:02:44 2021-08-26 18:02:48 EXAMPLE_USER EXAMPLE_CLIENT-Default-Application EXAMPLE_CLIENT DEPLOYED

vd-datastore-template-list


List all templates associated with a specific datastore. As a best practice, we do not recommend applying rules to datastore templates. Instead, use devices/service/application templates.

Base Command

vd-datastore-template-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.DataStoreTemplate.name string Template name.
VersaDirector.DataStoreTemplate.appliance-owner string DataStore template appliance owner.
VersaDirector.DataStoreTemplate.available-routing-instances string DataStore template available routing instances.
VersaDirector.DataStoreTemplate.owned-routing-instances string DataStore template owned routing instances.
VersaDirector.DataStoreTemplate.available-networks string DataStore template available networks.

Command example

!vd-datastore-template-list limit=3

Context Example

{
    "VersaDirector": {
        "DataStoreTemplate": {
            "collection": {
                "org": {
                    "appliance-owner": null,
                    "available-networks": [
                        "INET",
                        "INET-2",
                        "LTE",
                        "MPLS",
                        "MPLS-2"
                    ],
                    "available-routing-instances": "EXAMPLE_CLIENT-LAN-VR",
                    "name": "EXAMPLE_CLIENT",
                    "owned-routing-instances": "EXAMPLE_CLIENT-LAN-VR"
                }
            }
        }
    }
}

Human Readable Output

Templates associated with EXAMPLE_CLIENT Data-Store

Name Available - Routing - Instances Owned - Routing - Instances Available - Networks
EXAMPLE_CLIENT EXAMPLE_CLIENT-LAN-VR EXAMPLE_CLIENT-LAN-VR INET,
INET-2,
LTE,
MPLS,
MPLS-2

vd-template-list


List all templates associated with a specific organization. Default type argument is ‘MAIN’.

Base Command

vd-template-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
type Type of template. If not specified in the request, all types will be fetched. Possible values are: SERVICE, MAIN. Optional
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results. Optional

Context Output

Path Type Description
VersaDirector.Template   Template name.

Command example

!vd-template-list limit=3

Context Example

{
    "VersaDirector": {
        "Template": [
            {
                "analyticsEnabled": true,
                "compositeOrPrimary": "composite",
                "dynamicTenantConfig": false,
                "isAnalyticsEnabled": true,
                "isDynamicTenantConfig": false,
                "isPrimary": true,
                "isStaging": false,
                "lockDetails": {
                    "lockType": "NONE",
                    "user": "EXAMPLE_USER"
                },
                "name": "EXAMPLE_SITE",
                "organization": [
                    "EXAMPLE_CLIENT"
                ],
                "primary": true,
                "providerTenant": "EXAMPLE_CLIENT",
                "rbacResourceTags": [],
                "staging": false,
                "templateType": "sdwan-post-staging"
            }
        ]
    }
}

Human Readable Output

Templates associated with EXAMPLE_CLIENT

Name Organization Lock Details Template Type Is Primary Is Staging
EXAMPLE_SITE EXAMPLE_CLIENT user: EXAMPLE_USER
lockType: NONE
sdwan-post-staging true false

vd-appliance-group-template-appliance-list


List all appliances associated with a specific device-group and associated templates

Base Command

vd-appliance-group-template-appliance-list

Input

Argument Name Description Required
device_group Device group name. Required
template_name Template name. Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.DeviceGroup.createDate string Date the device group was created.
VersaDirector.DeviceGroup.modifyDate string Date the device group was modified.
VersaDirector.DeviceGroup.lastUpdatedBy string By whom the device group was last updated.
VersaDirector.DeviceGroup.name string Device group name.
VersaDirector.DeviceGroup.poststagingTemplatePriority string Device group post staging template priority.
VersaDirector.DeviceGroup.oneTimePassword string Device group one time password.
VersaDirector.DeviceGroup.poststaging-template string Device group post staging template.
VersaDirector.DeviceGroup.enable-2factor-auth string Device group enable two factor authentication.
VersaDirector.DeviceGroup.enable-staging-url string Device group enable staging URL.

Command example

!vd-appliance-group-template-appliance-list device_group="EXAMPLE_BRANCH" template_name=EXAMPLE_CLIENT-Test-NGFW limit=3

Context Example

{
    "VersaDirector": {
        "DeviceGroup": {
            "ca-config-on-branch-notification": false,
            "enable-2factor-auth": false,
            "enable-staging-url": false,
            "inventory-name": [],
            "name": "EXAMPLE_BRANCH",
            "oneTimePassword": false,
            "poststaging-template": "EXAMPLE_CLIENT-Test-NGFW",
            "template-association": [
                {
                    "category": "DataStore",
                    "deviceTemplateStatus": null,
                    "name": "EXAMPLE_CLIENT-DataStore",
                    "organization": "EXAMPLE_CLIENT",
                    "templateAssociationType": "DEVICE_GROUP"
                },
                {
                    "category": "Main",
                    "deviceTemplateStatus": null,
                    "name": "EXAMPLE_CLIENT-Test-NGFW",
                    "organization": "EXAMPLE_CLIENT",
                    "templateAssociationType": "DEVICE_GROUP"
                }
            ]
        }
    }
}

Human Readable Output

Appliances

Name Poststaging - Template Template - Association
EXAMPLE_BRANCH EXAMPLE_CLIENT-Test-NGFW - name: EXAMPLE_CLIENT-DataStore
- name: EXAMPLE_CLIENT-Test-NGFW

vd-appliance-group-list


List all appliance (device) groups associated with an organization (tenant)

Base Command

vd-appliance-group-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.DeviceGroup.createDate string Date the device group was created.
VersaDirector.DeviceGroup.modifyDate string Date the device group was modified.
VersaDirector.DeviceGroup.lastUpdatedBy string By whom the device group was last updated.
VersaDirector.DeviceGroup.name string Device group name.
VersaDirector.DeviceGroup.organization string Associated organization.
VersaDirector.DeviceGroup.poststagingTemplatePriority number Post staging template priority.
VersaDirector.DeviceGroup.oneTimePassword string One time password.
VersaDirector.DeviceGroup.poststaging-template string Post staging template.
VersaDirector.DeviceGroup.enable-2factor-auth string Enable two factor authentication.
VersaDirector.DeviceGroup.enable-staging-url string Enable staging URL.
VersaDirector.DeviceGroup.inventory-name String Inventory name.

Command example

!vd-appliance-group-list limit=3

Context Example

{
    "VersaDirector": {
        "DeviceGroup": {
            "device-group": [
                {
                    "ca-config-on-branch-notification": false,
                    "createDate": "2022-10-05 10:44:26",
                    "enable-2factor-auth": false,
                    "enable-staging-url": false,
                    "inventory-name": [
                        "EXAMPLE_BRANCH"
                    ],
                    "lastUpdatedBy": "EXAMPLE_USER",
                    "modifyDate": "2022-10-05 10:44:26",
                    "name": "EXAMPLE_BRANCH-DG",
                    "oneTimePassword": false,
                    "organization": "EXAMPLE_CLIENT",
                    "poststaging-template": "EXAMPLE_SITE",
                    "poststagingTemplatePriority": 2
                }
            ],
            "totalCount": 1
        }
    }
}

Human Readable Output

Appliance groups associated with EXAMPLE_CLIENT

Name Organization Create Date Inventory - Name Poststaging - Template
EXAMPLE_BRANCH-DG EXAMPLE_CLIENT 2022-10-05 10:44:26 EXAMPLE_BRANCH EXAMPLE_SITE

vd-organization-appliance-list


List all devices associated with a specific organization.

Base Command

vd-organization-appliance-list

Input

Argument Name Description Required
organization Name of the associated organization. Optional
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. default value 0. Optional
limit The maximum number of results to retrieve. Default is 50. Optional

Context Output

Path Type Description
VersaDirector.Appliance.name string Appliance name.
VersaDirector.Appliance.uuid string Appliance UUID.
VersaDirector.Appliance.applianceLocation string Appliance location.

Command example

!vd-organization-appliance-list limit=3

Context Example

{
    "VersaDirector": {
        "Appliance": {
            "appliances": [
                {
                    "Hardware": {
                        "cpuCores": 0,
                        "cpuCount": 4,
                        "cpuLoad": 2,
                        "cpuModel": "X",
                        "diskSize": "X",
                        "fanless": false,
                        "firmwareVersion": "X",
                        "freeDisk": "70.78GiB",
                        "freeMemory": "4.11GiB",
                        "hardWareSerialNo": "Not Specified",
                        "intelQuickAssistAcceleration": false,
                        "interfaceCount": 6,
                        "lpm": false,
                        "manufacturer": "X",
                        "memory": "X",
                        "model": "X",
                        "name": "EXAMPLE_BRANCH",
                        "packageName": "EXAMPLE_PACKAGE",
                        "serialNo": "EXAMPLE_BRANCH-SN",
                        "sku": "Not Specified",
                        "ssd": false
                    },
                    "OssPack": {
                        "name": "EXAMPLE_BRANCH",
                        "osspackVersion": "unknown",
                        "updateType": "unknown"
                    },
                    "SPack": {
                        "apiVersion": "Version",
                        "flavor": "SAMPLE",
                        "name": "EXAMPLE_BRANCH",
                        "releaseDate": "X",
                        "spackVersion": "X",
                        "updateType": "full"
                    },
                    "alarmSummary": {
                        "columnNames": [
                            "columnName 0"
                        ],
                        "monitorType": "Alarms",
                        "rows": [
                            {
                                "columnValues": [
                                    0
                                ],
                                "firstColumnValue": "critical"
                            },
                            {
                                "columnValues": [
                                    3
                                ],
                                "firstColumnValue": "major"
                            },
                            {
                                "columnValues": [
                                    0
                                ],
                                "firstColumnValue": "minor"
                            },
                            {
                                "columnValues": [
                                    0
                                ],
                                "firstColumnValue": "warning"
                            },
                            {
                                "columnValues": [
                                    0
                                ],
                                "firstColumnValue": "indeterminate"
                            },
                            {
                                "columnValues": [
                                    12
                                ],
                                "firstColumnValue": "cleared"
                            }
                        ],
                        "tableId": "Alarms",
                        "tableName": "Alarms"
                    },
                    "appIdDetails": {
                        "appIdAvailableBundleVersion": "EXAMPLE_VERSION ",
                        "appIdInstalledBundleVersion": "EXAMPLE_VERSION ",
                        "appIdInstalledEngineVersion": "EXAMPLE_VERSION "
                    },
                    "applianceCapabilities": {
                        "capabilities": [
                            "path-state-monitor",
                            "bw-in-interface-state",
                            "config-encryption:v3",
                            "route-filter-feature"
                        ]
                    },
                    "applianceLocation": {
                        "applianceName": "EXAMPLE_BRANCH",
                        "applianceUuid": "X",
                        "latitude": "0.",
                        "locationId": "X",
                        "longitude": "0.",
                        "type": "EXAMPLE"
                    },
                    "branch-maintenance-mode": false,
                    "branchId": "ID",
                    "branchInMaintenanceMode": false,
                    "connector": "local",
                    "connectorType": "local",
                    "controll-status": "Unavailable",
                    "controllers": [
                        "Controller-1"
                    ],
                    "cpeHealth": {
                        "columnNames": [
                            "Category",
                            "Up",
                            "Down",
                            "Disabled"
                        ],
                        "rows": [
                            {
                                "columnValues": [
                                    0,
                                    0,
                                    0
                                ],
                                "firstColumnValue": "Physical Ports"
                            },
                            {
                                "columnValues": [
                                    1,
                                    0,
                                    0
                                ],
                                "firstColumnValue": "Config Sync Status"
                            },
                            {
                                "columnValues": [
                                    1,
                                    0,
                                    0
                                ],
                                "firstColumnValue": "Reachability Status"
                            },
                            {
                                "columnValues": [
                                    1,
                                    0,
                                    0
                                ],
                                "firstColumnValue": "Service Status"
                            }
                        ]
                    },
                    "createdAt": "X",
                    "deployment": "normal",
                    "inter-chassis-ha-status": {
                        "ha-configured": false
                    },
                    "intra-chassis-ha-status": {
                        "ha-configured": false
                    },
                    "ipAddress": "EXAMPLE_URL",
                    "last-updated-time": "2022-11-13 10:24:39.0",
                    "location": "LOCATION",
                    "lockDetails": {
                        "lockType": "NONE",
                        "user": "EXAMPLE_USER"
                    },
                    "name": "EXAMPLE_BRANCH",
                    "nodes": {
                        "nodeStatusList": {
                            "cpu-load": 2,
                            "host-ip": "NOT-APPLICABLE",
                            "load-factor": 2,
                            "memory-load": 9,
                            "node-type": "VCSN",
                            "slot-id": 0,
                            "vm-name": "NOT-APPLICABLE",
                            "vm-status": "NOT-APPLICABLE"
                        }
                    },
                    "overall-status": "NOT-APPLICABLE",
                    "ownerOrg": "EXAMPLE_CLIENT",
                    "path-status": "Unavailable",
                    "ping-status": "REACHABLE",
                    "refreshCycleCount": 0,
                    "services": [
                        "sdwan",
                        "nextgen-firewall",
                        "cgnat"
                    ],
                    "services-status": "GOOD",
                    "sngCount": 0,
                    "softwareVersion": "",
                    "startTime": "Mon Nov  7 05:11:42 2022",
                    "sync-status": "IN_SYNC",
                    "type": "branch",
                    "ucpe-nodes": {
                        "ucpeNodeStatusList": []
                    },
                    "unreachable": false,
                    "uuid": "X",
                    "yang-compatibility-status": "Unavailable"
                }
            ],
            "totalCount": 1
        }
    }
}

Human Readable Output

Organization List

Name Ip Address Type Software Version Owner Org
EXAMPLE_BRANCH EXAMPLE_URL branch NORMAL EXAMPLE_CLIENT

vd-organization-list


List all organizations/tenants.

Base Command

vd-organization-list

Input

Argument Name Description Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results to retrieve. Optional

Context Output

Path Type Description
VersaDirector.Organization.name String Organization name.
VersaDirector.Organization.uuid String Organization UUID.
VersaDirector.Organization.parent String Organization parent.
VersaDirector.Organization.subscriptionPlan String Organization subscription plan.
VersaDirector.Organization.id String Organization ID.
VersaDirector.Organization.authType String Organization auth type.
VersaDirector.Organization.cpeDeploymentType String Organization CPE deployment type.
VersaDirector.Organization.appliances String Organization appliances.
VersaDirector.Organization.vrfsGroups String Organization VRFS groups.
VersaDirector.Organization.wanNetworkGroups String Organization WAN network groups.
VersaDirector.Organization.analyticsClusters String Organization analytics clusters.
VersaDirector.Organization.sharedControlPlane String Organization shared control plane.
VersaDirector.Organization.blockInterRegionRouting String Organization blockInter region routing.

Command example

!vd-organization-list limit=3

Context Example

{
    "VersaDirector": {
        "Organization": [
            {
                "analyticsClusters": [
                    "Analytics-Cluster"
                ],
                "appliances": [
                    "X",
                    "Y"
                ],
                "authType": "psk",
                "blockInterRegionRouting": false,
                "cpeDeploymentType": "SDWAN",
                "dynamicTenantConfig": {
                    "inactivityInterval": 48,
                    "uuid": "X"
                },
                "id": 1,
                "name": "EXAMPLE_CLIENT",
                "parent": "Versa",
                "sharedControlPlane": false,
                "subscriptionPlan": "EXAMPLE_PLAN",
                "uuid": "X",
                "vrfsGroups": [
                    {
                        "description": null,
                        "enable_vpn": true,
                        "id": 2,
                        "name": "EXAMPLE_CLIENT-LAN-VR",
                        "vrfId": 152
                    }
                ],
                "wanNetworkGroups": [
                    {
                        "description": "",
                        "id": 3,
                        "name": "INET",
                        "transport-domains": [
                            "Internet"
                        ]
                    },
                    {
                        "description": "",
                        "id": 4,
                        "name": "INET-2",
                        "transport-domains": [
                            "Internet"
                        ]
                    },
                    {
                        "description": "",
                        "id": 5,
                        "name": "LTE",
                        "transport-domains": [
                            "Internet"
                        ]
                    },
                    {
                        "description": "",
                        "id": 6,
                        "name": "MPLS",
                        "transport-domains": [
                            "MPLS"
                        ]
                    },
                    {
                        "description": "",
                        "id": 7,
                        "name": "MPLS-2",
                        "transport-domains": [
                            "MPLS-2"
                        ]
                    }
                ]
            }
        ]
    }
}

Human Readable Output

Organization List

Name Id Parent Appliances Cpe Deployment Type Uuid
EXAMPLE_CLIENT ID Versa NAME SDWAN XXX

vd-appliance-list


List all available appliances for all organizations/tenants, with a limit of max 25 appliances per organization.

Base Command

vd-appliance-list

Input

Argument Name Description Required
page The page number of the results to retrieve. Optional
page_size The maximum number of objects to retrieve per page. Optional
limit The maximum number of results. Optional

Context Output

Path Type Description
VersaDirector.Appliance.name String Appliance name.
VersaDirector.Appliance.uuid String Appliance UUID.
VersaDirector.Appliance.ipAddress String Appliance IP address.
VersaDirector.Appliance.appType String Appliance application type.
VersaDirector.Appliance.branchId Number Application branch ID.

Command example

!vd-appliance-list limit=3

Context Example

{
    "VersaDirector": {
        "Appliance": {
            "appliance-list": [
                {
                    "appType": "branch",
                    "branchId": "ID",
                    "ipAddress": "EXAMPLE_URL",
                    "name": "EXAMPLE_BRANCH",
                    "uuid": "X"
                }
            ]
        }
    }
}

Human Readable Output

Appliances

Name Uuid Ip Address App Type Branch Id
EXAMPLE_BRANCH UUID EXAMPLE_URL branch ID

Configuration parameters

  • url — Your server URL (required)
  • organization — Organization Name
  • credentials — Username
  • use_basic_auth — Use Basic Authentication
  • client_id — Client ID
  • client_secret — Client Secret
  • credentials_client — Client ID
  • access_token — Auth Token
  • credentials_access_token
  • insecure — Trust any certificate (not secure)
  • proxy — Use system proxy settings

Commands (52)

  • vd-appliance-access-policy-list

    List all access policies associated with a specific organization and appliance (device).

  • vd-appliance-access-policy-rule-create

    Create an access policy configuration (NGFW) rule associated with a specific appliance (device).

  • vd-appliance-access-policy-rule-delete

    Delete an access policy configuration (NGFW) rule associated with a specific appliance (device).

  • vd-appliance-access-policy-rule-edit

    Edit an access policy configuration (NGFW) rule associated with a specific appliance (device). Important note - the data provided in the request overwrites the existing rule settings.

  • vd-appliance-access-policy-rule-list

    List all access policy configuration (NGFW) rules associated with a specific appliance.

  • vd-appliance-address-object-create

    Create an address object associated with a specific organization and appliance (device).

  • vd-appliance-address-object-delete

    Delete an address object associated with a specific organization and appliance (device).

  • vd-appliance-address-object-edit

    Edit an address object associated with a specific organization and appliance (device).

  • vd-appliance-address-object-list

    List all address objects associated with a specific organization and appliance (device).

  • vd-appliance-custom-url-category-create

    Create a custom URL category associated with a specific appliance (device).

  • vd-appliance-custom-url-category-delete

    Delete a custom URL category associated with a specific appliance (device).

  • vd-appliance-custom-url-category-edit

    Edit a custom URL category associated with a specific appliance (device). Important note - the data provided in the request overwrites the existing object.

  • vd-appliance-custom-url-category-list

    List all custom URL categories associated with a specific appliance or get a specific custom URL category.

  • vd-appliance-group-list

    List all appliance (device) groups associated with an organization (tenant).

  • vd-appliance-group-template-appliance-list

    List all appliances associated with a specific device-group and associated templates.

  • vd-appliance-list

    List all available appliances for all organizations/tenants, with a maximum of 25 appliances per organization.

  • vd-appliance-sdwan-policy-list

    List all SDWAN policies associated with a specific organization and appliance (device).

  • vd-appliance-sdwan-policy-rule-create

    Create an SDWAN policy rule associated with a specific appliance (device).

  • vd-appliance-sdwan-policy-rule-delete

    Delete an SDWAN policy rule associated with a specific appliance (device).

  • vd-appliance-sdwan-policy-rule-edit

    Edit an SDWAN policy rule associated with a specific appliance (device).

  • vd-appliance-sdwan-policy-rule-list

    List all SDWAN policy rules associated with a specific appliance (device).

  • vd-appliance-user-defined-application-list

    List all user defined application objects associated with a specific organization and appliance (device).

  • vd-appliance-user-modified-application-list

    List all user modified predefined application objects associated with a specific organization and appliance (device).

  • vd-application-service-template-list

    List all application service templates. Can be filtered by organization or a keyword search.

  • vd-auth-start

    Obtain an access token from the API client. If Client ID and Client Secret were not passed as parameters or arguments, a new Auth Client will be created.

  • vd-auth-test

    Run a connectivity test to verify that the OAuth process worked.

  • vd-datastore-template-list

    List all templates associated with a specific datastore. As a best practice, we do not recommend applying rules to datastore templates. Instead, use devices/service/application templates.

  • vd-organization-appliance-list

    List all devices associated with a specific organization.

  • vd-organization-list

    List all organizations/tenants.

  • vd-predefined-application-list

    List all user predefined application objects.

  • vd-template-access-policy-list

    List all access policies associated with a specific organization and template.

  • vd-template-access-policy-rule-create

    Create an access policy configuration (NGFW) rule associated with a specific template.

  • vd-template-access-policy-rule-delete

    Delete an access policy configuration (NGFW) rule associated with a specific template.

  • vd-template-access-policy-rule-edit

    Edit an access policy configuration (NGFW) rule associated with a specific template. Important note - the data provided in the request overwrites the existing rule settings.

  • vd-template-access-policy-rule-list

    List all access policy configuration (NGFW) rules associated with a specific template.

  • vd-template-address-object-create

    Create an address object associated with a specific organization and template.

  • vd-template-address-object-delete

    Delete an address object associated with a specific organization and template.

  • vd-template-address-object-edit

    Create an address object associated with a specific organization and template.

  • vd-template-address-object-list

    List all address objects associated with a specific organization and template.

  • vd-template-change-commit

    Commit a specific template change to an appliance/s (devices). This will trigger a task to make the commit, and then it will be polled to retrieve the status until complete, and the status will be presented.

  • vd-template-custom-url-category-create

    Create a custom URL category associated with a specific template.

  • vd-template-custom-url-category-delete

    Delete a custom URL category associated with a specific template.

  • vd-template-custom-url-category-edit

    Edit a custom URL category associated with a specific template. Important note - the data provided in the request overwrites the existing object.

  • vd-template-custom-url-category-list

    List all custom URL categories associated with a specific template or get a specific custom URL category.

  • vd-template-list

    List all templates associated with a specific organization. Default type argument is 'MAIN'.

  • vd-template-sdwan-policy-list

    List all SDWAN policies associated with a specific organization and template.

  • vd-template-sdwan-policy-rule-create

    Create an SDWAN policy rule associated with a specific template.

  • vd-template-sdwan-policy-rule-delete

    Delete an SDWAN policy rule associated with a specific template.

  • vd-template-sdwan-policy-rule-edit

    Edit an SDWAN policy rule associated with a specific appliance (device).

  • vd-template-sdwan-policy-rule-list

    List all SDWAN policy rules associated with a specific template.

  • vd-template-user-defined-application-list

    List all user defined application objects associated with a specific organization and template.

  • vd-template-user-modified-application-list

    List all user modified predefined application objects associated with a specific organization and template.

from typing import Any

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

# Disable insecure warnings
urllib3.disable_warnings()


""" CONSTANTS """

BASIC_AUTH_PORT = "9182"
ADVANCED_AUTH_PORT = "9183"
DEFAULT_TIMEOUT = 600
DEFAULT_INTERVAL = 10
OAUTH_CLIENT = "XSOAR-OAuth-client"
VENDOR_NAME = "VersaDirector"


# The credentials below are public therefore they are not a secret
CLIENT_ID = "voae_rest"
CLIENT_CREDENTIALS = "asrevnet_123"


# Error messages:
AUTH_EXISTING_TOKEN = "Auth process failed. Existing Token found with the matching name."
AUTH_EXCEEDED_MAXIMUM = "Auth process failed. Possibly exceeded maximum number of allowed tokens."
AUTH_INVALID_CREDENTIALS = "Auth process failed. Invalid credentials returned from API."
BASIC_CREDENTIALS_COULD_NOT_START = (
    "Auth process could not start. To run '!vd-auth-start' command,"
    + " Please enter Username and Password parameters in instance configuration."
)
CLIENT_CREDENTIALS_COULD_NOT_START = (
    "Auth process could not start, missing Client ID and Client Secret command arguments or integration parameters."
)
AUTH_INVALID_ACCESS_TOKEN = (
    "Client authentication failed (e.g., unknown client, no client authentication included,"
    + " or unsupported authentication method)."
)
AUTH_BAD_CREDENTIALS = "Auth process failed. Please check Client ID and Client Secret validity."
AUTH_PARAMETERS_MISSING = (
    "Not all fields for the selected authenticating are"
    + " set or some of the parameters are invalid, therefore it cannot be executed."
)
ALREADY_EXISTS_MSG = "Object already exists."


""" CLIENT CLASS """


class Client(BaseClient):
    def __init__(
        self,
        server_url: str,
        verify: bool,
        proxy: bool,
        headers: dict | None,
        auth: tuple[str, str] | None,
        organization_params: str | None,
    ):
        super().__init__(base_url=server_url, verify=verify, proxy=proxy, headers=headers, auth=auth)
        self.organization_params = organization_params

    #  """ CLIENT HELPER FUNCTIONS """

    def _create_access_policy_rule_request_body(
        self,
        rule_name: str,
        description: str,
        tags: list,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        predefined_application: list,
        user_defined_application: list,
        custom_url_categories: list,
    ):
        request_body = {
            "access-policy": {
                "name": rule_name,
                "description": description,
                "rule-disable": "false",
                "tag": tags,
                "match": {
                    "source": {
                        "zone": {},
                        "address": {
                            "address-list": source_address_objects,
                            "negate": "",
                        },
                        "site-name": [],
                        "user": {
                            "user-type": "any",
                            "local-database": {"status": "disabled"},
                            "external-database": {"status": "disabled"},
                        },
                    },
                    "destination": {
                        "zone": {},
                        "address": {
                            "address-list": destination_address_objects,
                            "negate": "",
                        },
                        "site-name": [],
                    },
                    "application": {
                        "predefined-application-list": predefined_application,
                        "user-defined-application-list": user_defined_application,
                    },
                    "url-category": {"user-defined": custom_url_categories},
                    "url-reputation": {"predefined": url_reputation},
                    "ttl": {},
                },
                "set": {
                    "lef": {
                        "event": "never",
                        "options": {"send-pcap-data": {"enable": False}},
                    },
                    "action": "deny",
                    "tcp-session-keepalive": "disabled",
                },
            }
        }

        return request_body

    def _create_sdwan_policy_rule_request_body(
        self,
        rule_name: str,
        description: str,
        tags: list,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        custom_url_categories: list,
        forwarding_action: str,
        nexthop_ip: str,
        routing_instance: str,
        forwarding_profile: str,
        predefined_application: list,
        user_defined_application: list,
        rule_disable: str,
    ):
        request_body: dict[str, dict] = {
            "rule": {
                "name": rule_name,
                "description": description,
                "tag": tags,
                "rule-disable": rule_disable,
                "match": {
                    "source": {
                        "zone": {},
                        "address": {"address-list": source_address_objects},
                        "user": {
                            "user-type": "any",
                            "local-database": {"status": "disabled"},
                            "external-database": {"status": "disabled"},
                        },
                    },
                    "destination": {
                        "zone": {},
                        "address": {"address-list": destination_address_objects},
                    },
                    "application": {
                        "predefined-application-list": predefined_application,
                        "user-defined-application-list": user_defined_application,
                    },
                    "url-category": {"user-defined": custom_url_categories},
                    "url-reputation": {"predefined": url_reputation},
                    "ttl": {},
                },
                "set": {
                    "lef": {
                        "event": "never",
                        "profile-default": "true",
                        "rate-limit": "10",
                    },
                    "action": forwarding_action,
                    "tcp-optimization": {},
                },
                "monitor": {},
            }
        }

        for key, value in {
            "forwarding-profile": forwarding_profile,
            "nexthop-address": nexthop_ip,
            "routing-instance": routing_instance,
        }.items():
            if value:
                request_body.get("rule", {}).get("set", {}).update({key: value})

        return request_body

    def _create_address_object_request_body(
        self, object_name: str, description: str, tags: list, address_object_type: str, object_value: str
    ):
        request_body = {
            "address": {
                "name": object_name,
                "description": description,
                "tag": tags,
                address_object_type: object_value,
            }
        }

        return request_body

    def _create_custom_url_category_request_body(
        self,
        url_category_name: str,
        description: str,
        confidence: str,
        urls: list,
        url_reputation: list,
        patterns: list,
        pattern_reputation: list,
    ):
        urls_dict: dict[str, list] = {
            "strings": [],
            "patterns": [],
        }

        if urls:
            urls_dict_strings = urls_dict.get("strings", [])
            for value in urls:
                urls_dict_strings.append({"string-value": value})

            if url_reputation:
                for i in range(len(url_reputation)):
                    urls_dict_strings[i]["reputation"] = url_reputation[i]

        if patterns:
            urls_dict_patterns = urls_dict.get("patterns", [])
            for value in patterns:
                urls_dict_patterns.append({"pattern-value": value})

            if pattern_reputation:
                for i in range(len(pattern_reputation)):
                    urls_dict_patterns[i]["reputation"] = pattern_reputation[i]

        request_body = {
            "url-category": {
                "category-name": url_category_name,
                "category-description": description,
                "confidence": confidence,
                "urls": urls_dict,
            }
        }

        return request_body

    #  """ REQUEST FUNCTIONS """

    def test_organization_name_request(self, organization_name: str):
        try:
            self._http_request(
                "GET",
                url_suffix=f"nextgen/deviceGroup?organization={organization_name}",
                headers=self._headers,
            )
        except DemistoException:
            return_error("Organization Name parameter is invalid.")

    def refresh_token_request(self, client_id: str, client_secret: str, refresh_token: str):
        request_body = {
            "client_id": f"{client_id}",
            "client_secret": f"{client_secret}",
            "grant_type": "refresh_token",
            "refresh_token": f"{refresh_token}",
        }

        response = self._http_request(
            "POST",
            url_suffix="auth/refresh",
            headers=self._headers,
            json_data=request_body,
        )

        return response

    def appliance_list_request(self, offset: int | None = None, limit: int | None = None):
        params = assign_params(offset=offset, limit=limit)

        response = self._http_request(
            "GET",
            url_suffix="vnms/cloud/systems/getAllAppliancesBasicDetails",
            params=params,
            headers=self._headers,
        )

        return response

    def organization_list_request(self, offset: int | None = None, limit: int | None = None):
        params = assign_params(limit=limit, offset=offset)

        response = self._http_request(
            "GET",
            url_suffix="nextgen/organization",
            params=params,
            headers=self._headers,
        )

        return response

    def appliances_list_by_organization_request(self, organization: str, offset: int | None = None, limit: int | None = None):
        params = assign_params(offset=offset, limit=limit)

        response = self._http_request(
            "GET",
            url_suffix=f"vnms/appliance/filter/{organization}",
            params=params,
            headers=self._headers,
        )

        return response

    def appliances_group_list_by_organization_request(
        self, organization: str, offset: int | None = None, limit: int | None = None
    ):
        params = assign_params(organization_name=organization, offset=offset, limit=limit)
        response = self._http_request(
            "GET",
            url_suffix="nextgen/deviceGroup",
            params=params,
            headers=self._headers,
        )

        return response

    def appliances_list_by_device_group_request(
        self,
        device_group: str,
        template_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)

        response = self._http_request(
            "GET",
            url_suffix=f"nextgen/deviceGroup/{device_group}/template/{template_name}",
            params=params,
            headers=self._headers,
        )

        return response

    def template_list_by_organization_request(
        self,
        organization: str | None = None,
        type: list | None = None,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(organization=organization, type=type, offset=offset, limit=limit)

        response = self._http_request(
            "GET",
            url_suffix="vnms/template/metadata",
            params=params,
            headers=self._headers,
        )

        return response

    def template_list_by_datastore_request(self, organization: str, offset: int | None = None, limit: int | None = None):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/template/{organization}-DataStore/config/orgs/org",
            params=params,
            headers=headers,
        )

        return response

    def application_service_template_list_request(
        self,
        organization: str | None = None,
        keyword: str | None = None,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(organization=organization, searchKeyword=keyword, offset=offset, limit=limit)
        response = self._http_request(
            "GET",
            url_suffix="/nextgen/applicationServiceTemplate",
            params=params,
            headers=self._headers,
        )

        return response

    def template_change_commit_request(self, template_name: str, appliances: list, mode: str, reboot: str):
        request_body = {
            "versanms.templateRequest": {
                "device-list": appliances,
                "mode": f"{mode}",
                "reboot": f"{reboot}",
            }
        }

        response = self._http_request(
            "POST",
            url_suffix=f"vnms/template/applyTemplate/{template_name}/devices",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(
                200,
            ),  # ok_codes default value is insufficient because this http request should only accept status code 200.
            resp_type="response",
        )
        return response

    def template_change_commit_polling_request(self, task_id: str):
        response = self._http_request(
            "GET",
            url_suffix=f"/vnms/tasks/task/{task_id}",
            headers=self._headers,
        )
        return response

    def template_custom_url_category_list_request(
        self,
        organization: str,
        template_name: str,
        url_category_name: str | None = None,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(url_category_name=url_category_name, offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"/api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + "/url-filtering/user-defined-url-categories/url-category",
            params=params,
            headers=headers,
        )

        return response

    def template_custom_url_category_create_request(
        self,
        organization: str,
        template_name: str,
        url_category_name: str,
        description: str,
        confidence: str,
        urls: list,
        url_reputation: list,
        patterns: list,
        pattern_reputation: list,
    ):
        request_body = self._create_custom_url_category_request_body(
            url_category_name,
            description,
            confidence,
            urls,
            url_reputation,
            patterns,
            pattern_reputation,
        )

        response = self._http_request(
            "POST",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/"
            + f"{organization}/url-filtering/user-defined-url-categories",
            headers=self._headers,
            json_data=request_body,
            resp_type="response",
            ok_codes=(200, 201),
        )

        return response

    def template_custom_url_category_edit_request(
        self,
        organization: str,
        template_name: str,
        url_category_name: str,
        description: str,
        confidence: str,
        urls: list,
        url_reputation: list,
        patterns: list,
        pattern_reputation: list,
    ):
        request_body = self._create_custom_url_category_request_body(
            url_category_name,
            description,
            confidence,
            urls,
            url_reputation,
            patterns,
            pattern_reputation,
        )

        response = self._http_request(
            "PUT",
            url_suffix=f"/api/config/devices/template/{template_name}/config/orgs/org-services/"
            + f"{organization}/url-filtering/user-defined-url-categories/url-category/{url_category_name}",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201, 204),
            return_empty_response=True,
        )

        return response, request_body

    def template_custom_url_category_delete_request(self, organization: str, template_name: str, url_category_name: str):
        response = self._http_request(
            "DELETE",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/"
            + f"{organization}/url-filtering/user-defined-url-categories/url-category/{url_category_name}",
            headers=self._headers,
            ok_codes=(200, 201, 204),
            return_empty_response=True,
        )

        return response

    def appliance_custom_url_category_list_request(
        self,
        organization: str,
        appliance_name: str,
        url_category_name: str | None = None,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)

        suffix = (
            f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + "/url-filtering/user-defined-url-categories/url-category"
        )
        if url_category_name:
            suffix += f"/{url_category_name}"

        headers = self._headers

        response = self._http_request("GET", url_suffix=suffix, params=params, headers=headers)
        return response

    def appliance_custom_url_category_create_request(
        self,
        organization: str,
        appliance_name: str,
        url_category_name: str,
        description: str,
        confidence: str,
        urls: list,
        url_reputation: list,
        patterns: list,
        pattern_reputation: list,
    ):
        request_body = self._create_custom_url_category_request_body(
            url_category_name,
            description,
            confidence,
            urls,
            url_reputation,
            patterns,
            pattern_reputation,
        )

        response = self._http_request(
            "POST",
            url_suffix=f"/api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + "/url-filtering/user-defined-url-categories",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201, 204),
            resp_type="response",
        )

        return response, request_body

    def appliance_custom_url_category_edit_request(
        self,
        organization: str,
        appliance_name: str,
        url_category_name: str,
        description: str,
        confidence: str,
        urls: list,
        url_reputation: list,
        patterns: list,
        pattern_reputation: list,
    ):
        request_body = self._create_custom_url_category_request_body(
            url_category_name,
            description,
            confidence,
            urls,
            url_reputation,
            patterns,
            pattern_reputation,
        )

        response = self._http_request(
            "PUT",
            url_suffix=f"/api/config/devices/template/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/url-filtering/user-defined-url-categories/url-category/{url_category_name}",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 204),
            return_empty_response=True,
        )

        return response, request_body

    def appliance_custom_url_category_delete_request(self, organization: str, appliance_name: str, url_category_name: str):
        response = self._http_request(
            "DELETE",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/url-filtering/user-defined-url-categories/url-category/{url_category_name}",
            headers=self._headers,
            ok_codes=(200, 204),
            return_empty_response=True,
        )

        return response

    def template_access_policy_list_request(
        self,
        organization: str,
        template_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + "/security/access-policies/access-policy-group",
            params=params,
            headers=headers,
        )
        return response

    def template_access_policy_rule_list_request(
        self,
        organization: str,
        template_name: str,
        access_policy_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/security/access-policies/access-policy-group/{access_policy_name}/rules/access-policy",
            params=params,
            headers=headers,
        )
        return response

    def template_access_policy_rule_create_request(
        self,
        organization: str,
        template_name: str,
        access_policy_name: str,
        rule_name: str,
        description: str,
        tags: list,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        predefined_application: list,
        user_defined_application: list,
        custom_url_categories: list,
    ):
        request_body = self._create_access_policy_rule_request_body(
            rule_name,
            description,
            tags,
            source_address_objects,
            destination_address_objects,
            url_reputation,
            predefined_application,
            user_defined_application,
            custom_url_categories,
        )

        response = self._http_request(
            "POST",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/security/access-policies/access-policy-group/{access_policy_name}/rules",
            headers=self._headers,
            json_data=request_body,
            resp_type="response",
            ok_codes=(200, 201, 204),
        )

        return response, request_body

    def template_access_policy_rule_edit_request(
        self,
        organization: str,
        template_name: str,
        access_policy_name: str,
        rule_name: str,
        description: str,
        tags: list,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        predefined_application: list,
        user_defined_application: list,
        custom_url_categories: list,
    ):
        request_body = self._create_access_policy_rule_request_body(
            rule_name,
            description,
            tags,
            source_address_objects,
            destination_address_objects,
            url_reputation,
            predefined_application,
            user_defined_application,
            custom_url_categories,
        )

        response = self._http_request(
            "PUT",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/security/access-policies/access-policy-group/{access_policy_name}/rules/access-policy/{rule_name}",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201, 204),
            return_empty_response=True,
        )
        return response, request_body

    def template_access_policy_rule_delete_request(
        self,
        organization: str,
        template_name: str,
        access_policy_name: str,
        rule_name: str,
    ):
        response = self._http_request(
            "DELETE",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/security/access-policies/access-policy-group/{access_policy_name}/rules/access-policy/{rule_name}",
            headers=self._headers,
            ok_codes=(200, 201, 204),
            return_empty_response=True,
        )
        return response

    def appliance_access_policy_list_request(
        self,
        organization: str,
        appliance_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + "/security/access-policies/access-policy-group",
            params=params,
            headers=headers,
            ok_codes=(200, 201),
        )
        return response

    def appliance_access_policy_rule_list_request(
        self,
        organization: str,
        appliance_name: str,
        access_policy_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/security/access-policies/access-policy-group/{access_policy_name}/rules/access-policy",
            params=params,
            headers=headers,
        )
        return response

    def appliance_access_policy_rule_create_request(
        self,
        organization: str,
        appliance_name: str,
        access_policy_name: str,
        rule_name: str,
        description: str,
        tags: list,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        predefined_application: list,
        user_defined_application: list,
        custom_url_categories: list,
    ):
        request_body = self._create_access_policy_rule_request_body(
            rule_name,
            description,
            tags,
            source_address_objects,
            destination_address_objects,
            url_reputation,
            predefined_application,
            user_defined_application,
            custom_url_categories,
        )

        response = self._http_request(
            "POST",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/security/access-policies/access-policy-group/{access_policy_name}/rules",
            headers=self._headers,
            json_data=request_body,
            resp_type="response",
            ok_codes=(200, 201, 204),
        )

        return response, request_body

    def appliance_access_policy_rule_edit_request(
        self,
        organization: str,
        appliance_name: str,
        access_policy_name: str,
        rule_name: str,
        description: str,
        tags: list,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        predefined_application: list,
        user_defined_application: list,
        custom_url_categories: list,
    ):
        request_body = self._create_access_policy_rule_request_body(
            rule_name,
            description,
            tags,
            source_address_objects,
            destination_address_objects,
            url_reputation,
            predefined_application,
            user_defined_application,
            custom_url_categories,
        )

        response = self._http_request(
            "PUT",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/security/access-policies/access-policy-group/{access_policy_name}/rules/access-policy/{rule_name}",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201, 204),
            return_empty_response=True,
        )
        return response, request_body

    def appliance_access_policy_rule_delete_request(
        self,
        organization: str,
        appliance_name: str,
        access_policy_name: str,
        rule_name: str,
    ):
        response = self._http_request(
            "DELETE",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/security/access-policies/access-policy-group/{access_policy_name}/rules/access-policy/{rule_name}",
            headers=self._headers,
            ok_codes=(200, 201, 204),
            return_empty_response=True,
        )
        return response

    def template_sdwan_policy_list_request(
        self,
        organization: str,
        template_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + "/sd-wan/policies/sdwan-policy-group",
            params=params,
            headers=headers,
        )
        return response

    def template_sdwan_policy_rule_request(
        self,
        organization: str,
        template_name: str,
        sdwan_policy_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/sd-wan/policies/sdwan-policy-group/{sdwan_policy_name}/rules/rule",
            params=params,
            headers=headers,
        )
        return response

    def template_sdwan_policy_rule_create_request(
        self,
        organization: str,
        template_name: str,
        sdwan_policy_name: str,
        rule_name: str,
        description: str,
        tags: list,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        custom_url_categories: list,
        forwarding_action: str,
        nexthop_ip: str,
        routing_instance: str,
        forwarding_profile: str,
        predefined_application: list,
        user_defined_application: list,
        rule_disable: str,
    ):
        request_body = self._create_sdwan_policy_rule_request_body(
            rule_name,
            description,
            tags,
            source_address_objects,
            destination_address_objects,
            url_reputation,
            custom_url_categories,
            forwarding_action,
            nexthop_ip,
            routing_instance,
            forwarding_profile,
            predefined_application,
            user_defined_application,
            rule_disable,
        )

        response = self._http_request(
            "POST",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/sd-wan/policies/sdwan-policy-group/{sdwan_policy_name}/rules",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201),
            resp_type="response",
        )

        return response, request_body

    def template_sdwan_policy_rule_edit_request(
        self,
        organization: str,
        template_name: str,
        sdwan_policy_name: str,
        rule_name: str,
        description: str,
        tags: list,
        rule_disable: str,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        custom_url_categories: list,
        forwarding_action: str,
        nexthop_ip: str,
        routing_instance: str,
        forwarding_profile: str,
        predefined_application: list,
        user_defined_application: list,
    ):
        request_body = self._create_sdwan_policy_rule_request_body(
            rule_name,
            description,
            tags,
            source_address_objects,
            destination_address_objects,
            url_reputation,
            custom_url_categories,
            forwarding_action,
            nexthop_ip,
            routing_instance,
            forwarding_profile,
            predefined_application,
            user_defined_application,
            rule_disable,
        )

        response = self._http_request(
            "PUT",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/sd-wan/policies/sdwan-policy-group/{sdwan_policy_name}/rules/rule/{rule_name}",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201, 204),
            return_empty_response=True,
        )

        return response, request_body

    def template_sdwan_policy_rule_delete_request(
        self,
        organization: str,
        template_name: str,
        sdwan_policy_name: str,
        rule_name: str,
    ):
        response = self._http_request(
            "DELETE",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/sd-wan/policies/sdwan-policy-group/{sdwan_policy_name}/rules/rule/{rule_name}",
            headers=self._headers,
            ok_codes=(200, 201, 204),
            return_empty_response=True,
        )
        return response

    def appliance_sdwan_policy_list_request(
        self,
        organization: str,
        appliance_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + "/sd-wan/policies/sdwan-policy-group",
            params=params,
            headers=headers,
        )
        return response

    def appliance_sdwan_policy_rule_list_request(
        self,
        organization: str,
        appliance_name: str,
        sdwan_policy_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/sd-wan/policies/sdwan-policy-group/{sdwan_policy_name}/rules/rule",
            params=params,
            headers=headers,
        )
        return response

    def appliance_sdwan_policy_rule_create_request(
        self,
        organization: str,
        appliance_name: str,
        sdwan_policy_name: str,
        rule_name: str,
        description: str,
        tags: list,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        custom_url_categories: list,
        forwarding_action: str,
        nexthop_ip: str,
        routing_instance: str,
        forwarding_profile: str,
        predefined_application: list,
        user_defined_application: list,
        rule_disable: str,
    ):
        request_body = self._create_sdwan_policy_rule_request_body(
            rule_name,
            description,
            tags,
            source_address_objects,
            destination_address_objects,
            url_reputation,
            custom_url_categories,
            forwarding_action,
            nexthop_ip,
            routing_instance,
            forwarding_profile,
            predefined_application,
            user_defined_application,
            rule_disable,
        )

        response = self._http_request(
            "POST",
            url_suffix=f"/api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/sd-wan/policies/sdwan-policy-group/{sdwan_policy_name}/rules",
            headers=self._headers,
            resp_type="response",
            json_data=request_body,
            ok_codes=(200, 201),
        )
        return response, request_body

    def appliance_sdwan_policy_rule_edit_request(
        self,
        organization: str,
        appliance_name: str,
        sdwan_policy_name: str,
        rule_name: str,
        description: str,
        tags: list,
        rule_disable: str,
        source_address_objects: list,
        destination_address_objects: list,
        url_reputation: list,
        custom_url_categories: list,
        forwarding_action: str,
        nexthop_ip: str,
        routing_instance: str,
        forwarding_profile: str,
        predefined_application: list,
        user_defined_application: list,
    ):
        request_body = self._create_sdwan_policy_rule_request_body(
            rule_name,
            description,
            tags,
            source_address_objects,
            destination_address_objects,
            url_reputation,
            custom_url_categories,
            forwarding_action,
            nexthop_ip,
            routing_instance,
            forwarding_profile,
            predefined_application,
            user_defined_application,
            rule_disable,
        )

        response = self._http_request(
            "PUT",
            url_suffix=f"/api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/sd-wan/policies/sdwan-policy-group/{sdwan_policy_name}/rules/{rule_name}",
            headers=self._headers,
            resp_type="response",
            json_data=request_body,
            ok_codes=(200, 201),
        )
        return response, request_body

    def appliance_sdwan_policy_rule_delete_request(
        self,
        organization: str,
        appliance_name: str,
        sdwan_policy_name: str,
        rule_name: str,
    ):
        response = self._http_request(
            "DELETE",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/sd-wan/policies/sdwan-policy-group/{sdwan_policy_name}/rules/rule/{rule_name}",
            headers=self._headers,
            resp_type="response",
            ok_codes=(200, 204),
            return_empty_response=True,
        )
        return response

    def template_address_object_list_request(
        self,
        organization: str,
        template_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/"
            + f"{organization}/objects/addresses/address",
            params=params,
            headers=headers,
        )
        return response

    def template_address_object_create_request(
        self,
        organization: str,
        template_name: str,
        object_name: str,
        description: str,
        tags: list,
        address_object_type: str,
        object_value: str,
    ):
        request_body = self._create_address_object_request_body(object_name, description, tags, address_object_type, object_value)

        response = self._http_request(
            "POST",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}/objects/addresses",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201),
            resp_type="response",
        )

        return response, request_body

    def template_address_object_edit_request(
        self,
        organization: str,
        template_name: str,
        object_name: str,
        description: str,
        tags: list,
        address_object_type: str,
        object_value: str,
    ):
        request_body = self._create_address_object_request_body(object_name, description, tags, address_object_type, object_value)

        response = self._http_request(
            "PUT",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/objects/addresses/address/{object_name}",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201, 204),
            resp_type="response",
            return_empty_response=True,
        )

        return response, request_body

    def template_address_object_delete_request(self, organization: str, template_name: str, object_name: str):
        response = self._http_request(
            "DELETE",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + f"/objects/addresses/address/{object_name}",
            headers=self._headers,
            ok_codes=(200, 201, 204),
            resp_type="response",
            return_empty_response=True,
        )

        return response

    def appliance_address_object_list_request(
        self,
        organization: str,
        appliance_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + "/objects/addresses/address",
            params=params,
            headers=headers,
        )
        return response

    def appliance_address_object_create_request(
        self,
        organization: str,
        appliance_name: str,
        object_name: str,
        description: str,
        tags: list,
        address_object_type: str,
        object_value: str,
    ):
        request_body = self._create_address_object_request_body(object_name, description, tags, address_object_type, object_value)

        response = self._http_request(
            "POST",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}/objects/addresses",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201),
            resp_type="response",
        )

        return response, request_body

    def appliance_address_object_edit_request(
        self,
        organization: str,
        appliance_name: str,
        object_name: str,
        description: str,
        tags: list,
        address_object_type: str,
        object_value: str,
    ):
        request_body = self._create_address_object_request_body(object_name, description, tags, address_object_type, object_value)

        response = self._http_request(
            "PUT",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/objects/addresses/address/{object_name}",
            headers=self._headers,
            json_data=request_body,
            ok_codes=(200, 201, 204),
            resp_type="response",
            return_empty_response=True,
        )

        return response, request_body

    def appliance_address_object_delete_request(self, organization: str, appliance_name: str, object_name: str):
        response = self._http_request(
            "DELETE",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + f"/objects/addresses/address/{object_name}",
            headers=self._headers,
            ok_codes=(200, 201, 204),
            resp_type="response",
            return_empty_response=True,
        )

        return response

    def template_user_defined_application_list_request(
        self,
        organization: str,
        template_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + "/application-identification/user-defined-applications/user-defined-application",
            params=params,
            headers=headers,
            ok_codes=(200, 201, 204),
        )
        return response

    def appliance_user_defined_application_list_request(
        self,
        organization: str,
        appliance_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + "/application-identification/user-defined-applications/user-defined-application",
            params=params,
            headers=headers,
            ok_codes=(200, 201),
        )
        return response

    def template_user_modified_application_list_request(
        self,
        organization: str,
        template_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/template/{template_name}/config/orgs/org-services/{organization}"
            + "/application-identification/application-specific-options/app-specific-option-list",
            params=params,
            headers=headers,
            ok_codes=(200, 201),
        )
        return response

    def appliance_user_modified_application_list_request(
        self,
        organization: str,
        appliance_name: str,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(offset=offset, limit=limit)
        headers = self._headers

        response = self._http_request(
            "GET",
            url_suffix=f"api/config/devices/device/{appliance_name}/config/orgs/org-services/{organization}"
            + "/application-identification/application-specific-options/app-specific-option-list",
            params=params,
            headers=headers,
            ok_codes=(200, 201),
        )
        return response

    def predefined_application_list_request(
        self,
        family: str | None = None,
        risk: int | None = None,
        tags: list | None = None,
        offset: int | None = None,
        limit: int | None = None,
    ):
        params = assign_params(family=family, risk=risk, tags=tags, offset=offset, limit=limit)
        response = self._http_request(
            "GET",
            url_suffix="vnms/spack/predefined?xPath=/predefined/config/predefined-applications"
            + "/application-identification/applications/application",
            params=params,
            headers=self._headers,
            resp_type="json",
            ok_codes=(200, 201, 204),
        )
        return response


""" REQUEST FUNCTIONS (NEEDED TO INITIALIZE CLIENT CLASS) """


def request_access_token(
    server_url: str, verify: bool, proxy: bool, username: str, password: str, client_id: str, client_secret: str
):
    request_body = {
        "client_id": client_id,
        "client_secret": client_secret,
        "username": username,
        "password": password,
        "grant_type": "password",
    }
    return generic_http_request(
        "POST",
        server_url=server_url,
        url_suffix="auth/token",
        verify=verify,
        proxy=proxy,
        json_data=request_body,
    )


def request_auth_credentials(
    server_url: str, verify: bool, proxy: bool, access_token: str, client_name: str, client_description: str
):
    request_body = {
        "name": client_name,
        "description": client_description,
        "expires_at": "",
        "client_secret_expires_at": "",
        "max_access_tokens": 10,
        "max_access_tokens_per_user": 99,
        "access_token_validity": 900,
        "refresh_token_validity": 86400,
        "allowed_grant_types": ["password", "refresh_token", "client_credentials"],
        "allowed_source_client_address": {
            "source_type": "ANYWHERE",
            "ip_address_list": [],
        },
        "enabled": "true",
        "software_id": "",
        "software_version": "",
        "contacts": [],
        "redirect_uris": [],
    }
    headers = {"Authorization": f"Bearer {access_token}"}
    return generic_http_request(
        "POST",
        server_url=server_url,
        url_suffix="auth/admin/clients",
        verify=verify,
        proxy=proxy,
        headers=headers,
        json_data=request_body,
    )


""" HELPER FUNCTIONS """


def set_offset(page: int | None, page_size: int | None):
    """Determine offset according to 'page' and 'page_size' arguments

    :type page: ``Optional[int]``
    :param page: start index of page

    :type page_size: ``Optional[int]``
    :param ip: size of page

    :return: offset
    :rtype: Optional[int]
    """
    if not page:
        return page_size
    elif (isinstance(page, int) and isinstance(page_size, int)) and (page >= 0 and page_size >= 0):
        return page * page_size
    else:
        raise DemistoException(message="'page' or 'page_size' arguments are invalid.")


def check_limit(limit: int | None):
    """Given 'limit' as an argument, check its validity

    :type limit: ``int``

    :return: None
    :rtype: None
    """
    if isinstance(limit, int) and limit <= 0:
        raise DemistoException("Please provide a positive value for 'limit' argument.")


def set_organization(organization_args: str | None, organization_params: str | None):
    """Given two choices for default organization name (arguments or parameters), check if organization name exists.

    :type organization_args: ``str``
    :param organization_args: organization name from arguments

    :type organization_params: ``str``
    :param organization_params: organization name from parameters

    :return: organization
    :rtype: string
    """
    organization = organization_args or organization_params

    if not organization:
        raise DemistoException("Please provide 'Organization Name' via integration configuration or command argument.")

    return organization


def check_and_update_token(client: Client, client_id: str, client_secret: str, current_context: dict[str, Any]):
    """Checks if current auth token is valid.
    If needed - updates auth token using available refresh token.
    Updates new auth token in integration context.

    :type organization_args: ``Client``
    :param client: Client object

    :type client_id: ``str``
    :param client_id: client id parameter

    :type client_secret: ``str``
    :param client_id: client secret parameter

    :type current_context: ``dict[str, any]``
    :param current_context: current integration context

    :rtype: Tuple(boolean,str)
    """

    try:
        test_connectivity(client)  # send HTTP request to check if token is valid
    except DemistoException as e:
        if e.res.status_code == 401 or "invalid_token" in str(e.message):
            if current_context:
                # obtain refresh token and send it using client.refresh_token_request function
                refresh_token = current_context.get("refresh_token", "")

                client._headers = None

                # response contains updated auth_token to be used as Bearer token
                response = client.refresh_token_request(client_id, client_secret, refresh_token)
                auth_token = response.get("access_token")

                # integration context is updated with new access token and refresh token
                response["client_id"] = client_id
                response["client_secret"] = client_secret
                update_integration_auth_context(response)

                return auth_token
            else:
                raise DemistoException(
                    "Auth Token Expired, Refresh Token is not found."
                    + "Please create a new Auth Token using '!vd-auth-start' command."
                )

    return None


def create_client_header(
    use_basic_auth: bool,
    username: str,
    password: str,
    client_id: str | None,
    client_secret: str | None,
    access_token: str | None,
) -> tuple[tuple[str, str] | None, dict[str, str]]:
    """
    Creates Auth and Header arguments for the Client object based on the authentication
    method selected in the integration instance configuration.

    :type use_token: ``bool``
    :param use_token: boolean argument indicating which type of authentication will be used.

    :type username: ``str``
    :param username: Username parameter from instance configuration.

    :type password: ``str``
    :param password: Password parameter from instance configuration.

    :type client_id: ``str``
    :param client_id: Client ID parameter from instance configuration.

    :type client_secret: ``str``
    :param client_secret: Client Secret parameter from instance configuration.

    :type access_token: ``str``
    :param access_token: Access Token parameter from instance configuration.

    :rtype: Tuple(Optional[None,str],dict[str,str])
    returns (auth, header) tuple
    """
    # Basic Authentication
    if use_basic_auth:
        if username and password:
            credentials = f"{username}:{password}"
            auth_header = f"Basic {b64_encode(credentials)}"
            return (username, password), {
                "Authorization": auth_header,
                "Accept": "application/json",
                "Content-Type": "application/json",
            }
        else:
            raise DemistoException("Basic Authentication method chosen but Username or Password parameters are missing.")

    elif not use_basic_auth:
        # Auth Token authentication using Auth token parameter
        case_auth_token = bool(access_token and (not client_id and not client_secret))
        # Auth token already created and saved in integration context using `vd-auth-start`
        case_context = all([client_id, client_secret, access_token])

        if case_auth_token or case_context:
            return None, {
                "Authorization": f"Bearer {access_token}",
                "Accept": "application/json",
                "Content-Type": "application/json",
            }

        else:
            raise DemistoException(
                "Auth Authentication method chosen but Access Token, "
                + "Client ID or Client Secret parameters are missing or invalid."
                + " Please enter Client ID and Client Secret OR Auth Token parameters OR use '!vd-auth-start' command."
            )

    else:
        raise DemistoException(message=AUTH_PARAMETERS_MISSING)


def update_integration_auth_context(obj: dict[Any, Any]) -> None:
    """Update integration context. wraps 'set_integration_context'.

    Args:
        obj (dict[Any, Any]): dictionary to be updated in integration context
    """
    temp_context = get_integration_context()
    if temp_context.get("context"):
        temp_context = temp_context.get("context")
    temp_context.update(obj)
    set_integration_context({"context": temp_context})


def get_access_policy_rule_args_with_possible_custom_rule_json(args: dict[str, Any]) -> dict[str, Any]:
    """Get multiple arguments for access policy rule create/edit commands. handles custom_rule_json if passed as argument.

    Args:
        args (dict[str, Any]): args dictionary

    Returns:
        dict[str, Any]: dictionary of arguments
    """
    if custom_rule_json := args.get("custom_rule_json"):
        access_policy = custom_rule_json.get("access-policy", "")
        rule_name = access_policy.get("name", "")
        description = access_policy.get("description", "")
        tags = argToList(access_policy.get("tag"))
        source_address_objects = argToList(access_policy.get("match", {}).get("source", {}).get("address"))
        destination_address_objects = argToList(access_policy.get("match", {}).get("destination", {}).get("address"))
        url_reputation = argToList(access_policy.get("match", {}).get("url-reputation", {}).get("predefined"))
        predefined_application = argToList(
            access_policy.get("match", {}).get("application", {}).get("predefined-application-list")
        )

        user_defined_application = argToList(
            access_policy.get("match", {}).get("application", {}).get("user-defined-application-list")
        )
        custom_url_categories = []
    else:
        rule_name = args.get("rule_name", "")
        description = args.get("description", "")
        tags = argToList(args.get("tags"))
        source_address_objects = argToList(args.get("source_address_objects"))
        destination_address_objects = argToList(args.get("destination_address_objects"))
        url_reputation = argToList(args.get("url_reputation"))
        predefined_application = argToList(args.get("predefined_application"))
        user_defined_application = argToList(args.get("user_defined_application"))
        custom_url_categories = argToList(args.get("custom_url_categories"))

    return {
        "rule_name": rule_name,
        "description": description,
        "tags": tags,
        "source_address_objects": source_address_objects,
        "destination_address_objects": destination_address_objects,
        "url_reputation": url_reputation,
        "predefined_application": predefined_application,
        "user_defined_application": user_defined_application,
        "custom_url_categories": custom_url_categories,
    }


def get_sdwan_policy_rule_args_with_possible_custom_rule_json(args: dict[str, Any]) -> dict[str, Any]:
    """Get multiple arguments for sdwan policy rule create/edit commands. handles custom_rule_json if passed as argument.

    Args:
        args (dict[str, Any]): args dictionary

    Returns:
        dict[str, Any]: dictionary of arguments
    """
    if custom_rule_json := args.get("custom_rule_json"):
        rule = custom_rule_json.get("rule", {})
        rule_name = rule.get("name", "")
        description = rule.get("description", "")
        tags = argToList(rule.get("tag"))
        source_address_objects = rule.get("source", {}).get("address", {}).get("address-list", [])
        destination_address_objects = rule.get("destination", {}).get("address", {}).get("address-list", [])
        url_reputation = rule.get("match", {}).get("source", {}).get("url-reputation", [])
        custom_url_categories = rule.get("match", {}).get("url-category", {}).get("predefined", {}).get("user-defined", [])
        forwarding_action = rule.get("set", {}).get("action", {}).get("action", "")
        nexthop_ip = rule.get("set", {}).get("nexthop-address	", {})
        routing_instance = rule.get("match", {}).get("routing-instance", "")
        forwarding_profile = rule.get("set", {}).get("forwarding-profile", "")
        predefined_application = rule.get("match", {}).get("application", {}).get("predefined-application-list", [])
        user_defined_application = rule.get("match", {}).get("application", {}).get("user-defined-application-list", [])
        rule_disable = args.get("rule_disable", "false")

    else:
        rule_name = args.get("rule_name", "")
        description = args.get("description", "")
        tags = argToList(args.get("tag"))
        source_address_objects = argToList(args.get("source_address_objects"))
        destination_address_objects = argToList(args.get("destination_address_objects"))
        url_reputation = argToList(args.get("url_reputation"))
        custom_url_categories = argToList(args.get("custom_url_categories"))
        forwarding_action = args.get("forwarding_action", "")
        nexthop_ip = args.get("nexthop_ip", "")
        routing_instance = args.get("routing_instance", "")
        forwarding_profile = args.get("forwarding_profile", "")
        predefined_application = argToList(args.get("predefined_application"))
        user_defined_application = argToList(args.get("user_defined_application"))
        rule_disable = args.get("rule_disable", "false")

    return {
        "rule_name": rule_name,
        "description": description,
        "tags": tags,
        "source_address_objects": source_address_objects,
        "destination_address_objects": destination_address_objects,
        "url_reputation": url_reputation,
        "custom_url_categories": custom_url_categories,
        "forwarding_action": forwarding_action,
        "nexthop_ip": nexthop_ip,
        "routing_instance": routing_instance,
        "forwarding_profile": forwarding_profile,
        "predefined_application": predefined_application,
        "user_defined_application": user_defined_application,
        "rule_disable": rule_disable,
    }


#  """ COMMAND FUNCTIONS """


def auth_start_command(
    server_url: str,
    verify: bool,
    proxy: bool,
    username: str,
    password: str,
    client_id_param: str | None,
    client_secret_param: str | None,
    use_basic_auth: bool,
    args: dict[str, Any],
) -> CommandResults:
    """Creates Auth Clients and Auth tokens.

    The function will first determine whether Client ID and Client Secret were passed as parameters (default) or arguments,
    indicating an existing Auth Client.
    If not, it will use the VOEA REST API (from the product's official API documentation) to create a new Auth Client.

    When an Auth Client exists, the function will send a request to generate a new Auth Token.
    If successful, All of the Token's relevant information will be saved in the
    Integration Context for Later Use and Refresh Token requests.

    Args:
        client (Client): Client object
        args (Dict[str, Any]): command arguments

    Raises:
        DemistoException: raises DemistoException errors related to bad arguments/parameters or
                            failure in a specific step of the authentication process

    Returns:
        CommandResults: returns message in the War room if authentication process was successful
    """
    if not (username and password):
        raise DemistoException(message=BASIC_CREDENTIALS_COULD_NOT_START)

    client_name = args.get("auth_client_name", OAUTH_CLIENT)
    client_description = args.get("description", f"{OAUTH_CLIENT} for Versa Director Integration")
    client_id = ""
    client_secret = ""
    _outputs = None
    oauth_client_created_msg = ""

    # check if Client ID and Client Secret were passed as parameters
    if client_id_param and client_secret_param:
        demisto.debug("Taking client credentials from configuration parameters. Skipping to stage 3.")
        client_id = client_id_param
        client_secret = client_secret_param

    # check if Client ID and Client Secret were passed as arguments
    elif "client_id" and "client_secret" in args:
        demisto.debug("Taking client credentials from command arguments. Skipping to stage 3.")
        client_id = args.get("client_id", "")
        client_secret = args.get("client_secret", "")

    # if Client ID and Client Secret are not passed, create new Client ID and Client Secret (New Auth Client)
    else:
        demisto.debug("Creating new auth client using default client credentials and basic auth credentials. Starting stage 1.")
        if server_url.endswith(BASIC_AUTH_PORT):
            server_url = server_url.replace(BASIC_AUTH_PORT, ADVANCED_AUTH_PORT)

        try:
            # stage 1: Obtain Access token from voae_rest client
            demisto.debug("Stage 1: Requesting access token using using default client credentials and basic auth credentials.")
            token_response = request_access_token(
                server_url=server_url,
                verify=verify,
                proxy=proxy,
                username=username,
                password=password,
                client_id=CLIENT_ID,
                client_secret=CLIENT_CREDENTIALS,
            )
            access_token = token_response.get("access_token", "")

            # stage 2: If successful, use the “Access_token” from the response as a “Bearer token”
            # authorization to created the desired "Auth Client"
            demisto.debug("Stage 2: Requesting new auth client credentials using returned access token.")
            admin_clients_response = request_auth_credentials(
                server_url=server_url,
                verify=verify,
                proxy=proxy,
                access_token=access_token,
                client_name=client_name,
                client_description=client_description,
            )
        except DemistoException as e:
            status_code = e.res.status_code if isinstance(e.res, requests.Response) else None
            if status_code == HTTPStatus.INTERNAL_SERVER_ERROR:
                raise DemistoException(message=AUTH_EXISTING_TOKEN, exception=e)
            elif status_code == HTTPStatus.BAD_REQUEST:
                raise DemistoException(message=AUTH_EXCEEDED_MAXIMUM, exception=e)
            else:
                raise DemistoException(message="Auth process failed.", exception=e)

        # if "Auth Client" created successfully, Client ID and Client Secret would return
        # in the response and saved in the Integration Context
        client_id = admin_clients_response.get("client_id", "")
        client_secret = admin_clients_response.get("client_secret", "")

        if not client_id or not client_secret:
            raise DemistoException(message=AUTH_INVALID_CREDENTIALS)

        _outputs = {"client_id": client_id, "client_name": client_name}
        update_integration_auth_context(admin_clients_response)

        oauth_client_created_msg = (
            f"Auth Client Created Successfully.\nClient ID: {client_id}, Auth Client Name: {client_name}.\n\n"
        )

    # stage 3: create an Auth Token using the Auth Client
    try:
        demisto.debug("Stage 3: Requesting access token using client credentials.")
        token_response = request_access_token(
            server_url=server_url,
            verify=verify,
            proxy=proxy,
            username=username,
            password=password,
            client_id=client_id,
            client_secret=client_secret,
        )
    except DemistoException as e:
        status_code = e.res.status_code if isinstance(e.res, requests.Response) else None
        if status_code == HTTPStatus.UNAUTHORIZED:
            raise DemistoException(message=AUTH_INVALID_ACCESS_TOKEN)
        else:
            raise DemistoException(message=AUTH_BAD_CREDENTIALS)

    # save response with generated Auth Token, Refresh Token, Expiration Information and User Information
    # in Integration Context (among other information).
    token_response.update({"client_id": client_id, "client_secret": client_secret})
    update_integration_auth_context(token_response)

    output_message = (
        oauth_client_created_msg
        + "Authentication request was successful, Auth Token was created and saved in the Integration Context.\n"
    )
    if use_basic_auth:
        output_message += "Please uncheck the 'Use Basic Authentication' checkbox in the configuration screen.\n"
    output_message += "To ensure the authentication is valid, run the 'vd-auth-test' command."

    return CommandResults(
        outputs_prefix=VENDOR_NAME + ".AuthClient",
        outputs=_outputs if _outputs else {"client_id": client_id},
        raw_response=_outputs if _outputs else {"client_id": client_id},
        readable_output=output_message,
    )


def auth_test_command(client: Client, args: dict[str, Any]):
    # test connectivity with chosen authentication method
    message = test_connectivity(client)
    if message == "ok" and (headers := client._headers):
        if "Bearer" in headers.get("Authorization", ""):
            message = "Auth Token "
        else:
            message = "Basic "

    # test organization name if provided
    if organization_name := client.organization_params:
        client.test_organization_name_request(organization_name)

    return CommandResults(readable_output=message + "Authentication method connectivity verified.")


def appliance_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit", 25))
    offset = set_offset(page, page_size)

    check_limit(limit)

    response = client.appliance_list_request(offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".Appliance",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name="Appliances",
            t=response.get("appliance-list"),
            headers=["name", "uuid", "ipAddress", "appType", "branchId"],
            headerTransform=pascalToSpace,
        ),
    )
    return command_results


def organization_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    response = client.organization_list_request(offset, limit)

    # extract 'applianceuuid' list from 'appliances' dictionary
    appliances = []
    if response:
        for appliance in response[0].get("appliances", []):
            appliances.append(appliance.get("applianceuuid"))
        response[0]["appliances"] = appliances

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".Organization",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name="Organization List",
            headerTransform=pascalToSpace,
            t=response,
            headers=["name", "id", "parent", "appliances", "cpeDeploymentType", "uuid"],
        ),
    )

    return command_results


def appliances_list_by_organization_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization", None)
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size", 0))
    limit = arg_to_number(args.get("limit", 50))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliances_list_by_organization_request(organization, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".Appliance",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name="Organization List",
            headers=["name", "ipAddress", "type", "softwareVersion", "ownerOrg"],
            t=response.get("appliances", {}),
            headerTransform=pascalToSpace,
        ),
    )

    return command_results


def appliances_group_list_by_organization_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization", None)
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliances_group_list_by_organization_request(organization, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".DeviceGroup",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Appliance groups associated with {organization}",
            t=response.get("device-group", {}),
            headerTransform=pascalToSpace,
            headers=[
                "name",
                "organization",
                "createDate",
                "inventory-name",
                "poststaging-template",
            ],
        ),
    )
    return command_results


def appliances_list_by_device_group_command(client: Client, args: dict[str, Any]) -> CommandResults:
    device_group = args.get("device_group", "")
    template_name = args.get("template_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    response = client.appliances_list_by_device_group_request(device_group, template_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".DeviceGroup",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name="Appliances",
            t=response,
            headerTransform=pascalToSpace,
            headers=[
                "name",
                "organization",
                "createDate",
                "inventory-name",
                "poststaging-template",
                "template-association",
            ],
            json_transform_mapping={
                "template-association": JsonTransformer(
                    keys=["name"],
                ),
            },
            removeNull=True,
        ),
    )
    return command_results


def template_list_by_organization_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    type = args.get("type", "MAIN")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_list_by_organization_request(organization, type, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".Template",
        outputs=response.get("versanms.templates", {}).get("template", {}),
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Templates associated with {organization}",
            t=response.get("versanms.templates", {}).get("template", {}),
            headerTransform=pascalToSpace,
            headers=[
                "name",
                "organization",
                "lockDetails",
                "templateType",
                "isPrimary",
                "isStaging",
            ],
        ),
    )
    return command_results


def template_list_by_datastore_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_list_by_datastore_request(organization, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".DataStoreTemplate",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Templates associated with {organization} Data-Store",
            t=response.get("org", {}),
            headerTransform=pascalToSpace,
            removeNull=True,
            headers=[
                "name",
                "appliance-owner",
                "available-routing-instances",
                "owned-routing-instances",
                "available-networks",
            ],
        ),
    )
    return command_results


def application_service_template_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    keyword = args.get("keyword")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.application_service_template_list_request(organization, keyword, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplicationServiceTemplate",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Application Service Templates associated with {organization}",
            t=response.get("content", {}),
            headerTransform=pascalToSpace,
            headers=[
                "createDate",
                "modifyDate",
                "lastUpdatedBy",
                "name",
                "organization",
                "status",
            ],
        ),
    )
    return command_results


@polling_function(
    name="vd-template-change-commit",
    interval=DEFAULT_INTERVAL,
    timeout=DEFAULT_TIMEOUT,
    requires_polling_arg=False,
)
def template_change_commit_command(args: dict[str, Any], client: Client) -> PollResult:
    template_name = args.get("template_name", "")
    appliances = argToList(args.get("appliances"))
    mode = args.get("mode", "")
    reboot = args.get("reboot", "false")
    task_id = args.get("task_id")
    if not task_id:
        response = client.template_change_commit_request(template_name, appliances, mode, reboot)
        response = json.loads((response.content).decode("utf-8"))
        template_response = response.get("versanms.templateResponse", {})
        task_id = template_response.get("taskId")
        args["task_id"] = task_id

    response = client.template_change_commit_polling_request(task_id)
    percentage_completion = response.get("versa-tasks.task", {}).get("versa-tasks.percentage-completion")

    if percentage_completion == 100:
        return PollResult(
            response=CommandResults(
                outputs_prefix=VENDOR_NAME + ".Commit",
                raw_response=response.get("versa-tasks.task", {}),
                readable_output=tableToMarkdown(
                    name="Template change committed",
                    t=response.get("versa-tasks.task", {}),
                    headerTransform=pascalToSpace,
                    headers=[
                        "versa-tasks.id",
                        "versa-tasks.task-description",
                        "versa-tasks.user",
                        "versa-tasks.task-status",
                        "versa-tasks.progressmessages",
                    ],
                    is_auto_json_transform=True,
                ),
            ),
            continue_to_poll=False,
        )
    else:
        results = CommandResults(readable_output="Polling job failed.")
        return PollResult(
            continue_to_poll=True,
            args_for_next_run={"task_id": task_id, **args},
            response=results,
        )


def template_custom_url_category_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    url_category_name = args.get("url_category_name")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_custom_url_category_list_request(organization, template_name, url_category_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateCustomUrlCategory",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Application Service Templates associated with {organization}",
            t=response.get("url-category", {}),
            headerTransform=pascalToSpace,
            headers=["category-name", "category-description", "confidence", "urls"],
            is_auto_json_transform=True,
        ),
    )
    return command_results


def template_custom_url_category_create_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization", "")
    template_name = args.get("template_name", "")
    url_category_name = args.get("url_category_name", "")
    description = args.get("description", "")
    confidence = args.get("confidence", "")
    urls = argToList(args.get("urls"))
    url_reputation = argToList(args.get("url_reputation"))
    patterns = argToList(args.get("patterns"))
    pattern_reputation = argToList(args.get("pattern_reputation"))
    message = "Object created successfully."

    organization = set_organization(organization_args, client.organization_params)
    try:
        client.template_custom_url_category_create_request(
            organization,
            template_name,
            url_category_name,
            description,
            confidence,
            urls,
            url_reputation,
            patterns,
            pattern_reputation,
        )
    except DemistoException as e:
        if e.res.status_code == 409:
            message = ALREADY_EXISTS_MSG
        else:
            raise e

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateCustomUrlCategory",
        readable_output=message,
    )
    return command_results


def template_custom_url_category_edit_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    url_category_name = args.get("url_category_name", "")
    description = args.get("description", "")
    confidence = args.get("confidence", "")
    urls = argToList(args.get("urls"))
    url_reputation = argToList(args.get("url_reputation"))
    patterns = argToList(args.get("patterns"))
    pattern_reputation = argToList(args.get("pattern_reputation"))

    organization = set_organization(organization_args, client.organization_params)

    response, request_body = client.template_custom_url_category_edit_request(
        organization,
        template_name,
        url_category_name,
        description,
        confidence,
        urls,
        url_reputation,
        patterns,
        pattern_reputation,
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateCustomUrlCategory",
        readable_output=f"Command run successfully.\nRequest Body:\n\n{request_body}",
    )
    return command_results


def template_custom_url_category_delete_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    url_category_name = args.get("url_category_name", "")

    organization = set_organization(organization_args, client.organization_params)

    client.template_custom_url_category_delete_request(
        organization=organization,
        template_name=template_name,
        url_category_name=url_category_name,
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateCustomUrlCategory",
        readable_output="Command run successfully.",
    )
    return command_results


def appliance_custom_url_category_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    url_category_name = args.get("url_category_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliance_custom_url_category_list_request(organization, appliance_name, url_category_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceCustomUrlCategory",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Application Service Appliances associated with {organization}",
            t=response.get("url-category", {}),
            headerTransform=pascalToSpace,
            headers=["category-name", "category-description", "confidence", "urls"],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def appliance_custom_url_category_create_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    url_category_name = args.get("url_category_name", "")
    description = args.get("description", "")
    confidence = args.get("confidence", "")
    urls = argToList(args.get("urls"))
    url_reputation = argToList(args.get("url_reputation"))
    patterns = argToList(args.get("patterns"))
    pattern_reputation = argToList(args.get("pattern_reputation"))

    message = "Command run successfully."

    organization = set_organization(organization_args, client.organization_params)

    try:
        response, request_body = client.appliance_custom_url_category_create_request(
            organization,
            appliance_name,
            url_category_name,
            description,
            confidence,
            urls,
            url_reputation,
            patterns,
            pattern_reputation,
        )
    except DemistoException as e:
        if e.res.status_code == 409:
            message = ALREADY_EXISTS_MSG
            request_body = None, "Not available."

        else:
            raise e

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceCustomUrlCategory",
        readable_output=message + f"\nRequest Body:\n\n{request_body}",
    )
    return command_results


def appliance_custom_url_category_edit_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    url_category_name = args.get("url_category_name", "")
    description = args.get("description", "")
    confidence = args.get("confidence", "")
    urls = argToList(args.get("urls"))
    url_reputation = argToList(args.get("url_reputation"))
    patterns = argToList(args.get("patterns"))
    pattern_reputation = argToList(args.get("pattern_reputation"))

    organization = set_organization(organization_args, client.organization_params)

    response, request_body = client.appliance_custom_url_category_edit_request(
        organization,
        appliance_name,
        url_category_name,
        description,
        confidence,
        urls,
        url_reputation,
        patterns,
        pattern_reputation,
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceCustomUrlCategory",
        readable_output="Command run successfully.\nRequest Body:\n\n" + str(request_body),
    )
    return command_results


def appliance_custom_url_category_delete_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    url_category_name = args.get("url_category_name", "")

    organization = set_organization(organization_args, client.organization_params)

    client.appliance_custom_url_category_delete_request(
        organization=organization,
        appliance_name=appliance_name,
        url_category_name=url_category_name,
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceCustomUrlCategory",
        readable_output="Command run successfully.",
    )
    return command_results


def template_access_policy_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_access_policy_list_request(organization, template_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAccessPolicy",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Access policies associated with {organization}",
            t=response.get("access-policy-group", {}),
            headerTransform=pascalToSpace,
            headers=["name", "rules"],
            is_auto_json_transform=True,
        ),
    )
    return command_results


def template_access_policy_rule_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    access_policy_name = args.get("access_policy_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_access_policy_rule_list_request(organization, template_name, access_policy_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAccessPolicyRule",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Access policies associated with {organization}",
            t=response.get("access-policy", {}),
            headerTransform=pascalToSpace,
            headers=["name", "description", "tag", "rule-disable"],
            is_auto_json_transform=True,
        ),
    )
    return command_results


def template_access_policy_rule_create_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization", "")
    template_name = args.get("template_name", "")
    access_policy_name = args.get("access_policy_name", "")

    access_policy_rule_args = get_access_policy_rule_args_with_possible_custom_rule_json(args)

    organization = set_organization(organization_args, client.organization_params)

    message = "Command run successfully."

    try:
        response, request_body = client.template_access_policy_rule_create_request(
            organization, template_name, access_policy_name, **access_policy_rule_args
        )
    except DemistoException as e:
        if e.res.status_code == 409:
            message = ALREADY_EXISTS_MSG
            request_body = None, "Not available."

        else:
            raise e

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAccessPolicyRule",
        readable_output=message + f"\nRequest Body:\n\n{request_body}",
    )
    return command_results


def template_access_policy_rule_edit_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization", "")
    template_name = args.get("template_name", "")
    access_policy_name = args.get("access_policy_name", "")

    access_policy_rule_args = get_access_policy_rule_args_with_possible_custom_rule_json(args)

    organization = set_organization(organization_args, client.organization_params)

    response, request_body = client.template_access_policy_rule_edit_request(
        organization, template_name, access_policy_name, **access_policy_rule_args
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAccessPolicyRule",
        readable_output="Command run successfully.\nRequest Body:\n\n" + str(request_body),
    )
    return command_results


def template_access_policy_rule_delete_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    access_policy_name = args.get("access_policy_name", "")
    rule_name = args.get("rule_name", "")

    organization = set_organization(organization_args, client.organization_params)

    client.template_access_policy_rule_delete_request(organization, template_name, access_policy_name, rule_name)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAccessPolicyRule",
        readable_output="Command run successfully.",
    )
    return command_results


def appliance_access_policy_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliance_access_policy_list_request(organization, appliance_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAccessPolicy",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Access policies associated with {organization}",
            t=response.get("access-policy-group", {}),
            headerTransform=pascalToSpace,
            headers=["name", "rules"],
            is_auto_json_transform=True,
        ),
    )
    return command_results


def appliance_access_policy_rule_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    access_policy_name = args.get("access_policy_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliance_access_policy_rule_list_request(organization, appliance_name, access_policy_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAccessPolicyRule",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Access policies associated with {organization}",
            t=response.get("access-policy", {}),
            headerTransform=pascalToSpace,
            headers=["name", "description", "tag", "rule-disable"],
            is_auto_json_transform=True,
        ),
    )
    return command_results


def appliance_access_policy_rule_create_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization", "")
    appliance_name = args.get("appliance_name", "")
    access_policy_name = args.get("access_policy_name", "")

    access_policy_rule_args = get_access_policy_rule_args_with_possible_custom_rule_json(args)

    organization = set_organization(organization_args, client.organization_params)

    message = "Command run successfully."

    try:
        response, request_body = client.appliance_access_policy_rule_create_request(
            organization, appliance_name, access_policy_name, **access_policy_rule_args
        )
    except DemistoException as e:
        if e.res.status_code == 409:
            message = ALREADY_EXISTS_MSG
            request_body = None, "Not available."

        else:
            raise e

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAccessPolicyRule",
        readable_output=message + f"\nRequest Body:\n\n{request_body}",
    )
    return command_results


def appliance_access_policy_rule_edit_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization", "")
    appliance_name = args.get("appliance_name", "")
    access_policy_name = args.get("access_policy_name", "")

    access_policy_rule_args = get_access_policy_rule_args_with_possible_custom_rule_json(args)

    organization = set_organization(organization_args, client.organization_params)

    response, request_body = client.appliance_access_policy_rule_edit_request(
        organization, appliance_name, access_policy_name, **access_policy_rule_args
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAccessPolicyRule",
        readable_output="Command run successfully.\nRequest Body:\n\n" + str(request_body),
    )
    return command_results


def appliance_access_policy_rule_delete_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    access_policy_name = args.get("access_policy_name", "")
    rule_name = args.get("rule_name", "")

    organization = set_organization(organization_args, client.organization_params)

    client.appliance_access_policy_rule_delete_request(organization, appliance_name, access_policy_name, rule_name)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAccessPolicyRule",
        readable_output="Command run successfully.",
    )
    return command_results


def template_sdwan_policy_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_sdwan_policy_list_request(organization, template_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateSdwanPolicy",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"SD-WAN policies associated with {organization}",
            t=response.get("sdwan-policy-group", {}),
            headerTransform=pascalToSpace,
            headers=["name", "rules"],
            is_auto_json_transform=True,
        ),
    )
    return command_results


def template_sdwan_policy_rule_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    sdwan_policy_name = args.get("sdwan_policy_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_sdwan_policy_rule_request(organization, template_name, sdwan_policy_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateSdwanPolicyRule",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"SD-WAN policy rules associated with {organization}",
            t=response.get("rule"),
            headerTransform=string_to_table_header,
            headers=["name", "match", "set"],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def template_sdwan_policy_rule_create_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    sdwan_policy_name = args.get("sdwan_policy_name", "")

    organization = set_organization(organization_args, client.organization_params)

    sdwan_policy_rule_args = get_sdwan_policy_rule_args_with_possible_custom_rule_json(args)

    message = "Command run successfully."

    try:
        response, request_body = client.template_sdwan_policy_rule_create_request(
            organization, template_name, sdwan_policy_name, **sdwan_policy_rule_args
        )
    except DemistoException as e:
        if e.res.status_code == 409:
            message = ALREADY_EXISTS_MSG
            request_body = None, "Not available."

        else:
            raise e

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateSdwanPolicyRule",
        readable_output=message + f"\nRequest Body:\n\n{request_body}",
    )
    return command_results


def template_sdwan_policy_rule_edit_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    sdwan_policy_name = args.get("sdwan_policy_name", "")

    organization = set_organization(organization_args, client.organization_params)

    sdwan_policy_rule_args = get_sdwan_policy_rule_args_with_possible_custom_rule_json(args)

    response, request_body = client.template_sdwan_policy_rule_edit_request(
        organization, template_name, sdwan_policy_name, **sdwan_policy_rule_args
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateSdwanPolicyRule",
        readable_output="Command run successfully.\nRequest Body:\n\n" + str(request_body),
    )
    return command_results


def template_sdwan_policy_rule_delete_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    sdwan_policy_name = args.get("sdwan_policy_name", "")
    rule_name = args.get("rule_name", "")

    organization = set_organization(organization_args, client.organization_params)

    client.template_sdwan_policy_rule_delete_request(
        organization,
        template_name,
        sdwan_policy_name,
        rule_name,
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateSdwanPolicyRule",
        readable_output="Command run successfully.",
    )
    return command_results


def appliance_sdwan_policy_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliance_sdwan_policy_list_request(organization, appliance_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceSdwanPolicy",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"SD-WAN policies associated with {organization}",
            t=response.get("sdwan-policy-group"),
            headerTransform=pascalToSpace,
            headers=["name", "rules"],
            is_auto_json_transform=True,
        ),
    )
    return command_results


def appliance_sdwan_policy_rule_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    sdwan_policy_name = args.get("sdwan_policy_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliance_sdwan_policy_rule_list_request(organization, appliance_name, sdwan_policy_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceSdwanPolicyRule",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"SD-WAN policy rules associated with {organization}",
            t=response.get("rule", {}),
            headerTransform=pascalToSpace,
            headers=["name", "description", "rule-disable", "action"],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def appliance_sdwan_policy_rule_create_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    sdwan_policy_name = args.get("sdwan_policy_name", "")
    organization = set_organization(organization_args, client.organization_params)

    sdwan_policy_rule_args = get_sdwan_policy_rule_args_with_possible_custom_rule_json(args)

    message = "Command run successfully."

    try:
        response, request_body = client.appliance_sdwan_policy_rule_create_request(
            organization, appliance_name, sdwan_policy_name, **sdwan_policy_rule_args
        )
    except DemistoException as e:
        if e.res.status_code == 409:
            message = ALREADY_EXISTS_MSG
            request_body = None, "Not available."

        else:
            raise e

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceSdwanPolicyRule",
        readable_output=message + f"\nRequest Body:\n\n{request_body}",
    )
    return command_results


def appliance_sdwan_policy_rule_edit_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    sdwan_policy_name = args.get("sdwan_policy_name", "")
    organization = set_organization(organization_args, client.organization_params)

    sdwan_policy_rule_args = get_sdwan_policy_rule_args_with_possible_custom_rule_json(args)

    response, request_body = client.appliance_sdwan_policy_rule_edit_request(
        organization, appliance_name, sdwan_policy_name, **sdwan_policy_rule_args
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceSdwanPolicyRule",
        readable_output=f"Command run successfully.\nRequest Body:\n\n{request_body}",
    )
    return command_results


def appliance_sdwan_policy_rule_delete_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    sdwan_policy_name = args.get("sdwan_policy_name", "")
    rule_name = args.get("rule_name", "")
    organization = set_organization(organization_args, client.organization_params)

    client.appliance_sdwan_policy_rule_delete_request(organization, appliance_name, sdwan_policy_name, rule_name)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceSdwanPolicyRule",
        readable_output="Command run successfully.",
    )
    return command_results


def template_address_object_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_address_object_list_request(organization, template_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAddressObject",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Address objects associated with {organization}",
            t=response.get("address", {}),
            headerTransform=pascalToSpace,
            headers=[
                "name",
                "description",
                "tag",
                "ipv4-prefix",
                "fqdn",
                "ipv4-range",
                "ipv4-wildcard-mask",
                "ipv6-prefix",
                "dynamic-address",
            ],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def template_address_object_create_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    object_name = args.get("object_name", "")
    description = args.get("description", "")
    tags = argToList(args.get("tags"))
    address_object_type = args.get("address_object_type", "")
    object_value = args.get("object_value", "")

    organization = set_organization(organization_args, client.organization_params)

    message = "Command run successfully."

    try:
        response, request_body = client.template_address_object_create_request(
            organization,
            template_name,
            object_name,
            description,
            tags,
            address_object_type,
            object_value,
        )
    except DemistoException as e:
        if e.res.status_code == 409:
            message = ALREADY_EXISTS_MSG
            request_body = None, "Not available."

        else:
            raise e

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAddressObject",
        readable_output=message + f"\nRequest Body:\n\n{request_body}",
    )
    return command_results


def template_address_object_edit_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    object_name = args.get("object_name", "")
    description = args.get("description", "")
    tags = argToList(args.get("tags"))
    address_object_type = args.get("address_object_type", "")
    object_value = args.get("object_value", "")

    organization = set_organization(organization_args, client.organization_params)

    response, request_body = client.template_address_object_edit_request(
        organization,
        template_name,
        object_name,
        description,
        tags,
        address_object_type,
        object_value,
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAddressObject",
        readable_output="Command run successfully.\nRequest Body:\n\n" + str(request_body),
    )
    return command_results


def template_address_object_delete_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    object_name = args.get("object_name", "")

    organization = set_organization(organization_args, client.organization_params)

    client.template_address_object_delete_request(
        organization,
        template_name,
        object_name,
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateAddressObject",
        readable_output="Command run successfully.",
    )
    return command_results


def appliance_address_object_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliance_address_object_list_request(organization, appliance_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAddressObject",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"Address objects associated with {organization}",
            t=response.get("address", {}),
            headerTransform=pascalToSpace,
            headers=[
                "name",
                "description",
                "tag",
                "ipv4-prefix",
                "fqdn",
                "ipv4-range",
                "ipv4-wildcard-mask",
                "ipv6-prefix",
                "dynamic-address",
            ],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def appliance_address_object_create_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    object_name = args.get("object_name", "")
    description = args.get("description", "")
    tags = argToList(args.get("tags"))
    address_object_type = args.get("address_object_type", "")
    object_value = args.get("object_value", "")

    organization = set_organization(organization_args, client.organization_params)

    message = "Command run successfully."

    try:
        response, request_body = client.appliance_address_object_create_request(
            organization,
            appliance_name,
            object_name,
            description,
            tags,
            address_object_type,
            object_value,
        )
    except DemistoException as e:
        if e.res.status_code == 409:
            message = ALREADY_EXISTS_MSG
            request_body = None, "Not available."

        else:
            raise e

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAddressObject",
        readable_output=message + f"\nRequest Body:\n\n{request_body}",
    )
    return command_results


def appliance_address_object_edit_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    object_name = args.get("object_name", "")
    description = args.get("description", "")
    tags = argToList(args.get("tags"))
    address_object_type = args.get("address_object_type", "")
    object_value = args.get("object_value", "")

    organization = set_organization(organization_args, client.organization_params)

    response, request_body = client.appliance_address_object_edit_request(
        organization,
        appliance_name,
        object_name,
        description,
        tags,
        address_object_type,
        object_value,
    )

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAddressObject",
        readable_output="Command run successfully.\nRequest Body:\n\n" + str(request_body),
    )
    return command_results


def appliance_address_object_delete_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    object_name = args.get("object_name", "")

    organization = set_organization(organization_args, client.organization_params)

    client.appliance_address_object_delete_request(organization, appliance_name, object_name)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceAddressObject",
        readable_output="Command run successfully.",
    )
    return command_results


def template_user_defined_application_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_user_defined_application_list_request(organization, template_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateUserDefinedApplication",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"User defined application objects associated with {organization}",
            t=response.get("user-defined-application", {}),
            headerTransform=pascalToSpace,
            headers=["app-name", "description", "precedence", "tag", "risk", "family"],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def appliance_user_defined_application_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliance_user_defined_application_list_request(organization, appliance_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceUserDefinedApplication",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"User defined application objects associated with {organization}",
            t=response.get("user-defined-application", {}),
            headerTransform=pascalToSpace,
            headers=["app-name", "description", "precedence", "tag", "risk", "family"],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def template_user_modified_application_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    template_name = args.get("template_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.template_user_modified_application_list_request(organization, template_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".TemplateUserModifiedApplication",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"User modified predefined application objects associated with {organization}",
            t=response.get("app-specific-option-list", {}),
            headerTransform=pascalToSpace,
            headers=[
                "app-name",
                "app-risk",
                "app-productivity",
                "app-timeout",
                "app-final-with-endpoint",
            ],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def appliance_user_modified_application_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    organization_args = args.get("organization")
    appliance_name = args.get("appliance_name", "")
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    organization = set_organization(organization_args, client.organization_params)

    response = client.appliance_user_modified_application_list_request(organization, appliance_name, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".ApplianceUserModifiedApplication",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name=f"User modified predefined application objects associated with {organization}",
            t=response.get("app-specific-option-list", {}),
            headerTransform=pascalToSpace,
            headers=[
                "app-name",
                "app-risk",
                "app-productivity",
                "app-timeout",
                "app-final-with-endpoint",
            ],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def predefined_application_list_command(client: Client, args: dict[str, Any]) -> CommandResults:
    family = args.get("family")
    risks = arg_to_number(args.get("risks"))
    tags = argToList(args.get("tags"))
    page = arg_to_number(args.get("page"))
    page_size = arg_to_number(args.get("page_size"))
    limit = arg_to_number(args.get("limit"))
    offset = set_offset(page, page_size)

    check_limit(limit)

    response = client.predefined_application_list_request(family, risks, tags, offset, limit)

    command_results = CommandResults(
        outputs_prefix=VENDOR_NAME + ".PredefinedApplication",
        outputs=response,
        raw_response=response,
        readable_output=tableToMarkdown(
            name="User predefined application objects.",
            t=response,
            headerTransform=pascalToSpace,
            headers=[
                "name",
                "family",
                "subfamily",
                "description",
                "risk",
                "productivity",
                "tag",
            ],
            is_auto_json_transform=True,
            removeNull=True,
        ),
    )
    return command_results


def test_connectivity(client: Client) -> str:
    """Tests API connectivity and authentication'

    Returning 'ok' indicates that the integration works like it is supposed to.
    Connection to the service is successful.
    Raises exceptions if something goes wrong.

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

    :return: 'ok' if test passed, anything else will fail the test.
    :rtype: ``str``
    """
    try:
        client._http_request(
            method="GET",
            url_suffix="vnms/alarm/notification",
            params={"limit": 3, "offset": 0},
        )
        message = "ok"
    except DemistoException as e:
        if "Forbidden" in str(e) or "Authorization" in str(e):
            message = "Authorization Error: make sure authentication parameters/arguments are correctly set."
        else:
            raise e
    return message


def test_module(
    client: Client | None,
    use_basic_auth: bool = False,
    client_id: str = None,
    client_secret: str = None,
    access_token: str = None,
    username: str = None,
    password: str = None,
):
    """
    Performs basic GET request to check if the API is reachable using different authentication methods.
    Returns ok if successful.
    """

    case_client_id_and_client_secret = bool(client_id and client_secret)
    case_not_client_id_and_not_client_secret = bool(not client_id and not client_secret)
    case_missing_client_id_or_client_secret = bool(not client_id or not client_secret)
    case_missing_username_or_password = bool(not username or not password)
    case_client_id_and_client_secret_and_access_token = bool(client_id and client_secret and access_token)
    case_not_client_id_and_not_client_secret_and_not_access_token = bool(not client_id and not client_secret and not access_token)

    # Case: using Basic authentication with Username and Password parameter
    message = ""
    if use_basic_auth and client:
        if case_missing_username_or_password:
            return_error("Basic Authentication method chosen but Username or Password parameters are missing.")
        try:
            message = test_connectivity(client)
        except DemistoException as e:
            if e.res.status_code == 401:
                return_error("Basic Authentication method chosen but Username or Password parameters are invalid.")

    elif not use_basic_auth and case_client_id_and_client_secret_and_access_token:
        return_error(
            "More parameters passed than expected."
            + " Please pass Client ID and Client Secret OR Auth Token parameters (not both)."
        )

    elif not use_basic_auth and case_not_client_id_and_not_client_secret_and_not_access_token:
        return_error(
            "Auth Token authentication method chosen but no parameters passed."
            + " Please pass Client ID and Client Secret OR Auth Token parameters (not both)."
        )

    # Case: using Auth Token method with Auth Token parameter only (without Client ID and Client Secret parameters)
    elif not use_basic_auth and client and all([access_token, case_not_client_id_and_not_client_secret]):
        message = test_connectivity(client)

    # Case: using Auth Token method with Client ID and Client Secret parameters
    elif (not use_basic_auth and case_not_client_id_and_not_client_secret) or case_client_id_and_client_secret:
        return_error(
            "When using Auth Token authentication method with Client ID and Client Secret, please follow these steps:\n"
            "Input Client ID and Client Secret Parameters if available OR run '!vd-auth-start' "
            "command with Token Name argument to create a new Auth Client.\n"
            "Make sure 'Use Basic Authentication' checkbox is unchecked.\n"
            "Then run '!vd-auth-test' command to check valid connectivity using Auth Token authentication."
        )

    elif not use_basic_auth and case_missing_client_id_or_client_secret:
        return_error(
            "Auth Authentication method chosen but Client ID or Client Secret parameters are missing."
            + " Please enter Client ID and Client Secret parameters OR use '!vd-auth-start' command."
        )

    else:
        return_error(
            "Not all fields for the selected authenticating are set or some of the"
            + " parameters are invalid, therefore it cannot be executed."
        )

    # test organization name if provided
    if client and (organization_name := client.organization_params):
        client.test_organization_name_request(organization_name)

    return message


#  """ MAIN FUNCTION """


def main() -> None:
    params: dict[str, Any] = demisto.params()
    args: dict[str, Any] = demisto.args()
    command: str = demisto.command()
    context: dict[str, Any] = get_integration_context().get("context", {})

    # HTTP Connection
    verify_certificate: bool = not params.get("insecure", False)
    proxy = params.get("proxy", False)

    # Base URL
    use_basic_auth = params.get("use_basic_auth", False)
    port = BASIC_AUTH_PORT if use_basic_auth else ADVANCED_AUTH_PORT
    url = params.get("url", "").rstrip("/") + f":{port}"

    # Basic Auth
    basic_auth_credentials = params.get("credentials", {})
    username = basic_auth_credentials.get("identifier", "")
    password = basic_auth_credentials.get("password", "")

    # Client Auth
    client_auth_credentials = params.get("credentials_client", {})
    client_id = client_auth_credentials.get("identifier") or params.get("client_id") or context.get("client_id")
    client_secret = client_auth_credentials.get("password") or params.get("client_secret") or context.get("client_secret")
    access_token = params.get("access_token") or context.get("access_token")

    demisto.debug(f"Command being called is {command}")

    try:
        if command == "vd-auth-start":
            return_results(
                auth_start_command(
                    server_url=url,
                    verify=verify_certificate,
                    proxy=proxy,
                    username=username,
                    password=password,
                    client_id_param=client_id,
                    client_secret_param=client_secret,
                    use_basic_auth=use_basic_auth,
                    args=args,
                )
            )
            return

        # test_module functionality is disabled for Auth Token authentication
        case_auth_token_auth = bool(
            params.get("access_token", None) and not params.get("client_id", None) and not params.get("client_secret", None)
        )
        if command == "test-module" and not use_basic_auth and not case_auth_token_auth:
            return_results(
                test_module(
                    client=None,
                    use_basic_auth=use_basic_auth,
                    client_id=params.get("client_id"),
                    client_secret=params.get("client_secret"),
                    access_token=params.get("access_token"),
                    username=username,
                    password=password,
                )
            )

        auth, headers = create_client_header(use_basic_auth, username, password, client_id, client_secret, access_token)

        client = Client(
            server_url=url,
            verify=verify_certificate,
            headers=headers,
            proxy=proxy,
            auth=auth,
            organization_params=params.get("organization"),
        )

        # check auth token validity and if a refresh token is needed to obtain new auth token
        if (
            not use_basic_auth
            and client_id
            and client_secret
            and (new_token := check_and_update_token(client, client_id, client_secret, context))
        ):
            client._headers["Authorization"] = f"Bearer {new_token}"

        commands = {
            "vd-auth-test": auth_test_command,
            "vd-appliance-list": appliance_list_command,
            "vd-organization-list": organization_list_command,
            "vd-organization-appliance-list": appliances_list_by_organization_command,
            "vd-appliance-group-list": appliances_group_list_by_organization_command,
            "vd-appliance-group-template-appliance-list": appliances_list_by_device_group_command,
            "vd-template-list": template_list_by_organization_command,
            "vd-datastore-template-list": template_list_by_datastore_command,
            "vd-application-service-template-list": application_service_template_list_command,
            "vd-template-custom-url-category-list": template_custom_url_category_list_command,
            "vd-template-custom-url-category-create": template_custom_url_category_create_command,
            "vd-template-custom-url-category-edit": template_custom_url_category_edit_command,
            "vd-template-custom-url-category-delete": template_custom_url_category_delete_command,
            "vd-appliance-custom-url-category-list": appliance_custom_url_category_list_command,
            "vd-appliance-custom-url-category-create": appliance_custom_url_category_create_command,
            "vd-appliance-custom-url-category-edit": appliance_custom_url_category_edit_command,
            "vd-appliance-custom-url-category-delete": appliance_custom_url_category_delete_command,
            "vd-template-access-policy-list": template_access_policy_list_command,
            "vd-template-access-policy-rule-list": template_access_policy_rule_list_command,
            "vd-template-access-policy-rule-create": template_access_policy_rule_create_command,
            "vd-template-access-policy-rule-edit": template_access_policy_rule_edit_command,
            "vd-template-access-policy-rule-delete": template_access_policy_rule_delete_command,
            "vd-appliance-access-policy-list": appliance_access_policy_list_command,
            "vd-appliance-access-policy-rule-list": appliance_access_policy_rule_list_command,
            "vd-appliance-access-policy-rule-create": appliance_access_policy_rule_create_command,
            "vd-appliance-access-policy-rule-edit": appliance_access_policy_rule_edit_command,
            "vd-appliance-access-policy-rule-delete": appliance_access_policy_rule_delete_command,
            "vd-template-sdwan-policy-list": template_sdwan_policy_list_command,
            "vd-template-sdwan-policy-rule-list": template_sdwan_policy_rule_list_command,
            "vd-template-sdwan-policy-rule-create": template_sdwan_policy_rule_create_command,
            "vd-template-sdwan-policy-rule-edit": template_sdwan_policy_rule_edit_command,
            "vd-template-sdwan-policy-rule-delete": template_sdwan_policy_rule_delete_command,
            "vd-appliance-sdwan-policy-list": appliance_sdwan_policy_list_command,
            "vd-appliance-sdwan-policy-rule-list": appliance_sdwan_policy_rule_list_command,
            "vd-appliance-sdwan-policy-rule-create": appliance_sdwan_policy_rule_create_command,
            "vd-appliance-sdwan-policy-rule-edit": appliance_sdwan_policy_rule_edit_command,
            "vd-appliance-sdwan-policy-rule-delete": appliance_sdwan_policy_rule_delete_command,
            "vd-template-address-object-list": template_address_object_list_command,
            "vd-template-address-object-create": template_address_object_create_command,
            "vd-template-address-object-edit": template_address_object_edit_command,
            "vd-template-address-object-delete": template_address_object_delete_command,
            "vd-appliance-address-object-list": appliance_address_object_list_command,
            "vd-appliance-address-object-create": appliance_address_object_create_command,
            "vd-appliance-address-object-edit": appliance_address_object_edit_command,
            "vd-appliance-address-object-delete": appliance_address_object_delete_command,
            "vd-template-user-defined-application-list": template_user_defined_application_list_command,
            "vd-appliance-user-defined-application-list": appliance_user_defined_application_list_command,
            "vd-template-user-modified-application-list": template_user_modified_application_list_command,
            "vd-appliance-user-modified-application-list": appliance_user_modified_application_list_command,
            "vd-predefined-application-list": predefined_application_list_command,
        }
        if command == "test-module":
            return_results(test_module(client, use_basic_auth, client_id, client_secret, access_token, username, password))
        elif command == "vd-template-change-commit":
            return_results(template_change_commit_command(args, client))
        elif command in commands:
            return_results(commands[command](client, args))
        else:
            raise NotImplementedError(f"{command} command is not implemented.")
    except DemistoException as e:
        if e.res and e.res.status_code == 204:
            return_results(f"Empty response has returned from {command} command.\nMessage:\n{e!s}")
        else:
            raise e
    except Exception as e:
        return_error(f"Failed to execute {command} command.\nError:\n{e!s}")


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