Skip to content

Commit 8854a90

Browse files
committed
stuff and also things
1 parent 0184373 commit 8854a90

18 files changed

Lines changed: 1115 additions & 10 deletions

.github/copilot-instructions.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
* **Always** used named parameters wherever possible.
2424
* **Never** bother with docblocks unless they are necessary to specify types that cannot be expressed in code
2525
(e.g. `/** @param string[] $items */` for `array $items`).
26-
* **Never** call `jsonSerialize` directly in generated code.
26+
* **Never** call `jsonSerialize` directly in generated code from within others, as this is an implementation detail\
27+
of the `JsonSerializable` interface.
28+
* Instead, simply set the field of the output object to the raw value of the field (e.g.
29+
`$output->foo = $this->foo;` instead of `$output->foo = $this->foo->jsonSerialize();`).
2730

2831
# When generting code for concrete implementations of AbstractType:
2932
* **Always** ensure that class fields have an associated getter and setter method.

src/ACL/ACLAuthMethodListEntry.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ACLAuthMethodListEntry extends AbstractType
3434
public int $CreateIndex;
3535
public int $ModifyIndex;
3636
public string $Namespace;
37+
public string $Partition;
3738

3839
public function __construct(
3940
string $Name = '',
@@ -44,7 +45,8 @@ public function __construct(
4445
string $TokenLocality = '',
4546
int $CreateIndex = 0,
4647
int $ModifyIndex = 0,
47-
string $Namespace = ''
48+
string $Namespace = '',
49+
string $Partition = '',
4850
) {
4951
$this->Name = $Name;
5052
$this->Type = $Type;
@@ -55,6 +57,7 @@ public function __construct(
5557
$this->CreateIndex = $CreateIndex;
5658
$this->ModifyIndex = $ModifyIndex;
5759
$this->Namespace = $Namespace;
60+
$this->Partition = $Partition;
5861
}
5962

6063
public function getName(): string
@@ -156,6 +159,17 @@ public function setNamespace(string $Namespace): self
156159
return $this;
157160
}
158161

162+
public function getPartition(): string
163+
{
164+
return $this->Partition;
165+
}
166+
167+
public function setPartition(string $Partition): self
168+
{
169+
$this->Partition = $Partition;
170+
return $this;
171+
}
172+
159173
public static function jsonUnserialize(\stdClass $decoded): self
160174
{
161175
$n = new self();
@@ -191,6 +205,9 @@ public function jsonSerialize(): \stdClass
191205
if ('' !== $this->Namespace) {
192206
$out->Namespace = $this->Namespace;
193207
}
208+
if ('' !== $this->Partition) {
209+
$out->Partition = $this->Partition;
210+
}
194211
return $out;
195212
}
196213
}

src/ACL/ACLBindingRule.php

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ class ACLBindingRule extends AbstractType
3030
public string $Selector;
3131
public BindingRuleBindType $BindType;
3232
public string $BindName;
33+
public null|ACLTemplatedPolicyVariables $BindVars;
3334
public int $CreateIndex;
3435
public int $ModifyIndex;
3536
public string $Namespace;
37+
public string $Partition;
3638

3739
public function __construct(
3840
string $ID = '',
@@ -41,19 +43,23 @@ public function __construct(
4143
string $Selector = '',
4244
string|BindingRuleBindType $BindType = BindingRuleBindType::UNDEFINED,
4345
string $BindName = '',
46+
null|ACLTemplatedPolicyVariables $BindVars = null,
4447
int $CreateIndex = 0,
4548
int $ModifyIndex = 0,
46-
string $Namespace = ''
49+
string $Namespace = '',
50+
string $Partition = '',
4751
) {
4852
$this->ID = $ID;
4953
$this->Description = $Description;
5054
$this->AuthMethod = $AuthMethod;
5155
$this->Selector = $Selector;
5256
$this->BindType = ($BindType instanceof BindingRuleBindType) ? $BindType : BindingRuleBindType::from($BindType);
5357
$this->BindName = $BindName;
58+
$this->BindVars = $BindVars;
5459
$this->CreateIndex = $CreateIndex;
5560
$this->ModifyIndex = $ModifyIndex;
5661
$this->Namespace = $Namespace;
62+
$this->Partition = $Partition;
5763
}
5864

5965
public function getID(): string
@@ -122,6 +128,17 @@ public function setBindName(string $BindName): self
122128
return $this;
123129
}
124130

