summaryrefslogtreecommitdiffstats
path: root/application/clicommands/ImportCommand.php
blob: 3edfff2ffb1a74d9d3a2ce880b14e8cdf279ff70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

namespace Icinga\Module\Director\Clicommands;

use Icinga\Module\Director\Cli\Command;
use Icinga\Module\Director\DirectorObject\Automation\ImportExport;
use Icinga\Module\Director\Objects\ImportSource;

/**
 * Export Director Config Objects
 */
class ImportCommand extends Command
{
    /**
     * Import ImportSource definitions
     *
     * USAGE
     *
     * icingacli director import importsources < importsources.json
     *
     * OPTIONS
     */
    public function importsourcesAction()
    {
        $json = file_get_contents('php://stdin');
        $import = new ImportExport($this->db());
        $count = $import->unserializeImportSources(json_decode($json));
        echo "$count Import Sources have been imported\n";
    }

    // /**
    //  * Import an ImportSource definition
    //  *
    //  * USAGE
    //  *
    //  * icingacli director import importsource < importsource.json
    //  *
    //  * OPTIONS
    //  */
    // public function importsourcection()
    // {
    //     $json = file_get_contents('php://stdin');
    //     $object = ImportSource::import(json_decode($json), $this->db());
    //     $object->store();
    //     printf("Import Source '%s' has been imported\n", $object->getObjectName());
    // }

    /**
     * Import SyncRule definitions
     *
     * USAGE
     *
     * icingacli director import syncrules < syncrules.json
     */
    public function syncrulesAction()
    {
        $json = file_get_contents('php://stdin');
        $import = new ImportExport($this->db());
        $count = $import->unserializeSyncRules(json_decode($json));
        echo "$count Sync Rules have been imported\n";
    }
}