6. Using the WAPT Server APIs

6.1. API Overview

Note

This documentation does not describe all available APIs. It focuses on the most useful ones.

Currently, it is only possible to use Python code to interact with the APIs.

Most of the available APIs can be found in the server.py file located at /opt/wapt/waptserver/server.py on Debian.

Additional APIs are available in other files such as enterprise.py, repositories.py, wads.py, etc.

Warning

Since version 2.5, most API URLs are protected with SSL client certificates. Therefore, it is no longer possible to use HTML requests like: https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/hosts.

6.2. Using the API

6.2.1. Requirement:

1- Create a WAPT user and assign the ACL “launch requests” (It is recommended to create a new user for requests because the password is included in the request).

In the waptconsole : Go to Tools > Manage Wapt users and rights.

New account > F2 name like reporting.

Change User password on Wapt server (an key appear on the right on your reporting user in the red on the picture below).

Click on “Run Reports” ACL ( in green in the picture below).

Create reporting user

Create reporting user.

2- Depending on the request, it may be necessary to add ACLs on the reporting user. This can be see in the request file You can see this in the request in the api source file.

For example : On server.py file, you can read this at the begin of the API's resquest groups.

  example :
  @app.route('/api/v3/groups')
  @app.route('/api/v1/groups')
  @requires_auth(['admin','view']) Requires either the "admin" or "view" ACL (Access Control List) permissions. Having either one or both of these permissions is sufficient to access this endpoint.

6.2.2. Operating procedure:

There are two primary method to do an api request, the Command-Line Method and the Script-Based Method.

Any Wapt agent can launch an API.

6.2.2.1. Command-Line Method

The Command-Line Method involves executing API requests directly from the command line interface (CLI) using tools like cmd on Windows or bash on Unix-based systems. This method is quick and efficient for simple or one-off requests.

Example : On a CLI or bash

wapt-get server-request "/api/v1/hosts" -c waptconsole

6.2.2.2. Script-Based Method

The Script-Based Method requires creating a Python script (.py file) to define and execute the API request. This method is more flexible and powerful, allowing for complex logic, error handling, and data processing.

  1. Connect to a WAPT Windows agent.

  2. Create a directory named waptdev at the root of your disk, like, c:\waptdev\API_request.

  3. Create a .py file in this directory to edit the request, like, api-1.py.

  4. Copy the python script below and personalize the password for your user “reporting” and the desired API.

  5. Run the file with the following command: “C:\Program Files (x86)\wapt\wapt-get.exe” c:\waptdev\API_request\api-1.py.

  6. The output can be displayed in CSV format: cat api-1.csv.

The python script

import json
import waptlicences
import csv
import sys
sys.path.append('/opt/wapt')

from common import Wapt
WAPT = Wapt()
ini_wapt_path = WAPT.config_filename

user = "reporting"
password = "[Enter the password for user reporting]"

def run_report():
    auth_context = waptlicences.waptserver_login(ini_wapt_path, user=user, password=password)
    try:
        res = waptlicences.waptserver_request(ini_wapt_path, action='[enter the desired api]', auth_context=auth_context)
        if res['http_status'] == 200:
            data = json.loads(res['content'])['result']

            # Debugging: Print the raw data received from the API
            print("Raw data from API:", json.dumps(data, indent=2))

            # Check if data is not empty
            if not data:
                print("No data received from the API.")
                return []

            # Check if the first element of data is a list
            if isinstance(data[0], list):
                for row in data:
                    # Assuming row is a list of strings
                    for i, value in enumerate(row):
                        if isinstance(value, list):
                            row[i] = '|'.join(value)

                with open('test.csv', 'w', newline='', encoding='utf-8') as csvfile:
                    fieldnames = data[0]
                    writer = csv.writer(csvfile, delimiter=';')
                    writer.writerow(fieldnames)
                    writer.writerows(data[1:])  # Write the rest of the data
            else:
                print("Unexpected data format. First element is not a list.")
                return []

            return data
        else:
            raise Exception('Request failed with status %s : %s' % (res['http_status'], res['content']))
    finally:
        waptlicences.waptserver_logout(ini_wapt_path)

# Call the function and print the returned data
data = run_report()
print(repr(data))

6.3. API V1

