2121 */
2222
2323use DCarbone \PHPConsulAPI \AbstractModel ;
24- use DCarbone \PHPConsulAPI \FakeMap ;
25- use DCarbone \PHPConsulAPI \Transcoding ;
24+ use DCarbone \PHPConsulAPI \Consul ;
2625
2726class ProxyConfigEntry extends AbstractModel implements ConfigEntry
2827{
2928 use ConfigEntryTrait;
3029
31- protected const FIELDS = ConfigEntry::INTERFACE_FIELDS + [
32- self ::FIELD_MODE => Transcoding::OMITEMPTY_STRING_FIELD ,
33- self ::FIELD_CONFIG => Transcoding::MAP_FIELD ,
34- self ::FIELD_TRANSPARENT_PROXY => [
35- Transcoding::FIELD_TYPE => Transcoding::OBJECT ,
36- Transcoding::FIELD_CLASS => TransparentProxyConfig::class,
37- Transcoding::FIELD_NULLABLE => true ,
38- Transcoding::FIELD_OMITEMPTY => true ,
39- ],
40- self ::FIELD_MESH_GATEWAY => [
41- Transcoding::FIELD_TYPE => Transcoding::OBJECT ,
42- Transcoding::FIELD_CLASS => MeshGatewayConfig::class,
43- Transcoding::FIELD_OMITEMPTY => true , // todo: does nothing as field is not nullable..
44- ],
45- self ::FIELD_EXPOSE => [
46- Transcoding::FIELD_TYPE => Transcoding::OBJECT ,
47- Transcoding::FIELD_CLASS => ExposeConfig::class,
48- Transcoding::FIELD_OMITEMPTY => true , // todo: does nothing as field is not nullable,
49- ],
50- ];
51-
52- private const FIELD_MODE = 'Mode ' ;
53- private const FIELD_TRANSPARENT_PROXY = 'TransparentProxy ' ;
54- private const FIELD_CONFIG = 'Config ' ;
55- private const FIELD_MESH_GATEWAY = 'MeshGateway ' ;
56- private const FIELD_EXPOSE = 'Expose ' ;
57-
58- public string $ Mode ;
59- public ?TransparentProxyConfig $ TransparentProxy = null ;
60- public ?FakeMap $ Config = null ;
30+ public string $ Kind ;
31+ public string $ Name ;
32+ public string $ Partition ;
33+ public null |ProxyMode $ Mode ;
34+ public null |TransparentProxyConfig $ TransparentProxy ;
35+ public MutualTLSMode $ MutualTLSMode ;
36+ public null |\stdClass $ Config ;
37+
6138 public MeshGatewayConfig $ MeshGateway ;
6239 public ExposeConfig $ Expose ;
40+ public null |AccessLogsConfig $ AccessLogs ;
41+ /** @var array<\DCarbone\PHPConsulAPI\ConfigEntry\EnvoyExtension> */
42+ public array $ EnvoyExtensions ;
43+ public null |ServiceResolverFailoverPolicy $ FailoverPolicy ;
44+ public null |ServiceResolverPrioritizeByLocality $ PrioritizeByLocality ;
45+
46+ public function __construct (
47+ array |null $ data = null , // Deprecated, will be removed.
48+ string $ Kind = '' ,
49+ string $ Name = '' ,
50+ string $ Partition = '' ,
51+ string |ProxyMode $ Mode = ProxyMode::Default,
52+ null |TransparentProxyConfig $ TransparentProxy = null ,
53+ string |MutualTLSMode $ MutualTLSMode = MutualTLSMode::Default,
54+ null |\stdClass $ Config = null ,
55+ null |MeshGatewayConfig $ MeshGateway = null ,
56+ null |ExposeConfig $ Expose = null ,
57+ null |AccessLogsConfig $ AccessLogs = null ,
58+ array $ EnvoyExtensions = [],
59+ null |ServiceResolverFailoverPolicy $ FailoverPolicy = null ,
60+ null |ServiceResolverPrioritizeByLocality $ PrioritizeByLocality = null ,
61+ string $ Namespace = '' ,
62+ null |\stdClass $ Meta = null ,
63+ int $ CreateIndex = 0 ,
64+ int $ ModifyIndex = 0 ,
65+ ) {
66+ {
67+ $ this ->Kind = $ Kind ;
68+ $ this ->Name = $ Name ;
69+ $ this ->Partition = $ Partition ;
70+ $ this ->Namespace = $ Namespace ;
71+ $ this ->Mode = $ Mode instanceof ProxyMode ? $ Mode : ProxyMode::from ($ Mode );
72+ $ this ->TransparentProxy = $ TransparentProxy ;
73+ $ this ->MutualTLSMode = $ MutualTLSMode instanceof MutualTLSMode ? $ MutualTLSMode : MutualTLSMode::from ($ MutualTLSMode );
74+ $ this ->Config = $ Config ;
75+ $ this ->MeshGateway = $ MeshGateway ?? new MeshGatewayConfig ();
76+ $ this ->Expose = $ Expose ?? new ExposeConfig ();
77+ $ this ->AccessLogs = $ AccessLogs ;
78+ $ this ->EnvoyExtensions = $ this ->setEnvoyExtensions (...$ EnvoyExtensions );
79+ $ this ->FailoverPolicy = $ FailoverPolicy ;
80+ $ this ->PrioritizeByLocality = $ PrioritizeByLocality ;
81+ $ this ->Meta = $ Meta ;
82+ $ this ->CreateIndex = $ CreateIndex ;
83+ $ this ->ModifyIndex = $ ModifyIndex ;
84+
85+ if (null !== $ data && [] !== $ data ) {
86+ self ::jsonUnserialize ((object )$ data , $ this );
87+ }
88+ }
89+ }
90+
91+ public function getKind (): string
92+ {
93+ return $ this ->Kind ;
94+ }
95+
96+ public function setKind (string $ Kind ): self
97+ {
98+ $ this ->Kind = $ Kind ;
99+ return $ this ;
100+ }
101+
102+ public function getName (): string
103+ {
104+ return Consul::ProxyConfigGlobal;
105+ }
106+
107+ public function setName (string $ Name ): self
108+ {
109+ $ this ->Name = $ Name ;
110+ return $ this ;
111+ }
63112
64- public function getMode (): string
113+ public function getPartition (): string
114+ {
115+ return $ this ->Partition ;
116+ }
117+
118+ public function setPartition (string $ Partition ): self
119+ {
120+ $ this ->Partition = $ Partition ;
121+ return $ this ;
122+ }
123+
124+ public function getMode (): ProxyMode
65125 {
66126 return $ this ->Mode ;
67127 }
68128
69- public function setMode (string $ Mode ): self
129+ public function setMode (ProxyMode $ Mode ): self
70130 {
71131 $ this ->Mode = $ Mode ;
72132 return $ this ;
73133 }
74134
75- public function getTransparentProxy (): ? TransparentProxyConfig
135+ public function getTransparentProxy (): null | TransparentProxyConfig
76136 {
77137 return $ this ->TransparentProxy ;
78138 }
79139
80- public function setTransparentProxy (? TransparentProxyConfig $ TransparentProxy ): self
140+ public function setTransparentProxy (null | TransparentProxyConfig $ TransparentProxy ): self
81141 {
82142 $ this ->TransparentProxy = $ TransparentProxy ;
83143 return $ this ;
84144 }
85145
86- public function getConfig (): ?FakeMap
146+ public function getMutualTLSMode (): MutualTLSMode
147+ {
148+ return $ this ->MutualTLSMode ;
149+ }
150+
151+ public function setMutualTLSMode (MutualTLSMode $ MutualTLSMode ): self
152+ {
153+ $ this ->MutualTLSMode = $ MutualTLSMode ;
154+ return $ this ;
155+ }
156+
157+ public function getConfig (): null |\stdClass
87158 {
88159 return $ this ->Config ;
89160 }
90161
91- public function setConfig (mixed $ Config ): self
162+ public function setConfig (null | \ stdClass $ Config ): self
92163 {
93- $ this ->Config = FakeMap:: parse ( $ Config) ;
164+ $ this ->Config = $ Config ;
94165 return $ this ;
95166 }
96167
@@ -115,4 +186,70 @@ public function setExpose(ExposeConfig $Expose): self
115186 $ this ->Expose = $ Expose ;
116187 return $ this ;
117188 }
189+
190+ public function getAccessLogs (): null |AccessLogsConfig
191+ {
192+ return $ this ->AccessLogs ;
193+ }
194+
195+ public function setAccessLogs (null |AccessLogsConfig $ AccessLogs ): self
196+ {
197+ $ this ->AccessLogs = $ AccessLogs ;
198+ return $ this ;
199+ }
200+
201+ /**
202+ * @return array<\DCarbone\PHPConsulAPI\ConfigEntry\EnvoyExtension>
203+ */
204+ public function getEnvoyExtensions (): array
205+ {
206+ return $ this ->EnvoyExtensions ;
207+ }
208+
209+ /**
210+ * @param \DCarbone\PHPConsulAPI\ConfigEntry\EnvoyExtension ...$EnvoyExtensions
211+ */
212+ public function setEnvoyExtensions (EnvoyExtension ...$ EnvoyExtensions ): self
213+ {
214+ $ this ->EnvoyExtensions = $ EnvoyExtensions ;
215+ return $ this ;
216+ }
217+
218+ public function getFailoverPolicy (): null |ServiceResolverFailoverPolicy
219+ {
220+ return $ this ->FailoverPolicy ;
221+ }
222+
223+ public function setFailoverPolicy (null |ServiceResolverFailoverPolicy $ FailoverPolicy ): self
224+ {
225+ $ this ->FailoverPolicy = $ FailoverPolicy ;
226+ return $ this ;
227+ }
228+
229+ public function getPrioritizeByLocality (): null |ServiceResolverPrioritizeByLocality
230+ {
231+ return $ this ->PrioritizeByLocality ;
232+ }
233+
234+ public function setPrioritizeByLocality (null |ServiceResolverPrioritizeByLocality $ PrioritizeByLocality ): self
235+ {
236+ $ this ->PrioritizeByLocality = $ PrioritizeByLocality ;
237+ return $ this ;
238+ }
239+
240+ public static function jsonUnserialize (\stdClass $ decoded , null |self $ into = null ): static
241+ {
242+ $ n = $ into ?? new self ();
243+ foreach ($ decoded as $ k => $ v ) {
244+ $ n ->{$ k } = $ v ;
245+ }
246+ return $ n ;
247+ }
248+
249+ public function jsonSerialize (): \stdClass
250+ {
251+ $ out = new \stdClass ();
252+ foreach ($ this ->_getDynamicFields () as $ k => $ v ) {
253+ $ out ->{$ k } = $ v ;
254+ }
118255}
0 commit comments