Completed
Pull Request — master (#34)
by Adam
03:27
created

LogForwardingDestinations::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
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 LogForwardingDestinations
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class LogForwardingDestinations extends CloudApiBase implements CloudApiInterface
15
{
16
17
    /**
18
     * Returns a list of log forwarding destinations.
19
     *
20
     * @param string $environmentUuid The environment ID
21
     * @return LogForwardingDestinationsResponse
22
     */
23
    public function getAll($environmentUuid)
24
    {
25
        return new LogForwardingDestinationsResponse(
26
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...rwarding-destinations') can also be of type object; however, parameter $destinations of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
27
                'get',
28
                "/environments/${environmentUuid}/log-forwarding-destinations"
29
            )
30
        );
31
    }
32
33
    /**
34
     * Returns a specific log forwarding destination.
35
     *
36
     * @param string $environmentUuid The environment ID
37
     * @param int    $destinationId
38
     * @return LogForwardingDestinationResponse
39
     */
40
    public function get($environmentUuid, $destinationId)
41
    {
42
        return new LogForwardingDestinationResponse(
43
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...tions/'.$destinationId) can also be of type array; however, parameter $destination of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
44
                'get',
45
                "/environments/${environmentUuid}/log-forwarding-destinations/${destinationId}"
46
            )
47
        );
48
    }
49
50
    /**
51
     * Creates a log forwarding destination.
52
     *
53
     * @param string $environmentUuid
54
     * @param string $label
55
     * @param array  $sources
56
     * @param string $consumer
57
     * @param array  $credentials
58
     * @param string $address
59
     * @return OperationResponse
60
     */
61
    public function create($environmentUuid, $label, $sources, $consumer, $credentials, $address)
62
    {
63
64
        $options = [
65
            'form_params' => [
66
                'label' => $label,
67
                'sources' => $sources,
68
                'consumer' => $consumer,
69
                'credentials' => $credentials,
70
                'address' => $address
71
            ],
72
        ];
73
74
        return new OperationResponse(
75
            $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...estinations', $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

75
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options)
Loading history...
76
        );
77
    }
78
79
    /**
80
     * Delete a specific log forwarding destination.
81
     *
82
     * @param string $environmentUuid
83
     * @param int    $destId
84
     * @return OperationResponse
85
     */
86
    public function delete($environmentUuid, $destId)
87
    {
88
        return new OperationResponse(
89
            $this->client->request('delete', "/environments/${environmentUuid}/log-forwarding-destinations/${destId}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...destinations/'.$destId) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

89
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/log-forwarding-destinations/${destId}")
Loading history...
90
        );
91
    }
92
93
    /**
94
     * Disables a log forwarding destination.
95
     *
96
     * @param string $environmentUuid
97
     * @param int    $destId
98
     * @return OperationResponse
99
     */
100
    public function disable($environmentUuid, $destId)
101
    {
102
        return new OperationResponse(
103
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...tId.'/actions/disable') can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

103
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
104
                'post',
105
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/disable"
106
            )
107
        );
108
    }
109
110
    /**
111
     * Enables a log forwarding destination.
112
     *
113
     * @param string $environmentUuid
114
     * @param int    $destId
115
     * @return OperationResponse
116
     */
117
    public function enable($environmentUuid, $destId)
118
    {
119
        return new OperationResponse(
120
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...stId.'/actions/enable') can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

120
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
121
                'post',
122
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/enable"
123
            )
124
        );
125
    }
126
127
    /**
128
     * Updates a log forwarding destination.
129
     *
130
     * @param string $environmentUuid
131
     * @param int    $destId
132
     * @param string $label
133
     * @param array  $sources
134
     * @param string $consumer
135
     * @param array  $creds
136
     * @param string $address
137
     * @return OperationResponse
138
     */
139
    public function update($environmentUuid, $destId, $label, $sources, $consumer, $creds, $address)
140
    {
141
142
        $options = [
143
            'form_params' => [
144
                'label' => $label,
145
                'sources' => $sources,
146
                'consumer' => $consumer,
147
                'credentials' => $creds,
148
                'address' => $address
149
            ],
150
        ];
151
152
        return new OperationResponse(
153
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ns/'.$destId, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

153
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
154
                'put',
155
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}",
156
                $options
157
            )
158
        );
159
    }
160
}
161