forked from dcarbone/php-consul-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Consul.php
203 lines (176 loc) · 6.08 KB
/
Consul.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php namespace DCarbone\PHPConsulAPI;
/*
Copyright 2016-2018 Daniel Carbone ([email protected])
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
use DCarbone\PHPConsulAPI\ACL\ACLClient;
use DCarbone\PHPConsulAPI\Agent\AgentClient;
use DCarbone\PHPConsulAPI\Catalog\CatalogClient;
use DCarbone\PHPConsulAPI\Coordinate\CoordinateClient;
use DCarbone\PHPConsulAPI\Event\EventClient;
use DCarbone\PHPConsulAPI\Health\HealthClient;
use DCarbone\PHPConsulAPI\KV\KVClient;
use DCarbone\PHPConsulAPI\Operator\OperatorClient;
use DCarbone\PHPConsulAPI\PreparedQuery\PreparedQueryClient;
use DCarbone\PHPConsulAPI\Session\SessionClient;
use DCarbone\PHPConsulAPI\Status\StatusClient;
/**
* Class Consul
* @package DCarbone\PHPConsulAPI
*/
class Consul {
const HTTPAddrEnvName = 'CONSUL_HTTP_ADDR';
const HTTPTokenEnvName = 'CONSUL_HTTP_TOKEN';
const HTTPAuthEnvName = 'CONSUL_HTTP_AUTH';
const HTTPCAFileEnvName = "CONSUL_CACERT";
const HTTPClientCertEnvName = "CONSUL_CLIENT_CERT";
const HTTPClientKeyEnvName = "CONSUL_CLIENT_KEY";
const HTTPSSLEnvName = 'CONSUL_HTTP_SSL';
const HTTPSSLVerifyEnvName = 'CONSUL_HTTP_SSL_VERIFY';
const HealthAny = 'any';
const HealthPassing = 'passing';
const HealthWarning = 'warning';
const HealthCritical = 'critical';
const HealthMaint = 'maintenance';
const NodeMaint = '_node_maintenance';
const ServiceMaintPrefix = '_service_maintenance';
const AllSegments = '_all';
const KVSet = 'set';
const KVDelete = 'delete';
const KVDeleteCAS = 'delete-cas';
const KVDeleteTree = 'delete-tree';
const KVCAS = 'cas';
const KVLock = 'lock';
const KVUnlock = 'unlock';
const KVGet = 'get';
const KVGetTree = 'get-tree';
const KVCheckSession = 'check-session';
const KVCheckIndex = 'check-index';
const KVCheckNotExists = 'check-not-exists';
const SessionBehaviorRelease = 'release';
const SessionBehaviorDelete = 'delete';
/** @var \DCarbone\PHPConsulAPI\ACL\ACLClient */
public $ACL;
/** @var \DCarbone\PHPConsulAPI\Agent\AgentClient */
public $Agent;
/** @var \DCarbone\PHPConsulAPI\Catalog\CatalogClient */
public $Catalog;
/** @var \DCarbone\PHPConsulAPI\Coordinate\CoordinateClient */
public $Coordinate;
/** @var \DCarbone\PHPConsulAPI\Event\EventClient */
public $Event;
/** @var \DCarbone\PHPConsulAPI\Health\HealthClient */
public $Health;
/** @var \DCarbone\PHPConsulAPI\KV\KVClient */
public $KV;
/** @var \DCarbone\PHPConsulAPI\Operator\OperatorClient */
public $Operator;
/** @var \DCarbone\PHPConsulAPI\PreparedQuery\PreparedQueryClient */
public $PreparedQuery;
/** @var \DCarbone\PHPConsulAPI\Session\SessionClient */
public $Session;
/** @var \DCarbone\PHPConsulAPI\Status\StatusClient */
public $Status;
/**
* Client constructor.
* @param Config $config
*/
public function __construct(Config $config = null) {
if (null === $config) {
$config = Config::newDefaultConfig();
} else {
$def = Config::newDefaultConfig();
if ('' === $config->getAddress()) {
$config->setAddress($def->getAddress());
}
if ('' === $config->getScheme()) {
$config->setScheme($def->getScheme());
}
}
$this->ACL = new ACLClient($config);
$this->Agent = new AgentClient($config);
$this->Catalog = new CatalogClient($config);
$this->Coordinate = new CoordinateClient($config);
$this->Event = new EventClient($config);
$this->Health = new HealthClient($config);
$this->KV = new KVClient($config);
$this->Operator = new OperatorClient($config);
$this->PreparedQuery = new PreparedQueryClient($config);
$this->Session = new SessionClient($config);
$this->Status = new StatusClient($config);
}
/**
* @return \DCarbone\PHPConsulAPI\ACL\ACLClient
*/
public function ACL(): ACLClient {
return $this->ACL;
}
/**
* @return \DCarbone\PHPConsulAPI\Agent\AgentClient
*/
public function Agent(): AgentClient {
return $this->Agent;
}
/**
* @return \DCarbone\PHPConsulAPI\Catalog\CatalogClient
*/
public function Catalog(): CatalogClient {
return $this->Catalog;
}
/**
* @return \DCarbone\PHPConsulAPI\Coordinate\CoordinateClient
*/
public function Coordinate(): CoordinateClient {
return $this->Coordinate;
}
/**
* @return \DCarbone\PHPConsulAPI\Event\EventClient
*/
public function Event(): EventClient {
return $this->Event;
}
/**
* @return \DCarbone\PHPConsulAPI\Health\HealthClient
*/
public function Health(): HealthClient {
return $this->Health;
}
/**
* @return \DCarbone\PHPConsulAPI\KV\KVClient
*/
public function KV(): KVClient {
return $this->KV;
}
/**
* @return \DCarbone\PHPConsulAPI\Operator\OperatorClient
*/
public function Operator(): OperatorClient {
return $this->Operator;
}
/**
* @return \DCarbone\PHPConsulAPI\PreparedQuery\PreparedQueryClient
*/
public function PreparedQuery(): PreparedQueryClient {
return $this->PreparedQuery;
}
/**
* @return \DCarbone\PHPConsulAPI\Session\SessionClient
*/
public function Session(): SessionClient {
return $this->Session;
}
/**
* @return \DCarbone\PHPConsulAPI\Status\StatusClient
*/
public function Status(): StatusClient {
return $this->Status;
}
}