From: Marcin Haba Date: Wed, 31 May 2023 11:21:23 +0000 (+0200) Subject: baculum: Add object types endpoint X-Git-Tag: Release-13.0.4~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7be7fabe57f7c7fa5832f6ff4204995e548bf6e6;p=thirdparty%2Fbacula.git baculum: Add object types endpoint --- diff --git a/gui/baculum/protected/API/Modules/ObjectManager.php b/gui/baculum/protected/API/Modules/ObjectManager.php index 2b8ab6f30..6c0e3f662 100644 --- a/gui/baculum/protected/API/Modules/ObjectManager.php +++ b/gui/baculum/protected/API/Modules/ObjectManager.php @@ -659,4 +659,19 @@ JOIN Job USING (JobId) ' $statement = Database::runQuery($sql, $where['params']); return $statement->fetchAll(\PDO::FETCH_ASSOC); } + + /** + * Get existing object types. + * + * @return array object types + */ + public function getObjectTypes() { + $sql = 'SELECT DISTINCT ObjectType as objecttype + FROM Object'; + $statement = Database::runQuery($sql); + $result = $statement->fetchAll(\PDO::FETCH_GROUP); + $values = array_keys($result); + sort($values); + return $values; + } } diff --git a/gui/baculum/protected/API/Pages/API/ObjectTypes.php b/gui/baculum/protected/API/Pages/API/ObjectTypes.php new file mode 100644 index 000000000..b22363a3b --- /dev/null +++ b/gui/baculum/protected/API/Pages/API/ObjectTypes.php @@ -0,0 +1,39 @@ + + * @category API + * @package Baculum API + */ +class ObjectTypes extends BaculumAPIServer { + + public function get() { + $this->output = $this->getModule('object')->getObjectTypes(); + $this->error = ObjectError::ERROR_NO_ERRORS; + } +} diff --git a/gui/baculum/protected/API/Pages/API/endpoints.xml b/gui/baculum/protected/API/Pages/API/endpoints.xml index 400bfbeb5..8c2679ca7 100644 --- a/gui/baculum/protected/API/Pages/API/endpoints.xml +++ b/gui/baculum/protected/API/Pages/API/endpoints.xml @@ -106,6 +106,7 @@ + diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index e5d2afe8f..a1379c033 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -8327,6 +8327,39 @@ ] } }, + "/api/v2/objects/types": { + "get": { + "tags": ["objects"], + "summary": "Object types", + "description": "Get object types.", + "responses": { + "200": { + "description": "Object types.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "output": { + "type": "array", + "items": { + "type": "string", + "description": "Object type" + } + }, + "error": { + "type": "integer", + "description": "Error code", + "enum": [0, 1, 2, 3, 6, 7, 1000] + } + } + } + } + } + } + } + } + }, "/api/v2/objects/overview": { "get": { "tags": ["objects"],