Skip to content

Commit aa6bbf3

Browse files
Merge pull request #714 from vitspec99/next_minor
2 parents d86f113 + 85f69ca commit aa6bbf3

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace RESTAPI\Endpoints;
4+
5+
require_once 'RESTAPI/autoloader.inc';
6+
7+
use RESTAPI\Core\Endpoint;
8+
9+
/**
10+
* Defines an Endpoint for interacting with the SystemTimezone Model object at
11+
* /api/v2/system/timezone.
12+
*/
13+
class SystemTimezoneEndpoint extends Endpoint {
14+
public function __construct() {
15+
# Set Endpoint attributes
16+
$this->url = '/api/v2/system/timezone';
17+
$this->model_name = 'SystemTimezone';
18+
$this->request_method_options = ['GET', 'PATCH'];
19+
$this->get_help_text = 'Reads the current system timezone.';
20+
$this->patch_help_text = 'Updates the system timezone.';
21+
22+
# Construct the parent Endpoint object
23+
parent::__construct();
24+
}
25+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace RESTAPI\Models;
4+
5+
use RESTAPI\Core\Model;
6+
use RESTAPI\Fields\StringField;
7+
use RESTAPI\Responses\ValidationError;
8+
9+
/**
10+
* Defines a Model that represents the Timezone configuration on this system.
11+
*/
12+
class SystemTimezone extends Model {
13+
public StringField $timezone;
14+
15+
public function __construct(mixed $id = null, mixed $parent_id = null, mixed $data = [], mixed ...$options) {
16+
# Set model attributes
17+
$this->config_path = 'system';
18+
$this->update_strategy = 'merge';
19+
$this->always_apply = true;
20+
21+
# Set model Fields
22+
$this->timezone = new StringField(
23+
default: 'Etc/GMT',
24+
allow_empty: false,
25+
allow_null: false,
26+
many: false,
27+
choices_callable: 'get_timezone_choices',
28+
help_text: 'Set geographic region name (Continent/Location) to determine the timezone for the firewall.'
29+
);
30+
31+
parent::__construct($id, $parent_id, $data, ...$options);
32+
}
33+
34+
/**
35+
* Apply these Timezone changes to the system.
36+
*/
37+
public function apply() {
38+
system_timezone_configure();
39+
}
40+
41+
/*
42+
*
43+
*/
44+
public function get_timezone_choices(): array {
45+
return system_get_timezone_list();
46+
}
47+
}

0 commit comments

Comments
 (0)