1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
7
|
|
|
use AcquiaCloudApi\Response\LogForwardingDestinationsResponse; |
8
|
|
|
use AcquiaCloudApi\Response\LogForwardingDestinationResponse; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class Client |
12
|
|
|
* @package AcquiaCloudApi\CloudApi |
13
|
|
|
*/ |
14
|
|
|
class LogForwardingDestinations implements CloudApi |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** @var ClientInterface The API client. */ |
18
|
|
|
protected $client; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Client constructor. |
22
|
|
|
* |
23
|
|
|
* @param ClientInterface $client |
24
|
|
|
*/ |
25
|
|
|
public function __construct(ClientInterface $client) |
26
|
|
|
{ |
27
|
|
|
$this->client = $client; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Returns a list of log forwarding destinations. |
32
|
|
|
* |
33
|
|
|
* @param string $environmentUuid The environment ID |
34
|
|
|
* @return LogForwardingDestinationsResponse |
35
|
|
|
*/ |
36
|
|
|
public function getAll($environmentUuid) |
37
|
|
|
{ |
38
|
|
|
return new LogForwardingDestinationsResponse( |
39
|
|
|
$this->client->request( |
|
|
|
|
40
|
|
|
'get', |
41
|
|
|
"/environments/${environmentUuid}/log-forwarding-destinations" |
42
|
|
|
) |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Returns a specific log forwarding destination. |
48
|
|
|
* |
49
|
|
|
* @param string $environmentUuid The environment ID |
50
|
|
|
* @param int $destinationId |
51
|
|
|
* @return LogForwardingDestinationResponse |
52
|
|
|
*/ |
53
|
|
|
public function get($environmentUuid, $destinationId) |
54
|
|
|
{ |
55
|
|
|
return new LogForwardingDestinationResponse( |
56
|
|
|
$this->client->request( |
|
|
|
|
57
|
|
|
'get', |
58
|
|
|
"/environments/${environmentUuid}/log-forwarding-destinations/${destinationId}" |
59
|
|
|
) |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Creates a log forwarding destination. |
65
|
|
|
* |
66
|
|
|
* @param string $environmentUuid |
67
|
|
|
* @param string $label |
68
|
|
|
* @param array $sources |
69
|
|
|
* @param string $consumer |
70
|
|
|
* @param array $credentials |
71
|
|
|
* @param string $address |
72
|
|
|
* @return OperationResponse |
73
|
|
|
*/ |
74
|
|
|
public function create($environmentUuid, $label, $sources, $consumer, $credentials, $address) |
75
|
|
|
{ |
76
|
|
|
|
77
|
|
|
$options = [ |
78
|
|
|
'form_params' => [ |
79
|
|
|
'label' => $label, |
80
|
|
|
'sources' => $sources, |
81
|
|
|
'consumer' => $consumer, |
82
|
|
|
'credentials' => $credentials, |
83
|
|
|
'address' => $address |
84
|
|
|
], |
85
|
|
|
]; |
86
|
|
|
|
87
|
|
|
return new OperationResponse( |
88
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options) |
|
|
|
|
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Delete a specific log forwarding destination. |
94
|
|
|
* |
95
|
|
|
* @param string $environmentUuid |
96
|
|
|
* @param int $destId |
97
|
|
|
* @return OperationResponse |
98
|
|
|
*/ |
99
|
|
|
public function delete($environmentUuid, $destId) |
100
|
|
|
{ |
101
|
|
|
return new OperationResponse( |
102
|
|
|
$this->client->request('delete', "/environments/${environmentUuid}/log-forwarding-destinations/${destId}") |
|
|
|
|
103
|
|
|
); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Disables a log forwarding destination. |
108
|
|
|
* |
109
|
|
|
* @param string $environmentUuid |
110
|
|
|
* @param int $destId |
111
|
|
|
* @return OperationResponse |
112
|
|
|
*/ |
113
|
|
|
public function disable($environmentUuid, $destId) |
114
|
|
|
{ |
115
|
|
|
return new OperationResponse( |
116
|
|
|
$this->client->request( |
|
|
|
|
117
|
|
|
'post', |
118
|
|
|
"/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/disable" |
119
|
|
|
) |
120
|
|
|
); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Disables a log forwarding destination. |
125
|
|
|
* |
126
|
|
|
* @param string $environmentUuid |
127
|
|
|
* @param int $destId |
128
|
|
|
* @return OperationResponse |
129
|
|
|
*/ |
130
|
|
|
public function enable($environmentUuid, $destId) |
131
|
|
|
{ |
132
|
|
|
return new OperationResponse( |
133
|
|
|
$this->client->request( |
|
|
|
|
134
|
|
|
'post', |
135
|
|
|
"/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/enable" |
136
|
|
|
) |
137
|
|
|
); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Updates a log forwarding destination. |
142
|
|
|
* |
143
|
|
|
* @param string $environmentUuid |
144
|
|
|
* @param int $destId |
145
|
|
|
* @param string $label |
146
|
|
|
* @param array $sources |
147
|
|
|
* @param string $consumer |
148
|
|
|
* @param array $creds |
149
|
|
|
* @param string $address |
150
|
|
|
* @return OperationResponse |
151
|
|
|
*/ |
152
|
|
|
public function update($environmentUuid, $destId, $label, $sources, $consumer, $creds, $address) |
153
|
|
|
{ |
154
|
|
|
|
155
|
|
|
$options = [ |
156
|
|
|
'form_params' => [ |
157
|
|
|
'label' => $label, |
158
|
|
|
'sources' => $sources, |
159
|
|
|
'consumer' => $consumer, |
160
|
|
|
'credentials' => $creds, |
161
|
|
|
'address' => $address |
162
|
|
|
], |
163
|
|
|
]; |
164
|
|
|
|
165
|
|
|
return new OperationResponse( |
166
|
|
|
$this->client->request( |
|
|
|
|
167
|
|
|
'put', |
168
|
|
|
"/environments/${environmentUuid}/log-forwarding-destinations/${destId}", |
169
|
|
|
$options |
170
|
|
|
) |
171
|
|
|
); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|