6.3.1. /api/v1/hosts

  • Get registration data of one or several hosts.

    # Args:
    #     has_errors (0/1): filter out hosts with packages errors
    #     need_upgrade (0/1): filter out hosts with outdated packages
    #     groups (csvlist of packages): hosts with packages
    #     columns (csvlist of columns):
    #     uuid (csvlist of uuid): <uuid1[,uuid2,...]>): filter based on uuid
    #     filter (csvlist of field):regular expression: filter based on attributes
    #     not_filter (0,1):
    #     limit (int): 1000
    #     trusted_certs_sha256 (csvlist): filter out hosts based on their trusted package certs
    
    # Returns:
    #     result (dict): {'records':[],'files':[]}
    #     query:
    #       uuid=<uuid>
    #     or
    #       filter=<csvlist of fields>:regular expression
    # """
    
  • List all hosts using the following parameters:

    • reachable;

    • computer_fqdn ==> computer_name;

    • connected_ips;

    • mac_addresses.

    This example shows a request with parameters:

    cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
    advanced_hosts_wapt = wgets('https://%s:%s@%s/api/v1/hosts?columns=reachable,computer_fqdn,connected_ips,mac_addresses&limit=10000' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
    parsed = json.loads(advanced_hosts_wapt)
    print(json.dumps(parsed, indent=1, sort_keys=True))
    

    This example is a global request:

    cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
    hosts_wapt = wgets('https://%s:%s@%s/api/v1/hosts' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
    parsed = json.loads(hosts_wapt)
    print(json.dumps(parsed, indent=1, sort_keys=True))
    

    Hint

    This is the same exemple with a simple html request:

    https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/hosts
    

    This one just show request with reachable status, the computer name, its connected ips and its mac addresses. The display limit is 10000.

    https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/hosts?columns=reachable,computer_fqdn,connected_ips,mac_addresses&limit=10000
    

6.3.2. /api/v1/groups

  • Get all dependencies that are directly assigned to a machine package:

    cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
    group_wapt = wgets('https://%s:%s@%s/api/v1/groups' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
    parsed = json.loads(group_wapt)
    print(json.dumps(parsed, indent=1, sort_keys=True))
    

    Hint

    This is the same exemple with a simple html request:

    https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/groups
    

6.3.3. /api/v1/host_data

6.3.3.1. dmi

  • Get DMI info for a host:

Note

# # Get additional data for a host # query: # uuid=<uuid> # field=packages, dmi or softwares

Note

dmi is not the only available option. You can also lookup information using installed_packages, wsusupdates ou installed_softwares.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
dmi_host_data_wapt = wgets('https://%s:%s@%s/api/v1/host_data?uuid=UUID&field=dmi' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
#print(dmi_host_data_wapt)
parsed = json.loads(dmi_host_data_wapt)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/host_data?uuid=14F620FF-DE70-9E5B-996A-B597E8F9B4AD&field=dmi

6.3.3.2. installed_packages

Option installed_packages will list all packages installed on a specific host.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
install_packages_data_wapt = wgets('https://%s:%s@%s/api/v1/host_data?uuid=UUID&field=installed_packages' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
parsed = json.loads(install_packages_data_wapt)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/host_data?uuid=14F620FF-DE70-9E5B-996A-B597E8F9B4AD&field=installed_packages

6.3.3.3. installed_softwares

Option installed_softwares will list all softwares installed on a specific host.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
install_softwares_data_wapt = wgets('https://%s:%s@%s/api/v1/host_data?uuid=UUID&field=installed_softwares' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
#print(install_softwares_data_wapt)
parsed = json.loads(install_softwares_data_wapt)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/host_data?uuid=14F620FF-DE70-9E5B-996A-B597E8F9B4AD&field=installed_softwares

6.3.3.4. wsusupdates

Option wsusupdates will list all Windows Updates installed on a specific host.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
wsusupdates_data_wapt = wgets('https://%s:%s@%s/api/v1/host_data?uuid=UUID&field=wsusupdates' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
#print(wsusupdates_data_wapt)
parsed = json.loads(wsusupdates_data_wapt)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/host_data?uuid=14F620FF-DE70-9E5B-996A-B597E8F9B4AD&field=wsusupdates

6.3.4. /api/v1/usage_statistics

Get usage statistics from the WAPT Server.

Hint

This API is useful if you have several WAPT Servers and you want to know how many hosts are there.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
usage_statistics_wapt =wgets('https://%s:%s@%s/api/v1/usage_statistics' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
#print(usage_statistics_wapt)
parsed = json.loads(usage_statistics_wapt)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v1/usage_statistics

6.4. API V2

6.4.1. /api/v2/waptagent_version

Display waptagent.exe version.

waptagent_version = wgets('https://%s:%s@%s/api/v2/waptagent_version' % (wapt_user,wapt_password,wapt_url))
parsed = json.loads(waptagent_version)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v2/waptagent_version

6.5. API V3

6.5.1. /api/v3/reporting_exec

Here is a python script that executes a query with a specific id from WAPT Console Reporting tab. In this script, user “reporting” should have “Run reports” ACL. It works on every platform (windows, linux and mac agents).

import os
import json
import logging
import waptlicences
import requests
import sys
sys.path.append('/opt/wapt')
from common import get_requests_client_cert_session
from common import Wapt



WAPT = Wapt()
ini_wapt_path = WAPT.config_filename
w = Wapt(config_filename=ini_wapt_path)

# WAPT Conf
wapt_url = w.waptserver.server_url

user = "reporting"
password = "password"


def run_report():

    t = waptlicences.waptserver_login(ini_wapt_path,user,password)
    session = get_requests_client_cert_session(wapt_url,
    cert=(t['client_certificate'],t['client_private_key'],t['client_private_key_password']),
    verify=w.waptserver.verify_cert
    )
    if not 'session' in t['session_cookies']:
      session_cookies = [u for u in t['session_cookies'] if u['Domain'] == WAPT.waptserver.server_url.split('://')[-1]][0]
    else:
      session_cookies = t['session_cookies']['session']
      session_cookies['Name'] = 'session'

    session.cookies.set(session_cookies['Name'], session_cookies['Value'], domain=session_cookies['Domain'])
    t= None


    url = f'{wapt_url}/api/v3/reporting_exec?id=19'
    response = session.get(url)
    data = response.json()

    return data['result']



print(run_report())

6.5.2. /api/v3/packages

List packages on the repository, retrieve the control files of WAPT packages.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
packages_wapt = wgets('https://%s:%s@%s/api/v3/packages' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
parsed = json.loads(packages_wapt)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/packages

6.5.3. /api/v3/known_packages

List all packages with last signed_on information.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
known_packages_wapt = wgets('https://%s:%s@%s/api/v3/known_packages' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
parsed = json.loads(known_packages_wapt)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/known_packages

6.5.4. /api/v3/trigger_cancel_task

Cancel a running task.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
trigger_cancel_task = wgets('https://%s:%s@%s/api/v3/trigger_cancel_task' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
parsed = json.loads(trigger_cancel_task)
print(json.dumps(parsed, indent=1, sort_keys=True))

6.5.5. /api/v3/get_ad_ou

List OU seen by hosts and displayed in the WAPT Console.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
get_ad_ou = wgets('https://%s:%s@%s/api/v3/get_ad_ou' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
parsed = json.loads(get_ad_ou)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/get_ad_ou

6.5.6. /api/v3/get_ad_sites

List Active Directory sites.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
get_ad_sites = wgets('https://%s:%s@%s/api/v3/get_ad_sites' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
parsed = json.loads(get_ad_sites)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/get_ad_sites

6.5.7. /api/v3/hosts_for_package

List hosts with a specific package installed.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
hosts_for_package = wgets('https://%s:%s@%s/api/v3/hosts_for_package?package=PACKAGE' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
parsed = json.loads(hosts_for_package)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/hosts_for_package?package=demo-namepackage

6.5.8. /api/v3/host_tasks_status

List tasks on a particular host.

cert_path = (r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt',r'C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem')
host_tasks_status = wgets('https://%s:%s@%s/api/v3/host_tasks_status?uuid=UUID' % (wapt_user,wapt_password,wapt_url),verify_cert=False,cert=cert_path)
parsed = json.loads(host_tasks_status)
print(json.dumps(parsed, indent=1, sort_keys=True))

Hint

This is the same exemple with a simple html request:

https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/host_tasks_status?uuid=14F620FF-DE70-9E5B-996A-B597E8F9B4AD

Attention

Next API are with POST method.

6.5.9. /api/v3/upload_packages

6.5.10. /api/v3/upload_hosts

6.5.11. /api/v3/change_password

Change the Admininistrator password [only this account]. The request is a python dictionnary {} with keys:

  • user;

  • old_password;

  • new_password.

curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST --data-raw '{"user":"USER","password":"old_password","new_password":"new_password"}' -H "Content-Type: application/json" "https://user:old_password@srvwapt/api/v3/change_password"

6.5.12. /api/v3/login

Initialize a connection to the WAPT Server.

curl --insecure -X POST --data-raw '{"user":"admin","password":"MYPASSWORD"}' -H "Content-Type: application/json" "https://srvwapt.mydomain.lan/api/v3/login"

{"msg": "Authentication OK", "result": {"edition": "enterprise", "hosts_count": 6, "version": "1.7.4", "server_domain": "mydomain.lan", "server_uuid": "32464dd6-c261-11e8-87be-cee799b43a00"}, "success": true, "request_time": 0.03377699851989746}

Hint

We can make a connection by html form then POST: https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/get_ad_sites

6.5.13. /api/v3/packages_delete

Delete package with a precise version. The request is a python list []. A list of packages may be given, separated by commas ,.

Example:

curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST --data-raw '["demo-libreoffice-stable_5.4.6.2-3_all.wapt"]' -H "Content-Type: application/json" "https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/packages_delete"

6.5.14. /api/v3/reset_hosts_sid

Reinitialize all host connections.

For the POST method, the syntax is: --data-raw a dictionnary list with uuids as keys and the UUIDs of the hosts as values.

curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST --data-raw '{"uuids":["UUID"]}' -H "Content-Type: application/json" "https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/reset_hosts_sid"

{"msg": "Hosts connection reset launched for 1 host(s)", "result": {}, "success": true, "request_time": null}

Hint

If you want several hosts:

curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST --data-raw '{"uuids":["UUID#1","UUID#2"]}' -H "Content-Type: application/json" "https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/reset_hosts_sid"

{"msg": "Hosts connection reset launched for 2 host(s)", "result": {}, "success": true, "request_time": null}

6.5.15. /api/v3/trigger_wakeonlan

If hosts are WakeOnLan enabled, this API is useful.

Syntax is --data-raw: a dictionnary with key uuids and a list of host uuids.

curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST --data-raw '{"uuids":["UUID"]}' -H "Content-Type: application/json" "https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/trigger_wakeonlan"

{"msg": "Wakeonlan packets sent to 1 machines.", "result": [{"computer_fqdn": "computer_fqdn", "mac_addresses": ["mac_addresses"], "uuid": "UUID"}], "success": true, "request_time": null}

Hint

If you want several hosts:

curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST --data-raw '{"uuids":["UUID#1","UUID#2"]}' -H "Content-Type: application/json" "https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/trigger_wakeonlan"

{"msg": "Wakeonlan packets sent to 2 machines.", "result": [{"computer_fqdn": "computer_fqdn#1", "mac_addresses": ["mac_addresses#1"], "uuid": "UUID#1"}, {"computer_fqdn": "computer_fqdn#2", "mac_addresses": ["mac_addresses#2"], "uuid": "UUID#2"}], "success": true, "request_time": null}

6.5.16. /api/v3/hosts_delete

"""Remove one or several hosts from the WAPT Server database and optionnally the host packages

Args:
    uuids (list): list of uuids to delete
    filter (csvlist of field:regular expression): filter based on attributes
    delete_packages (bool): delete host's packages
    delete_inventory (bool): delete host's inventory

Returns:
    result (dict):
"""

If you want to delete a host from the inventory:

curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST --data-raw '{"uuids":["UUID"],"delete_inventory":"True","delete_packages":"True"}' -H "Content-Type: application/json" "https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/hosts_delete"

{"msg": "1 files removed from host repository\n1 hosts removed from DB", "result": {"files": ["/var/www/wapt-host/UUID.wapt"], "records": [{"computer_fqdn": "computer_fqdn", "uuid": "UUID"}]}, "success": true, "request_time": null}

If you do not want to delete from the inventory:

curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST --data-raw '{"uuids":["UUID"],"delete_inventory":"False","delete_packages":"False"}' -H "Content-Type: application/json" "https://admin:MYPASSWORD@srvwapt.mydomain.lan/api/v3/hosts_delete"

{"msg": "0 files removed from host repository\n1 hosts removed from DB", "result": {"files": [], "records": [{"computer_fqdn": "computer_fqdn", "uuid": "UUID"}]}, "success": true, "request_time": null}

6.5.17. /api/v3/trigger_host_action

6.5.18. /api/v3/upload_waptsetup

# Upload waptsetup

#Handle the upload of customized waptagent.exe into wapt repository

### DOES NOT WORK
#curl --cert "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.crt" --key "C:\Program Files (x86)\wapt\private\71253c6c-f412-455b-a907-93b10ce07490.pem" --insecure -X POST -H "Content-Type: multipart/form-data" -F 'data=@waptagent.exe' "https://admin:MYPASSWORD@srvwapt.mydomain.lan/upload_waptsetup"

6.5.19. /api/v3/ping

Ping shows a general set of informations on a WAPT Server.

# https://srvwapt.mydomain.lan/ping
# Lists WAPT Server informations

ping_wapt = wgets('https://%s:%s@%s/ping' % (wapt_user,wapt_password,wapt_url))
parsed = json.loads(ping_wapt)
print(json.dumps(parsed, indent=1, sort_keys=True))