connessione con hardware in assets
This commit is contained in:
@@ -17,8 +17,6 @@ use RuntimeException;
|
||||
|
||||
class UrbackupApiClient
|
||||
{
|
||||
private object $server;
|
||||
|
||||
private string $base_url;
|
||||
|
||||
private string $username;
|
||||
@@ -52,10 +50,11 @@ class UrbackupApiClient
|
||||
*/
|
||||
public function __construct(object $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
$this->base_url = rtrim($server->getWebInterfaceUrl(), '/') . '/x';
|
||||
$this->username = (string) ($server->fields['api_username'] ?? '');
|
||||
$this->password = (string) ($server->fields['api_password'] ?? '');
|
||||
$this->password = $server instanceof Server
|
||||
? $server->getApiPassword()
|
||||
: (string) ($server->fields['api_password'] ?? '');
|
||||
$this->ignore_ssl = ((int) ($server->fields['ignore_ssl'] ?? 0)) === 1;
|
||||
$this->server_version = (string) ($server->fields['server_version'] ?? '');
|
||||
$this->is_version_2_4_or_higher = $this->detectVersion2_4OrHigher();
|
||||
@@ -95,23 +94,6 @@ class UrbackupApiClient
|
||||
return $this->is_version_2_4_or_higher ? 'internet_mode_enabled' : 'internet_mode';
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract setting value from 2.5+ structured format or simple value.
|
||||
*
|
||||
* @param mixed $setting Setting value
|
||||
* @param mixed $default Default value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function extractSettingValue(mixed $setting, mixed $default = null): mixed
|
||||
{
|
||||
if (is_array($setting) && array_key_exists('value', $setting)) {
|
||||
return $setting['value'];
|
||||
}
|
||||
|
||||
return $setting ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test API connection.
|
||||
*
|
||||
@@ -361,25 +343,6 @@ class UrbackupApiClient
|
||||
unset($this->cached_settings[$client_id]);
|
||||
}
|
||||
|
||||
public function changeClientSetting(string $client_name, string $key, mixed $value): bool
|
||||
{
|
||||
$client_id = $this->getClientIdByName($client_name);
|
||||
|
||||
if ($client_id <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = $this->apiAction('settings', [
|
||||
'sa' => 'clientsettings_save',
|
||||
't_clientid' => $client_id,
|
||||
'overwrite' => 'true',
|
||||
$key => (string) $value,
|
||||
]);
|
||||
|
||||
$this->clearSettingsCache($client_id);
|
||||
return $this->responseIsSuccess($data);
|
||||
}
|
||||
|
||||
public function updateClientSettings(string $client_name, string $key, string $value): bool
|
||||
{
|
||||
$client_id = $this->getClientIdByName($client_name);
|
||||
|
||||
Reference in New Issue
Block a user