Client for interacting with the Palo Alto Networks XML API. Encapsulates methods for performing HTTP GET and POST requests with XML data and conversion utilities for API operations.

Constructors

  • Constructs a new instance of ApiClient.

    Parameters

    • hostname: string

      The hostname or IP address of the target PAN-OS device.

    • apiKey: string

      The API key for authenticating requests to the PAN-OS device.

    Returns ApiClient

Methods

  • Edits a configuration entity on the PAN-OS device.

    Parameters

    • xpath: string

      The XPath of the configuration to be edited.

    • element: string

      The configuration's XML representation.

    • Optional entryName: string

      Optional. The name of the configuration entry to be edited.

    Returns Promise<string>

    A promise that resolves to a string containing the raw XML response from the configuration edit API call.

  • Generates an API key for the PAN-OS device.

    Parameters

    • endpoint: string

      The API endpoint for key generation.

    • params: Record<string, unknown>

      The parameters for the API key generation request.

    Returns Promise<string>

    A promise that resolves to the generated API key.

    Throws

    An error if the API key generation fails.

  • Performs an HTTP GET request to the specified endpoint on the PAN-OS device.

    Parameters

    • endpoint: string

      The API endpoint to send the request to.

    • Optional params: Record<string, unknown>

      Optional parameters to include in the request.

    Returns Promise<string>

    A promise that resolves to a string containing the raw XML response.

  • Retrieves a specified configuration from the PAN-OS device, with options to parse the response.

    Parameters

    • xpath: string

      The XPath of the configuration to be retrieved.

    • parse: boolean = true

      Optional. Whether to parse the XML response into a JavaScript object. Defaults to true.

    Returns Promise<string | ApiResponse<ApiResult>>

    The configuration data, either as a raw XML string or as an ApiResponse<ApiResult>.

  • Retrieves and optionally parses data from the PAN-OS API.

    Type Parameters

    Parameters

    • endpoint: string

      The API endpoint to send the request to.

    • Optional params: Record<string, unknown>

      Optional parameters to include in the request.

    Returns Promise<ApiResponse<T>>

    A promise that resolves to the response data, either as a raw XML string or as an ApiResponse<T>.

    Typeparam

    T The expected type of the API result.

  • Retrieves raw data from the PAN-OS API.

    Parameters

    • endpoint: string

      The API endpoint to send the request to.

    • Optional params: Record<string, unknown>

      Optional parameters to include in the request.

    Returns Promise<string>

    A promise that resolves to a string containing the raw XML response.

  • Executes an operational command on the PAN-OS device and retrieves the result.

    Type Parameters

    Parameters

    • command: string

      The command string or XML to execute.

    • parse: boolean = true

      Optional. Whether to parse the command response into a JavaScript object. Defaults to true.

    Returns Promise<string | ApiResponse<T>>

    The response from the operational command, either as raw XML or an object.

    Typeparam

    T The expected type of the API result structure.

  • Parses an XML string into a JavaScript object structure.

    Type Parameters

    Parameters

    • xml: string

      The XML string to parse.

    • explicitArray: boolean = false

      Optional. Forces arrays for child elements if set to true. Defaults to false.

    • ignoreAttrs: boolean = true

      Optional. Ignores XML attributes and only creates text nodes if set to true. Defaults to true.

    Returns Promise<ApiResponse<T>>

    A promise resolved with the parsed object structure.

    Typeparam

    T The expected type of the API result structure.

  • Performs an HTTP POST request to the specified endpoint on the PAN-OS device.

    Parameters

    • endpoint: string

      The API endpoint to send the request to.

    • data: string

      The XML string to be sent as the request body.

    Returns Promise<string>

    A promise that resolves to a string containing the raw XML response.

  • Sends a configuration change to the PAN-OS device via an API POST request.

    Parameters

    • xpath: string

      The XPath of the configuration to be updated.

    • element: string

      The configuration's XML representation.

    • action: "delete" | "set" | "edit"

      The configuration action to perform (set, edit, or delete).

    Returns Promise<string>

    A promise that resolves to a string containing the raw XML response.

  • Creates a configuration entity on the PAN-OS device.

    Parameters

    • xpath: string

      The XPath of the configuration to be created.

    • element: string

      The configuration's XML representation.

    Returns Promise<string>

    A promise that resolves to a string containing the raw XML response from the configuration creation API call.

Generated using TypeDoc