|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace AsyncAws\CloudWatchLogs\Input; |
| 4 | + |
| 5 | +use AsyncAws\Core\Exception\InvalidArgument; |
| 6 | +use AsyncAws\Core\Input; |
| 7 | +use AsyncAws\Core\Request; |
| 8 | +use AsyncAws\Core\Stream\StreamFactory; |
| 9 | + |
| 10 | +final class FilterLogEventsRequest extends Input |
| 11 | +{ |
| 12 | + /** |
| 13 | + * The name of the log group to search. |
| 14 | + * |
| 15 | + * @required |
| 16 | + * |
| 17 | + * @var string|null |
| 18 | + */ |
| 19 | + private $logGroupName; |
| 20 | + |
| 21 | + /** |
| 22 | + * Filters the results to only logs from the log streams in this list. |
| 23 | + * |
| 24 | + * @var string[]|null |
| 25 | + */ |
| 26 | + private $logStreamNames; |
| 27 | + |
| 28 | + /** |
| 29 | + * Filters the results to include only events from log streams that have names starting with this prefix. |
| 30 | + * |
| 31 | + * @var string|null |
| 32 | + */ |
| 33 | + private $logStreamNamePrefix; |
| 34 | + |
| 35 | + /** |
| 36 | + * The start of the time range, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events with a |
| 37 | + * timestamp before this time are not returned. |
| 38 | + * |
| 39 | + * @var string|null |
| 40 | + */ |
| 41 | + private $startTime; |
| 42 | + |
| 43 | + /** |
| 44 | + * The end of the time range, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC. Events with a |
| 45 | + * timestamp later than this time are not returned. |
| 46 | + * |
| 47 | + * @var string|null |
| 48 | + */ |
| 49 | + private $endTime; |
| 50 | + |
| 51 | + /** |
| 52 | + * The filter pattern to use. For more information, see Filter and Pattern Syntax. |
| 53 | + * |
| 54 | + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html |
| 55 | + * |
| 56 | + * @var string|null |
| 57 | + */ |
| 58 | + private $filterPattern; |
| 59 | + |
| 60 | + /** |
| 61 | + * The token for the next set of events to return. (You received this token from a previous call.). |
| 62 | + * |
| 63 | + * @var string|null |
| 64 | + */ |
| 65 | + private $nextToken; |
| 66 | + |
| 67 | + /** |
| 68 | + * The maximum number of events to return. The default is 10,000 events. |
| 69 | + * |
| 70 | + * @var int|null |
| 71 | + */ |
| 72 | + private $limit; |
| 73 | + |
| 74 | + /** |
| 75 | + * If the value is true, the operation makes a best effort to provide responses that contain events from multiple log |
| 76 | + * streams within the log group, interleaved in a single response. If the value is false, all the matched log events in |
| 77 | + * the first log stream are searched first, then those in the next log stream, and so on. The default is false. |
| 78 | + * |
| 79 | + * @var bool|null |
| 80 | + */ |
| 81 | + private $interleaved; |
| 82 | + |
| 83 | + /** |
| 84 | + * @param array{ |
| 85 | + * logGroupName?: string, |
| 86 | + * logStreamNames?: string[], |
| 87 | + * logStreamNamePrefix?: string, |
| 88 | + * startTime?: string, |
| 89 | + * endTime?: string, |
| 90 | + * filterPattern?: string, |
| 91 | + * nextToken?: string, |
| 92 | + * limit?: int, |
| 93 | + * interleaved?: bool, |
| 94 | + * @region?: string, |
| 95 | + * } $input |
| 96 | + */ |
| 97 | + public function __construct(array $input = []) |
| 98 | + { |
| 99 | + $this->logGroupName = $input['logGroupName'] ?? null; |
| 100 | + $this->logStreamNames = $input['logStreamNames'] ?? null; |
| 101 | + $this->logStreamNamePrefix = $input['logStreamNamePrefix'] ?? null; |
| 102 | + $this->startTime = $input['startTime'] ?? null; |
| 103 | + $this->endTime = $input['endTime'] ?? null; |
| 104 | + $this->filterPattern = $input['filterPattern'] ?? null; |
| 105 | + $this->nextToken = $input['nextToken'] ?? null; |
| 106 | + $this->limit = $input['limit'] ?? null; |
| 107 | + $this->interleaved = $input['interleaved'] ?? null; |
| 108 | + parent::__construct($input); |
| 109 | + } |
| 110 | + |
| 111 | + public static function create($input): self |
| 112 | + { |
| 113 | + return $input instanceof self ? $input : new self($input); |
| 114 | + } |
| 115 | + |
| 116 | + public function getEndTime(): ?string |
| 117 | + { |
| 118 | + return $this->endTime; |
| 119 | + } |
| 120 | + |
| 121 | + public function getFilterPattern(): ?string |
| 122 | + { |
| 123 | + return $this->filterPattern; |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * @deprecated |
| 128 | + */ |
| 129 | + public function getInterleaved(): ?bool |
| 130 | + { |
| 131 | + @trigger_error(sprintf('The property "interleaved" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED); |
| 132 | + |
| 133 | + return $this->interleaved; |
| 134 | + } |
| 135 | + |
| 136 | + public function getLimit(): ?int |
| 137 | + { |
| 138 | + return $this->limit; |
| 139 | + } |
| 140 | + |
| 141 | + public function getLogGroupName(): ?string |
| 142 | + { |
| 143 | + return $this->logGroupName; |
| 144 | + } |
| 145 | + |
| 146 | + public function getLogStreamNamePrefix(): ?string |
| 147 | + { |
| 148 | + return $this->logStreamNamePrefix; |
| 149 | + } |
| 150 | + |
| 151 | + /** |
| 152 | + * @return string[] |
| 153 | + */ |
| 154 | + public function getLogStreamNames(): array |
| 155 | + { |
| 156 | + return $this->logStreamNames ?? []; |
| 157 | + } |
| 158 | + |
| 159 | + public function getNextToken(): ?string |
| 160 | + { |
| 161 | + return $this->nextToken; |
| 162 | + } |
| 163 | + |
| 164 | + public function getStartTime(): ?string |
| 165 | + { |
| 166 | + return $this->startTime; |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * @internal |
| 171 | + */ |
| 172 | + public function request(): Request |
| 173 | + { |
| 174 | + // Prepare headers |
| 175 | + $headers = [ |
| 176 | + 'Content-Type' => 'application/x-amz-json-1.1', |
| 177 | + 'X-Amz-Target' => 'Logs_20140328.FilterLogEvents', |
| 178 | + ]; |
| 179 | + |
| 180 | + // Prepare query |
| 181 | + $query = []; |
| 182 | + |
| 183 | + // Prepare URI |
| 184 | + $uriString = '/'; |
| 185 | + |
| 186 | + // Prepare Body |
| 187 | + $bodyPayload = $this->requestBody(); |
| 188 | + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); |
| 189 | + |
| 190 | + // Return the Request |
| 191 | + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); |
| 192 | + } |
| 193 | + |
| 194 | + public function setEndTime(?string $value): self |
| 195 | + { |
| 196 | + $this->endTime = $value; |
| 197 | + |
| 198 | + return $this; |
| 199 | + } |
| 200 | + |
| 201 | + public function setFilterPattern(?string $value): self |
| 202 | + { |
| 203 | + $this->filterPattern = $value; |
| 204 | + |
| 205 | + return $this; |
| 206 | + } |
| 207 | + |
| 208 | + /** |
| 209 | + * @deprecated |
| 210 | + */ |
| 211 | + public function setInterleaved(?bool $value): self |
| 212 | + { |
| 213 | + @trigger_error(sprintf('The property "interleaved" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED); |
| 214 | + $this->interleaved = $value; |
| 215 | + |
| 216 | + return $this; |
| 217 | + } |
| 218 | + |
| 219 | + public function setLimit(?int $value): self |
| 220 | + { |
| 221 | + $this->limit = $value; |
| 222 | + |
| 223 | + return $this; |
| 224 | + } |
| 225 | + |
| 226 | + public function setLogGroupName(?string $value): self |
| 227 | + { |
| 228 | + $this->logGroupName = $value; |
| 229 | + |
| 230 | + return $this; |
| 231 | + } |
| 232 | + |
| 233 | + public function setLogStreamNamePrefix(?string $value): self |
| 234 | + { |
| 235 | + $this->logStreamNamePrefix = $value; |
| 236 | + |
| 237 | + return $this; |
| 238 | + } |
| 239 | + |
| 240 | + /** |
| 241 | + * @param string[] $value |
| 242 | + */ |
| 243 | + public function setLogStreamNames(array $value): self |
| 244 | + { |
| 245 | + $this->logStreamNames = $value; |
| 246 | + |
| 247 | + return $this; |
| 248 | + } |
| 249 | + |
| 250 | + public function setNextToken(?string $value): self |
| 251 | + { |
| 252 | + $this->nextToken = $value; |
| 253 | + |
| 254 | + return $this; |
| 255 | + } |
| 256 | + |
| 257 | + public function setStartTime(?string $value): self |
| 258 | + { |
| 259 | + $this->startTime = $value; |
| 260 | + |
| 261 | + return $this; |
| 262 | + } |
| 263 | + |
| 264 | + private function requestBody(): array |
| 265 | + { |
| 266 | + $payload = []; |
| 267 | + if (null === $v = $this->logGroupName) { |
| 268 | + throw new InvalidArgument(sprintf('Missing parameter "logGroupName" for "%s". The value cannot be null.', __CLASS__)); |
| 269 | + } |
| 270 | + $payload['logGroupName'] = $v; |
| 271 | + if (null !== $v = $this->logStreamNames) { |
| 272 | + $index = -1; |
| 273 | + $payload['logStreamNames'] = []; |
| 274 | + foreach ($v as $listValue) { |
| 275 | + ++$index; |
| 276 | + $payload['logStreamNames'][$index] = $listValue; |
| 277 | + } |
| 278 | + } |
| 279 | + if (null !== $v = $this->logStreamNamePrefix) { |
| 280 | + $payload['logStreamNamePrefix'] = $v; |
| 281 | + } |
| 282 | + if (null !== $v = $this->startTime) { |
| 283 | + $payload['startTime'] = $v; |
| 284 | + } |
| 285 | + if (null !== $v = $this->endTime) { |
| 286 | + $payload['endTime'] = $v; |
| 287 | + } |
| 288 | + if (null !== $v = $this->filterPattern) { |
| 289 | + $payload['filterPattern'] = $v; |
| 290 | + } |
| 291 | + if (null !== $v = $this->nextToken) { |
| 292 | + $payload['nextToken'] = $v; |
| 293 | + } |
| 294 | + if (null !== $v = $this->limit) { |
| 295 | + $payload['limit'] = $v; |
| 296 | + } |
| 297 | + if (null !== $v = $this->interleaved) { |
| 298 | + @trigger_error(sprintf('The property "interleaved" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED); |
| 299 | + $payload['interleaved'] = (bool) $v; |
| 300 | + } |
| 301 | + |
| 302 | + return $payload; |
| 303 | + } |
| 304 | +} |
0 commit comments