diff --git a/library/Director/Import/ImportSourceCoreApi.php b/library/Director/Import/ImportSourceCoreApi.php new file mode 100644 index 00000000..f8550161 --- /dev/null +++ b/library/Director/Import/ImportSourceCoreApi.php @@ -0,0 +1,55 @@ +getSetting('object_type') . 'Objects'; + $objects = $this->api()->$func(); + $result = array(); + foreach ($objects as $object) { + $result[] = $object->toPlainObject(); + } + + return $result; + } + + public function listColumns() + { + $res = $this->fetchData(); + return array_keys((array) $res[0]); + } + + public static function addSettingsFormFields(QuickForm $form) + { + $form->addElement('select', 'object_type', array( + 'label' => 'Object type', + 'required' => true, + 'multiOptions' => $form->optionalEnum(array( + 'CheckCommand' => 'Commands', + 'Endpoint' => 'Endpoints', + 'Zone' => 'Zones', + )) + )); + } + + protected function api() + { + $apiconfig = Config::module('director')->getSection('api'); + $client = new RestApiClient($apiconfig->get('address'), $apiconfig->get('port')); + $client->setCredentials($apiconfig->get('username'), $apiconfig->get('password')); + $api = new CoreApi($client); + return $api; + } +}