Skip to content

Commit 3b2e565

Browse files
committed
more work.
1 parent fc4176b commit 3b2e565

2 files changed

Lines changed: 164 additions & 4 deletions

File tree

src/ConfigEntry/MeshConfigEntry.php

Lines changed: 100 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MeshConfigEntry extends AbstractModel implements ConfigEntry
2828
use ConfigEntryTrait;
2929

3030
public string $Partition;
31-
public TransparentProxyConfig $TransparentProxy;
31+
public TransparentProxyMeshConfig $TransparentProxy;
3232
public bool $AllowEnablingPermissiveMutualTLS;
3333
public null|MeshTLSConfig $TLS;
3434
public null|MeshHTTPConfig $HTTP;
@@ -38,7 +38,7 @@ public function __construct(
3838
null|array $data = null, // Deprecated, will be removed.
3939
string $Partition = '',
4040
string $Namespace = '',
41-
null|TransparentProxyConfig $TransparentProxy = null,
41+
null|TransparentProxyMeshConfig $TransparentProxy = null,
4242
bool $AllowEnablingPermissiveMutualTLS = false,
4343
null|MeshTLSConfig $TLS = null,
4444
null|MeshHTTPConfig $HTTP = null,
@@ -73,14 +73,110 @@ public function getName(): string
7373
return Consul::MeshConfigMesh;
7474
}
7575

76-
public function getTransparentProxy(): TransparentProxyConfig
76+
public function getTransparentProxy(): TransparentProxyMeshConfig
7777
{
7878
return $this->TransparentProxy;
7979
}
8080

81-
public function setTransparentProxy(TransparentProxyConfig $TransparentProxy): self
81+
public function setTransparentProxy(TransparentProxyMeshConfig $TransparentProxy): self
8282
{
8383
$this->TransparentProxy = $TransparentProxy;
8484
return $this;
8585
}
86+
87+
public function isAllowEnablingPermissiveMutualTLS(): bool
88+
{
89+
return $this->AllowEnablingPermissiveMutualTLS;
90+
}
91+
92+
public function setAllowEnablingPermissiveMutualTLS(bool $AllowEnablingPermissiveMutualTLS): self
93+
{
94+
$this->AllowEnablingPermissiveMutualTLS = $AllowEnablingPermissiveMutualTLS;
95+
return $this;
96+
}
97+
98+
public function getTLS(): null|MeshTLSConfig
99+
{
100+
return $this->TLS;
101+
}
102+
103+
public function setTLS(null|MeshTLSConfig $TLS): self
104+
{
105+
$this->TLS = $TLS;
106+
return $this;
107+
}
108+
109+
public function getHTTP(): null|MeshHTTPConfig
110+
{
111+
return $this->HTTP;
112+
}
113+
114+
public function setHTTP(null|MeshHTTPConfig $HTTP): self
115+
{
116+
$this->HTTP = $HTTP;
117+
return $this;
118+
}
119+
120+
public function getPeering(): null|PeeringMeshConfig
121+
{
122+
return $this->Peering;
123+
}
124+
125+
public function setPeering(null|PeeringMeshConfig $Peering): self
126+
{
127+
$this->Peering = $Peering;
128+
return $this;
129+
}
130+
131+
public static function jsonUnserialize(\stdClass $decoded, null|self $n = null): self
132+
{
133+
$n = $n ?? new self();
134+
foreach ($decoded as $k => $v) {
135+
if ('TransparentProxy' === $k || 'transparent_proxy' === $k) {
136+
$n->TransparentProxy = null === $v ? new TransparentProxyMeshConfig() : TransparentProxyMeshConfig::jsonUnserialize($v);
137+
} elseif ('TLS' === $k) {
138+
$n->TLS = null === $v ? null : MeshTLSConfig::jsonUnserialize($v);
139+
} elseif ('HTTP' === $k) {
140+
$n->HTTP = null === $v ? null : MeshHTTPConfig::jsonUnserialize($v);
141+
} elseif ('Peering' === $k) {
142+
$n->Peering = null === $v ? null : PeeringMeshConfig::jsonUnserialize($v);
143+
} elseif ('allow_enabling_permissive_mutual_tls' === $k) {
144+
$n->AllowEnablingPermissiveMutualTLS = $v;
145+
} else {
146+
$n->{$k} = $v;
147+
}
148+
}
149+
return $n;
150+
}
151+
152+
public function jsonSerialize(): \stdClass
153+
{
154+
$out = new \stdClass();
155+
foreach ($this->_getDynamicFields() as $k => $v) {
156+
$out->{$k} = $v;
157+
}
158+
$out->Kind = Consul::MeshConfigMesh;
159+
if ('' !== $this->Partition) {
160+
$out->Partition = $this->Partition;
161+
}
162+
$out->TransparentProxy = $this->TransparentProxy;
163+
if ($this->AllowEnablingPermissiveMutualTLS) {
164+
$out->allow_enabling_permissive_mutual_tls = true;
165+
}
166+
if (null !== $this->TLS) {
167+
$out->TLS = $this->TLS;
168+
}
169+
if (null !== $this->HTTP) {
170+
$out->HTTP = $this->HTTP;
171+
}
172+
if (null !== $this->Peering) {
173+
$out->Peering = $this->Peering;
174+
}
175+
if (null !== $this->Meta) {
176+
$out->Meta = $this->Meta;
177+
}
178+
$out->CreateIndex = $this->CreateIndex;
179+
$out->ModifyIndex = $this->ModifyIndex;
180+
return $out;
181+
}
86182
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DCarbone\PHPConsulAPI\ConfigEntry;
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\AbstractModel;
24+
25+
class TransparentProxyMeshConfig extends AbstractModel
26+
{
27+
public bool $MeshDestinationsOnly;
28+
29+
public function __construct(bool $MeshDestinationsOnly = false)
30+
{
31+
$this->MeshDestinationsOnly = $MeshDestinationsOnly;
32+
}
33+
34+
public function isMeshDestinationsOnly(): bool
35+
{
36+
return $this->MeshDestinationsOnly;
37+
}
38+
39+
public function setMeshDestinationsOnly(bool $MeshDestinationsOnly): self
40+
{
41+
$this->MeshDestinationsOnly = $MeshDestinationsOnly;
42+
return $this;
43+
}
44+
45+
public static function jsonUnserialize(\stdClass $decoded): self
46+
{
47+
$n = new self();
48+
foreach ($decoded as $k => $v) {
49+
if ('mesh_destinations_only' === $k) {
50+
$n->MeshDestinationsOnly = $v;
51+
} else {
52+
$n->{$k} = $v;
53+
}
54+
}
55+
return $n;
56+
}
57+
58+
public function jsonSerialize(): \stdClass
59+
{
60+
$o = new \stdClass();
61+
$o->MeshDestinationsOnly = $this->MeshDestinationsOnly;
62+
return $o;
63+
}
64+
}

0 commit comments

Comments
 (0)