$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;
+ }
}
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2023 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+use Baculum\API\Modules\BaculumAPIServer;
+use Baculum\Common\Modules\Errors\ObjectError;
+
+/**
+ * Available object types endpoint.
+ *
+ * @author Marcin Haba <marcin.haba@bacula.pl>
+ * @category API
+ * @package Baculum API
+ */
+class ObjectTypes extends BaculumAPIServer {
+
+ public function get() {
+ $this->output = $this->getModule('object')->getObjectTypes();
+ $this->error = ObjectError::ERROR_NO_ERRORS;
+ }
+}
<url ServiceParameter="ObjectClass" pattern="api/v2/objects/{id}/" parameters.id="\d+" />
<url ServiceParameter="ObjectsOverview" pattern="api/v2/objects/overview/" />
<url ServiceParameter="ObjectVersions" pattern="api/v2/objects/versions/{uuid}" parameters.uuid="[a-zA-Z0-9:.\-_ ]+" />
+ <url ServiceParameter="ObjectTypes" pattern="api/v2/objects/types/" />
<url ServiceParameter="ObjectStatsCategorySum" pattern="api/v2/objects/stats/category-sum/" />
<url ServiceParameter="ObjectStatsCategoryStatus" pattern="api/v2/objects/stats/category-status/" />
<url ServiceParameter="ObjectStatsSizeSum" pattern="api/v2/objects/stats/size-sum/" />
]
}
},
+ "/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"],