Icingacli director service delete -- for ServiceApply objects

Dears,

Working on removing apply services from icinga: wrote a script to extract id’s directly from director db and pass them to icingacli director service delete, without success:

SQL query for services

# this script is used to delete service checks before creating new ones,
#
# 2022 07 03  + init /A
#

local_db="director"
local_username="director"
local_password="abrakadabra"

services_to_delete=$(mysql \
    -ss \
    -u ${local_username} \
    -p${local_password} \
    ${local_db} \
    -e "SELECT id FROM icinga_service WHERE object_type='apply' AND object_name LIKE '%546%';" \
)

for service in ${services_to_delete[@]}; do
    echo $service
done

output

[11:38:34 Tue Jul 05] @hostname /data/scripts/# ./services_remove.sh
463
464
465
466
467
468
469
470
471
472

icingacli removing services:

[11:03:32 Tue Jul 05] @hostname /data/scripts/hostname# icingacli director service show "15467"
ERROR: Icinga\Exception\NotFoundError in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:636 with message: Failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = '15467' AND object_type = 'template'

[11:03:42 Tue Jul 05] @hostname /data/scripts/hostname# icingacli director service show --id 472
ERROR: InvalidArgumentException in /usr/share/icingaweb2/modules/director/library/Director/Cli/ObjectCommand.php:480 with message: Object name parameter is required

[11:04:50 Tue Jul 05] @hostname /data/scripts/hostname# icingacli director service delete "15467"
ERROR: Icinga\Exception\NotFoundError in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:636 with message: Failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = '15467' AND object_type = 'template'

[11:06:16 Tue Jul 05] @hostname /data/scripts/hostname# icingacli director service delete "15467" --host ''
ERROR: Icinga\Exception\NotFoundError in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:636 with message: Failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = '15467' AND object_type = 'template'

[11:06:25 Tue Jul 05] @hostname /data/scripts/hostname# icingacli director service delete "15467" --host '*'
ERROR: Icinga\Exception\NotFoundError in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:642 with message: Failed to load icinga_host "*"

[11:06:28 Tue Jul 05] @hostname /data/scripts/hostname# icingacli director service delete "15467" --host
ERROR: Icinga\Exception\NotFoundError in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:642 with message: Failed to load icinga_host "1"

[11:06:33 Tue Jul 05] @hostname /data/scripts/hostname# icingacli director service delete "15467" --host 'NULL'
ERROR: Icinga\Exception\NotFoundError in /usr/share/icingaweb2/modules/director/library/Director/Data/Db/DbObject.php:642 with message: Failed to load icinga_host "NULL"

I have several questions:

  1. if serviceapply is stored in DB as service with object_type apply, why it can not be deleted using icingacli?
  2. why using above mentioned commands, service check can not be found?
  3. why searching for service, by default, criteria is “AND object_type=‘template’”?
  4. how to avoid host declaration , if it is NULL ?
MariaDB [(none)]> use director;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [director]> SELECT * FROM icinga_service WHERE id=472 \G
*************************** 1. row ***************************
                     id: 472
            object_name: 15467
            object_type: apply
               disabled: n
           display_name: NULL
                host_id: NULL
         service_set_id: NULL
       check_command_id: 240
     max_check_attempts: NULL
        check_period_id: NULL
         check_interval: NULL
         retry_interval: NULL
          check_timeout: NULL
   enable_notifications: NULL
   enable_active_checks: NULL
  enable_passive_checks: NULL
   enable_event_handler: NULL
        enable_flapping: NULL
        enable_perfdata: NULL
       event_command_id: NULL
flapping_threshold_high: NULL
 flapping_threshold_low: NULL
               volatile: NULL
                zone_id: NULL
    command_endpoint_id: NULL
                  notes: NULL
              notes_url: NULL
             action_url: NULL
             icon_image: NULL
         icon_image_alt: NULL
              use_agent: NULL
              apply_for: NULL
      use_var_overrides: NULL
          assign_filter: NULL
     template_choice_id: NULL
1 row in set (0.000 sec)

many thanks,
/A