$sth->execute();
return $sth->fetchAll(\PDO::FETCH_ASSOC);
}
+
+ /**
+ * Get all object versions by objectuuid.
+ *
+ * @param string $objectuuid object UUID
+ * @return array object versions
+ */
+ public function getObjectVersions($objectuuid) {
+ $sql = 'SELECT
+ obj.ObjectUUID AS objectuuid,
+ obj.ObjectId AS objectid,
+ obj.ObjectType AS objecttype,
+ obj.ObjectName AS objectname,
+ obj.ObjectCategory AS objectcategory,
+ Job.JobId AS jobid,
+ Job.Name AS jobname,
+ Job.Level AS level,
+ Job.JobStatus AS jobstatus,
+ Job.JobBytes AS jobbytes,
+ Job.JobFiles AS jobfiles,
+ Job.StartTime AS starttime,
+ Job.EndTime AS endtime,
+ Job.JobErrors AS joberrors,
+ Client.Name AS client,
+ FileSet.FileSet AS fileset
+ FROM
+ Object AS obj
+ LEFT JOIN Job USING(JobId)
+ LEFT JOIN Client USING(ClientId)
+ LEFT JOIN FileSet USING(FileSetId)
+ WHERE
+ obj.ObjectUUID=:objectuuid
+ ORDER BY Job.StartTime DESC';
+ $connection = ObjectRecord::finder()->getDbConnection();
+ $connection->setActive(true);
+ $pdo = $connection->getPdoInstance();
+ $sth = $pdo->prepare($sql);
+ $sth->bindParam(':objectuuid', $objectuuid, \PDO::PARAM_STR, 400);
+ $sth->execute();
+ return $sth->fetchAll(\PDO::FETCH_ASSOC);
+ }
}
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2022 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\Common\Modules\Errors\ObjectError;
+
+/**
+ * Object versions endpoint.
+ *
+ * @author Marcin Haba <marcin.haba@bacula.pl>
+ * @category API
+ * @package Baculum API
+ */
+class ObjectVersions extends BaculumAPIServer {
+
+ public function get() {
+ $misc = $this->getModule('misc');
+ $objectuuid = null;
+ if ($this->Request->contains('uuid') && $misc->isValidName($this->Request['uuid'])) {
+ $objectuuid = $this->Request['uuid'];
+ }
+
+ $versions = $this->getModule('object')->getObjectVersions(
+ $objectuuid
+ );
+ $this->output = $versions;
+ $this->error = ObjectError::ERROR_NO_ERRORS;
+ }
+}
<!-- event endpoints -->
<url ServiceParameter="Objects" pattern="api/v2/objects/" />
<url ServiceParameter="ObjectClass" pattern="api/v2/objects/{id}/" parameters.id="\d+" />
+ <url ServiceParameter="ObjectVersions" pattern="api/v2/objects/versions/{uuid}" parameters.uuid="[a-zA-Z0-9:.\-_ ]+" />
<url ServiceParameter="ObjectStatsCategorySum" pattern="api/v2/objects/stats/category-sum/" />
<url ServiceParameter="ObjectStatsSizeSum" pattern="api/v2/objects/stats/size-sum/" />
<!-- @TODO: Separate this endpoint outside 'joblog' -->
]
}
},
+ "/api/v2/objects/versions/{objectuuid}": {
+ "get": {
+ "tags": ["objects"],
+ "summary": "Object versions by objectuuid",
+ "description": "Get object versions.",
+ "responses": {
+ "200": {
+ "description": "Object versions by objectuuid",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "output": {
+ "$ref": "#/components/schemas/Objects"
+ },
+ "error": {
+ "type": "integer",
+ "description": "Error code",
+ "enum": [0, 1, 2, 3, 6, 7, 1000]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "objectuuid",
+ "in": "path",
+ "required": true,
+ "description": "Object UUID",
+ "schema": {
+ "type": "string"
+ }
+ }
+ ]
+ }
+ },
"/api/v2/objects/stats/category-sum": {
"get": {
"tags": ["objects"],