--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 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.
+ */
+
+class JobBandwidthLimit extends BaculumAPIServer {
+
+ public function set($id, $params) {
+ $job = null;
+ if ($id > 0) {
+ $job = $this->getModule('job')->getJobById($id);
+ }
+
+ $jobid = null;
+ $result = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'));
+ if ($result->exitcode === 0) {
+ array_shift($result->output);
+ if(is_object($job) && in_array($job->name, $result->output)) {
+ $jobid = $job->jobid;
+ }
+ }
+ if (is_null($jobid)) {
+ $this->output = JobError::MSG_ERROR_JOB_DOES_NOT_EXISTS;
+ $this->error = JobError::ERROR_JOB_DOES_NOT_EXISTS;
+ return;
+ }
+
+ $limit = property_exists($params, 'limit') && $this->getModule('misc')->isValidInteger($params->limit) ? $params->limit : 0;
+
+ $cmd = array('setbandwidth', 'jobid="' . $jobid . '"', 'limit="' . $limit . '"');
+ $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd);
+ $this->output = $result->output;
+ if ($result->exitcode === 0) {
+ $this->error = GenericError::ERROR_NO_ERRORS;
+ } else {
+ $this->error = $result->exitcode;
+ }
+ }
+}
+?>
<url ServiceParameter="JobResNames" pattern="api/v1/jobs/resnames/" />
<url ServiceParameter="JobsShow" pattern="api/v1/jobs/show/" />
<url ServiceParameter="JobShow" pattern="api/v1/jobs/{id}/show/" parameters.id="\d+" />
+ <url ServiceParameter="JobBandwidthLimit" pattern="api/v1/jobs/{id}/bandwidth/" parameters.id="\d+" />
<url ServiceParameter="JobsRecent" pattern="api/v1/jobs/recent/{name}/" parameters.name="[a-zA-Z0-9:.\-_ ]+" />
<url ServiceParameter="JobEstimate" pattern="api/v1/jobs/estimate/" />
<url ServiceParameter="JobRun" pattern="api/v1/jobs/run/" />
"put": {
"tags": ["clients"],
"summary": "Set Client bandwidth limit",
- "description": "Set Client bandwidth limit in bytesh",
+ "description": "Set Client bandwidth limit in bytes",
"responses": {
"200": {
"description": "Set bandwidth limit output",
]
}
},
+ "/api/v1/jobs/{jobid}/bandwidth": {
+ "put": {
+ "tags": ["jobs"],
+ "summary": "Set Job bandwidth limit",
+ "description": "Set Job bandwidth limit in bytes",
+ "responses": {
+ "200": {
+ "description": "Set bandwidth limit output",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "output": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "description": "Bandwidth limit setting output"
+ }
+ },
+ "error": {
+ "type": "integer",
+ "description": "Error code",
+ "enum": [0, 1, 2, 3, 4, 5, 6, 7, 11, 50, 1000]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/JobId"
+ },
+ {
+ "name": "limit",
+ "in": "body",
+ "required": false,
+ "default": 0,
+ "description": "Bandwidth limit in bytes",
+ "schema": {
+ "type": "integer"
+ }
+ }
+ ]
+ }
+ },
"/api/v1/jobs/resnames": {
"get": {
"tags": ["jobs"],