1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AcquiaCloudApi\Endpoints; |
4
|
|
|
|
5
|
|
|
use AcquiaCloudApi\Connector\ClientInterface; |
6
|
|
|
use AcquiaCloudApi\Response\EnvironmentResponse; |
7
|
|
|
use AcquiaCloudApi\Response\EnvironmentsResponse; |
8
|
|
|
use AcquiaCloudApi\Response\LogstreamResponse; |
9
|
|
|
use AcquiaCloudApi\Response\LogsResponse; |
10
|
|
|
use AcquiaCloudApi\Response\OperationResponse; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Client |
14
|
|
|
* @package AcquiaCloudApi\CloudApi |
15
|
|
|
*/ |
16
|
|
|
class Logs implements CloudApi |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** @var ClientInterface The API client. */ |
20
|
|
|
protected $client; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Client constructor. |
24
|
|
|
* |
25
|
|
|
* @param ClientInterface $client |
26
|
|
|
*/ |
27
|
|
|
public function __construct(ClientInterface $client) |
28
|
|
|
{ |
29
|
|
|
$this->client = $client; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Returns a list of log files available for download. |
34
|
|
|
* |
35
|
|
|
* @return LogsResponse |
36
|
|
|
*/ |
37
|
|
|
public function getAll($environmentUuid) |
38
|
|
|
{ |
39
|
|
|
return new LogsResponse( |
40
|
|
|
$this->client->request('get', "/environments/${environmentUuid}/logs") |
|
|
|
|
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Downloads a log file. |
46
|
|
|
* |
47
|
|
|
* @return object |
48
|
|
|
*/ |
49
|
|
|
public function download($environmentUuid, $logType) |
50
|
|
|
{ |
51
|
|
|
return $this->client->request('get', "/environments/${environmentUuid}/logs/${logType}"); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Creates a log file snapshot. |
56
|
|
|
* |
57
|
|
|
* @return OperationResponse |
58
|
|
|
*/ |
59
|
|
|
public function snapshot($environmentUuid, $logType) |
60
|
|
|
{ |
61
|
|
|
return new OperationResponse( |
62
|
|
|
$this->client->request('post', "/environments/${environmentUuid}/logs/${logType}") |
|
|
|
|
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Returns logstream WSS stream information. |
68
|
|
|
* |
69
|
|
|
* @return LogstreamResponse |
70
|
|
|
*/ |
71
|
|
|
public function stream($environmentUuid) |
72
|
|
|
{ |
73
|
|
|
return new LogstreamResponse( |
74
|
|
|
$this->client->request('get', "/environments/${environmentUuid}/logstream") |
|
|
|
|
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|