131+
public function getBindVars(): null|ACLTemplatedPolicyVariables
132+
{
133+
return $this->BindVars;
134+
}
135+
136+
public function setBindVars(null|ACLTemplatedPolicyVariables $BindVars): self
137+
{
138+
$this->BindVars = $BindVars;
139+
return $this;
140+
}
141+
125142
public function getCreateIndex(): int
126143
{
127144
return $this->CreateIndex;
@@ -155,11 +172,26 @@ public function setNamespace(string $Namespace): self
155172
return $this;
156173
}
157174

175+
public function getPartition(): string
176+
{
177+
return $this->Partition;
178+
}
179+
180+
public function setPartition(string $Partition): self
181+
{
182+
$this->Partition = $Partition;
183+
return $this;
184+
}
185+
158186
public static function jsonUnserialize(\stdClass $decoded): self
159187
{
160188
$n = new self();
161189
foreach ((array)$decoded as $k => $v) {
162-
$n->{$k} = $v;
190+
if ('BindVars' === $k && null !== $v) {
191+
$n->BindVars = ACLTemplatedPolicyVariables::jsonUnserialize($v);
192+
} else {
193+
$n->{$k} = $v;
194+
}
163195
}
164196
return $n;
165197
}
@@ -173,11 +205,17 @@ public function jsonSerialize(): \stdClass
173205
$out->Selector = $this->Selector;
174206
$out->BindType = $this->BindType;
175207
$out->BindName = $this->BindName;
208+
if (null !== $this->BindVars) {
209+
$out->BindVars = $this->BindVars;
210+
}
176211
$out->CreateIndex = $this->CreateIndex;
177212
$out->ModifyIndex = $this->ModifyIndex;
178213
if ('' !== $this->Namespace) {
179214
$out->Namespace = $this->Namespace;
180215
}
216+
if ('' !== $this->Partition) {
217+
$out->Partition = $this->Partition;
218+
}
181219
return $out;
182220
}
183221
}

src/ACL/ACLReplicationStatus.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,36 @@ class ACLReplicationStatus extends AbstractType
2929
public bool $Enabled;
3030
public bool $Running;
3131
public string $SourceDatacenter;
32+
public string $ReplicationType;
3233
public int $ReplicatedIndex;
3334
public int $ReplicatedRoleIndex;
3435
public int $ReplicatedTokenIndex;
3536
public Time\Time $LastSuccess;
3637
public Time\Time $LastError;
38+
public string $LastErrorMessage;
3739

3840
public function __construct(
3941
bool $Enabled = false,
4042
bool $Running = false,
4143
string $SourceDatacenter = '',
44+
string $ReplicationType = '',
4245
int $ReplicatedIndex = 0,
4346
int $ReplicatedRoleIndex = 0,
4447
int $ReplicatedTokenIndex = 0,
4548
null|Time\Time $LastSuccess = null,
4649
null|Time\Time $LastError = null,
50+
string $LastErrorMessage = '',
4751
) {
4852
$this->Enabled = $Enabled;
4953
$this->Running = $Running;
5054
$this->SourceDatacenter = $SourceDatacenter;
55+
$this->ReplicationType = $ReplicationType;
5156
$this->ReplicatedIndex = $ReplicatedIndex;
5257
$this->ReplicatedRoleIndex = $ReplicatedRoleIndex;
5358
$this->ReplicatedTokenIndex = $ReplicatedTokenIndex;
5459
$this->LastSuccess = $LastSuccess ?? Time::New();
5560
$this->LastError = $LastError ?? Time::New();
61+
$this->LastErrorMessage = $LastErrorMessage;
5662
}
5763

