| 1 |
efrain |
1 |
<?php
|
|
|
2 |
namespace Aws\CloudWatchLogs;
|
|
|
3 |
|
|
|
4 |
use Aws\AwsClient;
|
| 1441 |
ariadna |
5 |
use Aws\CommandInterface;
|
|
|
6 |
use Generator;
|
| 1 |
efrain |
7 |
|
|
|
8 |
/**
|
|
|
9 |
* This client is used to interact with the **Amazon CloudWatch Logs** service.
|
|
|
10 |
*
|
|
|
11 |
* @method \Aws\Result associateKmsKey(array $args = [])
|
|
|
12 |
* @method \GuzzleHttp\Promise\Promise associateKmsKeyAsync(array $args = [])
|
|
|
13 |
* @method \Aws\Result cancelExportTask(array $args = [])
|
|
|
14 |
* @method \GuzzleHttp\Promise\Promise cancelExportTaskAsync(array $args = [])
|
| 1441 |
ariadna |
15 |
* @method \Aws\Result createDelivery(array $args = [])
|
|
|
16 |
* @method \GuzzleHttp\Promise\Promise createDeliveryAsync(array $args = [])
|
| 1 |
efrain |
17 |
* @method \Aws\Result createExportTask(array $args = [])
|
|
|
18 |
* @method \GuzzleHttp\Promise\Promise createExportTaskAsync(array $args = [])
|
| 1441 |
ariadna |
19 |
* @method \Aws\Result createLogAnomalyDetector(array $args = [])
|
|
|
20 |
* @method \GuzzleHttp\Promise\Promise createLogAnomalyDetectorAsync(array $args = [])
|
| 1 |
efrain |
21 |
* @method \Aws\Result createLogGroup(array $args = [])
|
|
|
22 |
* @method \GuzzleHttp\Promise\Promise createLogGroupAsync(array $args = [])
|
|
|
23 |
* @method \Aws\Result createLogStream(array $args = [])
|
|
|
24 |
* @method \GuzzleHttp\Promise\Promise createLogStreamAsync(array $args = [])
|
|
|
25 |
* @method \Aws\Result deleteAccountPolicy(array $args = [])
|
|
|
26 |
* @method \GuzzleHttp\Promise\Promise deleteAccountPolicyAsync(array $args = [])
|
|
|
27 |
* @method \Aws\Result deleteDataProtectionPolicy(array $args = [])
|
|
|
28 |
* @method \GuzzleHttp\Promise\Promise deleteDataProtectionPolicyAsync(array $args = [])
|
| 1441 |
ariadna |
29 |
* @method \Aws\Result deleteDelivery(array $args = [])
|
|
|
30 |
* @method \GuzzleHttp\Promise\Promise deleteDeliveryAsync(array $args = [])
|
|
|
31 |
* @method \Aws\Result deleteDeliveryDestination(array $args = [])
|
|
|
32 |
* @method \GuzzleHttp\Promise\Promise deleteDeliveryDestinationAsync(array $args = [])
|
|
|
33 |
* @method \Aws\Result deleteDeliveryDestinationPolicy(array $args = [])
|
|
|
34 |
* @method \GuzzleHttp\Promise\Promise deleteDeliveryDestinationPolicyAsync(array $args = [])
|
|
|
35 |
* @method \Aws\Result deleteDeliverySource(array $args = [])
|
|
|
36 |
* @method \GuzzleHttp\Promise\Promise deleteDeliverySourceAsync(array $args = [])
|
| 1 |
efrain |
37 |
* @method \Aws\Result deleteDestination(array $args = [])
|
|
|
38 |
* @method \GuzzleHttp\Promise\Promise deleteDestinationAsync(array $args = [])
|
| 1441 |
ariadna |
39 |
* @method \Aws\Result deleteIndexPolicy(array $args = [])
|
|
|
40 |
* @method \GuzzleHttp\Promise\Promise deleteIndexPolicyAsync(array $args = [])
|
|
|
41 |
* @method \Aws\Result deleteIntegration(array $args = [])
|
|
|
42 |
* @method \GuzzleHttp\Promise\Promise deleteIntegrationAsync(array $args = [])
|
|
|
43 |
* @method \Aws\Result deleteLogAnomalyDetector(array $args = [])
|
|
|
44 |
* @method \GuzzleHttp\Promise\Promise deleteLogAnomalyDetectorAsync(array $args = [])
|
| 1 |
efrain |
45 |
* @method \Aws\Result deleteLogGroup(array $args = [])
|
|
|
46 |
* @method \GuzzleHttp\Promise\Promise deleteLogGroupAsync(array $args = [])
|
|
|
47 |
* @method \Aws\Result deleteLogStream(array $args = [])
|
|
|
48 |
* @method \GuzzleHttp\Promise\Promise deleteLogStreamAsync(array $args = [])
|
|
|
49 |
* @method \Aws\Result deleteMetricFilter(array $args = [])
|
|
|
50 |
* @method \GuzzleHttp\Promise\Promise deleteMetricFilterAsync(array $args = [])
|
|
|
51 |
* @method \Aws\Result deleteQueryDefinition(array $args = [])
|
|
|
52 |
* @method \GuzzleHttp\Promise\Promise deleteQueryDefinitionAsync(array $args = [])
|
|
|
53 |
* @method \Aws\Result deleteResourcePolicy(array $args = [])
|
|
|
54 |
* @method \GuzzleHttp\Promise\Promise deleteResourcePolicyAsync(array $args = [])
|
|
|
55 |
* @method \Aws\Result deleteRetentionPolicy(array $args = [])
|
|
|
56 |
* @method \GuzzleHttp\Promise\Promise deleteRetentionPolicyAsync(array $args = [])
|
|
|
57 |
* @method \Aws\Result deleteSubscriptionFilter(array $args = [])
|
|
|
58 |
* @method \GuzzleHttp\Promise\Promise deleteSubscriptionFilterAsync(array $args = [])
|
| 1441 |
ariadna |
59 |
* @method \Aws\Result deleteTransformer(array $args = [])
|
|
|
60 |
* @method \GuzzleHttp\Promise\Promise deleteTransformerAsync(array $args = [])
|
| 1 |
efrain |
61 |
* @method \Aws\Result describeAccountPolicies(array $args = [])
|
|
|
62 |
* @method \GuzzleHttp\Promise\Promise describeAccountPoliciesAsync(array $args = [])
|
| 1441 |
ariadna |
63 |
* @method \Aws\Result describeConfigurationTemplates(array $args = [])
|
|
|
64 |
* @method \GuzzleHttp\Promise\Promise describeConfigurationTemplatesAsync(array $args = [])
|
|
|
65 |
* @method \Aws\Result describeDeliveries(array $args = [])
|
|
|
66 |
* @method \GuzzleHttp\Promise\Promise describeDeliveriesAsync(array $args = [])
|
|
|
67 |
* @method \Aws\Result describeDeliveryDestinations(array $args = [])
|
|
|
68 |
* @method \GuzzleHttp\Promise\Promise describeDeliveryDestinationsAsync(array $args = [])
|
|
|
69 |
* @method \Aws\Result describeDeliverySources(array $args = [])
|
|
|
70 |
* @method \GuzzleHttp\Promise\Promise describeDeliverySourcesAsync(array $args = [])
|
| 1 |
efrain |
71 |
* @method \Aws\Result describeDestinations(array $args = [])
|
|
|
72 |
* @method \GuzzleHttp\Promise\Promise describeDestinationsAsync(array $args = [])
|
|
|
73 |
* @method \Aws\Result describeExportTasks(array $args = [])
|
|
|
74 |
* @method \GuzzleHttp\Promise\Promise describeExportTasksAsync(array $args = [])
|
| 1441 |
ariadna |
75 |
* @method \Aws\Result describeFieldIndexes(array $args = [])
|
|
|
76 |
* @method \GuzzleHttp\Promise\Promise describeFieldIndexesAsync(array $args = [])
|
|
|
77 |
* @method \Aws\Result describeIndexPolicies(array $args = [])
|
|
|
78 |
* @method \GuzzleHttp\Promise\Promise describeIndexPoliciesAsync(array $args = [])
|
| 1 |
efrain |
79 |
* @method \Aws\Result describeLogGroups(array $args = [])
|
|
|
80 |
* @method \GuzzleHttp\Promise\Promise describeLogGroupsAsync(array $args = [])
|
|
|
81 |
* @method \Aws\Result describeLogStreams(array $args = [])
|
|
|
82 |
* @method \GuzzleHttp\Promise\Promise describeLogStreamsAsync(array $args = [])
|
|
|
83 |
* @method \Aws\Result describeMetricFilters(array $args = [])
|
|
|
84 |
* @method \GuzzleHttp\Promise\Promise describeMetricFiltersAsync(array $args = [])
|
|
|
85 |
* @method \Aws\Result describeQueries(array $args = [])
|
|
|
86 |
* @method \GuzzleHttp\Promise\Promise describeQueriesAsync(array $args = [])
|
|
|
87 |
* @method \Aws\Result describeQueryDefinitions(array $args = [])
|
|
|
88 |
* @method \GuzzleHttp\Promise\Promise describeQueryDefinitionsAsync(array $args = [])
|
|
|
89 |
* @method \Aws\Result describeResourcePolicies(array $args = [])
|
|
|
90 |
* @method \GuzzleHttp\Promise\Promise describeResourcePoliciesAsync(array $args = [])
|
|
|
91 |
* @method \Aws\Result describeSubscriptionFilters(array $args = [])
|
|
|
92 |
* @method \GuzzleHttp\Promise\Promise describeSubscriptionFiltersAsync(array $args = [])
|
|
|
93 |
* @method \Aws\Result disassociateKmsKey(array $args = [])
|
|
|
94 |
* @method \GuzzleHttp\Promise\Promise disassociateKmsKeyAsync(array $args = [])
|
|
|
95 |
* @method \Aws\Result filterLogEvents(array $args = [])
|
|
|
96 |
* @method \GuzzleHttp\Promise\Promise filterLogEventsAsync(array $args = [])
|
|
|
97 |
* @method \Aws\Result getDataProtectionPolicy(array $args = [])
|
|
|
98 |
* @method \GuzzleHttp\Promise\Promise getDataProtectionPolicyAsync(array $args = [])
|
| 1441 |
ariadna |
99 |
* @method \Aws\Result getDelivery(array $args = [])
|
|
|
100 |
* @method \GuzzleHttp\Promise\Promise getDeliveryAsync(array $args = [])
|
|
|
101 |
* @method \Aws\Result getDeliveryDestination(array $args = [])
|
|
|
102 |
* @method \GuzzleHttp\Promise\Promise getDeliveryDestinationAsync(array $args = [])
|
|
|
103 |
* @method \Aws\Result getDeliveryDestinationPolicy(array $args = [])
|
|
|
104 |
* @method \GuzzleHttp\Promise\Promise getDeliveryDestinationPolicyAsync(array $args = [])
|
|
|
105 |
* @method \Aws\Result getDeliverySource(array $args = [])
|
|
|
106 |
* @method \GuzzleHttp\Promise\Promise getDeliverySourceAsync(array $args = [])
|
|
|
107 |
* @method \Aws\Result getIntegration(array $args = [])
|
|
|
108 |
* @method \GuzzleHttp\Promise\Promise getIntegrationAsync(array $args = [])
|
|
|
109 |
* @method \Aws\Result getLogAnomalyDetector(array $args = [])
|
|
|
110 |
* @method \GuzzleHttp\Promise\Promise getLogAnomalyDetectorAsync(array $args = [])
|
| 1 |
efrain |
111 |
* @method \Aws\Result getLogEvents(array $args = [])
|
|
|
112 |
* @method \GuzzleHttp\Promise\Promise getLogEventsAsync(array $args = [])
|
|
|
113 |
* @method \Aws\Result getLogGroupFields(array $args = [])
|
|
|
114 |
* @method \GuzzleHttp\Promise\Promise getLogGroupFieldsAsync(array $args = [])
|
|
|
115 |
* @method \Aws\Result getLogRecord(array $args = [])
|
|
|
116 |
* @method \GuzzleHttp\Promise\Promise getLogRecordAsync(array $args = [])
|
|
|
117 |
* @method \Aws\Result getQueryResults(array $args = [])
|
|
|
118 |
* @method \GuzzleHttp\Promise\Promise getQueryResultsAsync(array $args = [])
|
| 1441 |
ariadna |
119 |
* @method \Aws\Result getTransformer(array $args = [])
|
|
|
120 |
* @method \GuzzleHttp\Promise\Promise getTransformerAsync(array $args = [])
|
|
|
121 |
* @method \Aws\Result listAnomalies(array $args = [])
|
|
|
122 |
* @method \GuzzleHttp\Promise\Promise listAnomaliesAsync(array $args = [])
|
|
|
123 |
* @method \Aws\Result listIntegrations(array $args = [])
|
|
|
124 |
* @method \GuzzleHttp\Promise\Promise listIntegrationsAsync(array $args = [])
|
|
|
125 |
* @method \Aws\Result listLogAnomalyDetectors(array $args = [])
|
|
|
126 |
* @method \GuzzleHttp\Promise\Promise listLogAnomalyDetectorsAsync(array $args = [])
|
|
|
127 |
* @method \Aws\Result listLogGroupsForQuery(array $args = [])
|
|
|
128 |
* @method \GuzzleHttp\Promise\Promise listLogGroupsForQueryAsync(array $args = [])
|
| 1 |
efrain |
129 |
* @method \Aws\Result listTagsForResource(array $args = [])
|
|
|
130 |
* @method \GuzzleHttp\Promise\Promise listTagsForResourceAsync(array $args = [])
|
|
|
131 |
* @method \Aws\Result listTagsLogGroup(array $args = [])
|
|
|
132 |
* @method \GuzzleHttp\Promise\Promise listTagsLogGroupAsync(array $args = [])
|
|
|
133 |
* @method \Aws\Result putAccountPolicy(array $args = [])
|
|
|
134 |
* @method \GuzzleHttp\Promise\Promise putAccountPolicyAsync(array $args = [])
|
|
|
135 |
* @method \Aws\Result putDataProtectionPolicy(array $args = [])
|
|
|
136 |
* @method \GuzzleHttp\Promise\Promise putDataProtectionPolicyAsync(array $args = [])
|
| 1441 |
ariadna |
137 |
* @method \Aws\Result putDeliveryDestination(array $args = [])
|
|
|
138 |
* @method \GuzzleHttp\Promise\Promise putDeliveryDestinationAsync(array $args = [])
|
|
|
139 |
* @method \Aws\Result putDeliveryDestinationPolicy(array $args = [])
|
|
|
140 |
* @method \GuzzleHttp\Promise\Promise putDeliveryDestinationPolicyAsync(array $args = [])
|
|
|
141 |
* @method \Aws\Result putDeliverySource(array $args = [])
|
|
|
142 |
* @method \GuzzleHttp\Promise\Promise putDeliverySourceAsync(array $args = [])
|
| 1 |
efrain |
143 |
* @method \Aws\Result putDestination(array $args = [])
|
|
|
144 |
* @method \GuzzleHttp\Promise\Promise putDestinationAsync(array $args = [])
|
|
|
145 |
* @method \Aws\Result putDestinationPolicy(array $args = [])
|
|
|
146 |
* @method \GuzzleHttp\Promise\Promise putDestinationPolicyAsync(array $args = [])
|
| 1441 |
ariadna |
147 |
* @method \Aws\Result putIndexPolicy(array $args = [])
|
|
|
148 |
* @method \GuzzleHttp\Promise\Promise putIndexPolicyAsync(array $args = [])
|
|
|
149 |
* @method \Aws\Result putIntegration(array $args = [])
|
|
|
150 |
* @method \GuzzleHttp\Promise\Promise putIntegrationAsync(array $args = [])
|
| 1 |
efrain |
151 |
* @method \Aws\Result putLogEvents(array $args = [])
|
|
|
152 |
* @method \GuzzleHttp\Promise\Promise putLogEventsAsync(array $args = [])
|
|
|
153 |
* @method \Aws\Result putMetricFilter(array $args = [])
|
|
|
154 |
* @method \GuzzleHttp\Promise\Promise putMetricFilterAsync(array $args = [])
|
|
|
155 |
* @method \Aws\Result putQueryDefinition(array $args = [])
|
|
|
156 |
* @method \GuzzleHttp\Promise\Promise putQueryDefinitionAsync(array $args = [])
|
|
|
157 |
* @method \Aws\Result putResourcePolicy(array $args = [])
|
|
|
158 |
* @method \GuzzleHttp\Promise\Promise putResourcePolicyAsync(array $args = [])
|
|
|
159 |
* @method \Aws\Result putRetentionPolicy(array $args = [])
|
|
|
160 |
* @method \GuzzleHttp\Promise\Promise putRetentionPolicyAsync(array $args = [])
|
|
|
161 |
* @method \Aws\Result putSubscriptionFilter(array $args = [])
|
|
|
162 |
* @method \GuzzleHttp\Promise\Promise putSubscriptionFilterAsync(array $args = [])
|
| 1441 |
ariadna |
163 |
* @method \Aws\Result putTransformer(array $args = [])
|
|
|
164 |
* @method \GuzzleHttp\Promise\Promise putTransformerAsync(array $args = [])
|
|
|
165 |
* @method \Aws\Result startLiveTail(array $args = [])
|
|
|
166 |
* @method \GuzzleHttp\Promise\Promise startLiveTailAsync(array $args = [])
|
| 1 |
efrain |
167 |
* @method \Aws\Result startQuery(array $args = [])
|
|
|
168 |
* @method \GuzzleHttp\Promise\Promise startQueryAsync(array $args = [])
|
|
|
169 |
* @method \Aws\Result stopQuery(array $args = [])
|
|
|
170 |
* @method \GuzzleHttp\Promise\Promise stopQueryAsync(array $args = [])
|
|
|
171 |
* @method \Aws\Result tagLogGroup(array $args = [])
|
|
|
172 |
* @method \GuzzleHttp\Promise\Promise tagLogGroupAsync(array $args = [])
|
|
|
173 |
* @method \Aws\Result tagResource(array $args = [])
|
|
|
174 |
* @method \GuzzleHttp\Promise\Promise tagResourceAsync(array $args = [])
|
|
|
175 |
* @method \Aws\Result testMetricFilter(array $args = [])
|
|
|
176 |
* @method \GuzzleHttp\Promise\Promise testMetricFilterAsync(array $args = [])
|
| 1441 |
ariadna |
177 |
* @method \Aws\Result testTransformer(array $args = [])
|
|
|
178 |
* @method \GuzzleHttp\Promise\Promise testTransformerAsync(array $args = [])
|
| 1 |
efrain |
179 |
* @method \Aws\Result untagLogGroup(array $args = [])
|
|
|
180 |
* @method \GuzzleHttp\Promise\Promise untagLogGroupAsync(array $args = [])
|
|
|
181 |
* @method \Aws\Result untagResource(array $args = [])
|
|
|
182 |
* @method \GuzzleHttp\Promise\Promise untagResourceAsync(array $args = [])
|
| 1441 |
ariadna |
183 |
* @method \Aws\Result updateAnomaly(array $args = [])
|
|
|
184 |
* @method \GuzzleHttp\Promise\Promise updateAnomalyAsync(array $args = [])
|
|
|
185 |
* @method \Aws\Result updateDeliveryConfiguration(array $args = [])
|
|
|
186 |
* @method \GuzzleHttp\Promise\Promise updateDeliveryConfigurationAsync(array $args = [])
|
|
|
187 |
* @method \Aws\Result updateLogAnomalyDetector(array $args = [])
|
|
|
188 |
* @method \GuzzleHttp\Promise\Promise updateLogAnomalyDetectorAsync(array $args = [])
|
| 1 |
efrain |
189 |
*/
|
| 1441 |
ariadna |
190 |
class CloudWatchLogsClient extends AwsClient {
|
|
|
191 |
static $streamingCommands = [
|
|
|
192 |
'StartLiveTail' => true
|
|
|
193 |
];
|
|
|
194 |
|
|
|
195 |
public function __construct(array $args)
|
|
|
196 |
{
|
|
|
197 |
parent::__construct($args);
|
|
|
198 |
$this->addStreamingFlagMiddleware();
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
private function addStreamingFlagMiddleware()
|
|
|
202 |
{
|
|
|
203 |
$this->getHandlerList()
|
|
|
204 |
-> appendInit(
|
|
|
205 |
$this->getStreamingFlagMiddleware(),
|
|
|
206 |
'streaming-flag-middleware'
|
|
|
207 |
);
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
private function getStreamingFlagMiddleware(): callable
|
|
|
211 |
{
|
|
|
212 |
return function (callable $handler) {
|
|
|
213 |
return function (CommandInterface $command, $request = null) use ($handler) {
|
|
|
214 |
if (!empty(self::$streamingCommands[$command->getName()])) {
|
|
|
215 |
$command['@http']['stream'] = true;
|
|
|
216 |
}
|
|
|
217 |
|
|
|
218 |
return $handler($command, $request);
|
|
|
219 |
};
|
|
|
220 |
};
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
/**
|
|
|
224 |
* Helper method for 'startLiveTail' operation that checks for results.
|
|
|
225 |
*
|
|
|
226 |
* Initiates 'startLiveTail' operation with given arguments, and continuously
|
|
|
227 |
* checks response stream for session updates or results, yielding each
|
|
|
228 |
* stream chunk when results are not empty. This method abstracts from users
|
|
|
229 |
* the need of checking if there are logs entry available to be watched, which means
|
|
|
230 |
* that users will always get a next item to be iterated when more log entries are
|
|
|
231 |
* available.
|
|
|
232 |
*
|
|
|
233 |
* @param array $args Command arguments.
|
|
|
234 |
*
|
|
|
235 |
* @return Generator Yields session update or result stream chunks.
|
|
|
236 |
*/
|
|
|
237 |
public function startLiveTailCheckingForResults(array $args): Generator
|
|
|
238 |
{
|
|
|
239 |
$response = $this->startLiveTail($args);
|
|
|
240 |
foreach ($response['responseStream'] as $streamChunk) {
|
|
|
241 |
if (isset($streamChunk['sessionUpdate'])) {
|
|
|
242 |
if (!empty($streamChunk['sessionUpdate']['sessionResults'])) {
|
|
|
243 |
yield $streamChunk;
|
|
|
244 |
}
|
|
|
245 |
} else {
|
|
|
246 |
yield $streamChunk;
|
|
|
247 |
}
|
|
|
248 |
}
|
|
|
249 |
}
|
|
|
250 |
}
|