5864
public function isEnabled(): bool
@@ -88,6 +94,17 @@ public function setSourceDatacenter(string $SourceDatacenter): self
8894
return $this;
8995
}
9096

97+
public function getReplicationType(): string
98+
{
99+
return $this->ReplicationType;
100+
}
101+
102+
public function setReplicationType(string $ReplicationType): self
103+
{
104+
$this->ReplicationType = $ReplicationType;
105+
return $this;
106+
}
107+
91108
public function getReplicatedIndex(): int
92109
{
93110
return $this->ReplicatedIndex;
@@ -143,6 +160,17 @@ public function setLastError(Time\Time $LastError): self
143160
return $this;
144161
}
145162

163+
public function getLastErrorMessage(): string
164+
{
165+
return $this->LastErrorMessage;
166+
}
167+
168+
public function setLastErrorMessage(string $LastErrorMessage): self
169+
{
170+
$this->LastErrorMessage = $LastErrorMessage;
171+
return $this;
172+
}
173+
146174
public static function jsonUnserialize(\stdClass $decoded): self
147175
{
148176
$n = new self();
@@ -164,11 +192,13 @@ public function jsonSerialize(): \stdClass
164192
$out->Enabled = $this->Enabled;
165193
$out->Running = $this->Running;
166194
$out->SourceDatacenter = $this->SourceDatacenter;
195+
$out->ReplicationType = $this->ReplicationType;
167196
$out->ReplicatedIndex = $this->ReplicatedIndex;
168197
$out->ReplicatedRoleIndex = $this->ReplicatedRoleIndex;
169198
$out->ReplicatedTokenIndex = $this->ReplicatedTokenIndex;
170199
$out->LastSuccess = $this->LastSuccess->format(DATE_RFC3339);
171200
$out->LastError = $this->LastError->format(DATE_RFC3339);
201+
$out->LastErrorMessage = $this->LastErrorMessage;
172202
return $out;
173203
}
174204
}

src/Agent/AgentAuthorize.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DCarbone\PHPConsulAPI\Agent;
6+
7+
/*
8+
Copyright 2016-2025 Daniel Carbone (daniel.p.carbone@gmail.com)
9+
10+
Licensed under the Apache License, Version 2.0 (the "License");
11+
you may not use this file except in compliance with the License.
12+
You may obtain a copy of the License at
13+
14+
http://www.apache.org/licenses/LICENSE-2.0
15+
16+
Unless required by applicable law or agreed to in writing, software
17+
distributed under the License is distributed on an "AS IS" BASIS,
18+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
See the License for the specific language governing permissions and
20+
limitations under the License.
21+
*/
22+
23+
use DCarbone\PHPConsulAPI\PHPLib\AbstractType;
24+
25+
class AgentAuthorize extends AbstractType
26+
{
27+
public bool $Authorized;
28+
public string $Reason;
29+
30+
public function __construct(
31+
bool $Authorized = false,
32+
string $Reason = '',
33+
) {
34+
$this->Authorized = $Authorized;
35+
$this->Reason = $Reason;
36+
}
37+
38+
public function isAuthorized(): bool
39+
{
40+
return $this->Authorized;
41+
}
42+
43+
public function setAuthorized(bool $Authorized): self
44+
{
45+
$this->Authorized = $Authorized;
46+
return $this;
47+
}
48+
49+
public function getReason(): string
50+
{
51+
return $this->Reason;
52+
}
53+
54+
public function setReason(string $Reason): self
55+
{
56+
$this->Reason = $Reason;
57+
return $this;
58+
}
59+
60+
public static function jsonUnserialize(\stdClass $decoded): self
61+
{
62+
$n = new self();
63+
foreach ((array)$decoded as $k => $v) {
64+
$n->{$k} = $v;
65+
}
66+
return $n;
67+
}
68+
69+
public function jsonSerialize(): \stdClass
70+
{
71+
$out = $this->_startJsonSerialize();
72+
$out->Authorized = $this->Authorized;
73+
$out->Reason = $this->Reason;
74+
return $out;
75+
}
76+
}
77+

0 commit comments

Comments
 (0)