Completed
Push — master ( b67977...b30551 )
by Timur
03:20
created

Site::deploymentStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Laravel\Forge\Sites;
4
5
use Laravel\Forge\Contracts\ApplicationContract;
6
use Laravel\Forge\ApiResource;
7
8
class Site extends ApiResource
9
{
10
    /**
11
     * Resource type.
12
     *
13
     * @return string
14
     */
15
    public static function resourceType()
16
    {
17
        return 'site';
18
    }
19
20
    /**
21
     * Resource path (relative to Server URL).
22
     *
23
     * @return string
24
     */
25
    public function resourcePath()
26
    {
27
        return 'sites';
28
    }
29
30
    /**
31
     * Site domain.
32
     *
33
     * @return string
34
     */
35
    public function domain()
36
    {
37
        return $this->getData('name');
38
    }
39
40
    /**
41
     * Project type.
42
     *
43
     * @return string
44
     */
45
    public function projectType()
46
    {
47
        return $this->getData('project_type');
48
    }
49
50
    /**
51
     * Site repository.
52
     *
53
     * @return string
54
     */
55
    public function repository()
56
    {
57
        return $this->getData('repository');
58
    }
59
60
    /**
61
     * Site repository provider.
62
     *
63
     * @return string
64
     */
65
    public function repositoryProvider()
66
    {
67
        return $this->getData('repository_provider');
68
    }
69
70
    /**
71
     * Site repository branch.
72
     *
73
     * @return string
74
     */
75
    public function repositoryBranch()
76
    {
77
        return $this->getData('repository_branch');
78
    }
79
80
    /**
81
     * Site repository status.
82
     *
83
     * @return string
84
     */
85
    public function repositoryStatus()
86
    {
87
        return $this->getData('repository_status');
88
    }
89
90
    /**
91
     * Site deployment status.
92
     *
93
     * @return string | null
94
     */
95
    public function deploymentStatus()
96
    {
97
        return $this->getData('deployment_status');
98
    }
99
100
    /**
101
     * Site allows wildcard URIs.
102
     *
103
     * @return boolean
104
     */
105
    public function wildcards()
106
    {
107
        return $this->getData('wildcards');
108
    }
109
110
    /**
111
     * Site quick deploy enabled.
112
     *
113
     * @return boolean
114
     */
115
    public function quickDeploy()
116
    {
117
        return $this->getData('quick_deploy');
118
    }
119
120
    /**
121
     * Site hipchat room.
122
     *
123
     * @return string
124
     */
125
    public function hipchatRoom()
126
    {
127
        return $this->getData('hipchat_room');
128
    }
129
130
    /**
131
     * Site slack channel.
132
     *
133
     * @return string
134
     */
135
    public function slackChannel()
136
    {
137
        return $this->getData('slack_channel');
138
    }
139
140
    /**
141
     * Site app.
142
     *
143
     * @return string | null
144
     */
145
    public function app()
146
    {
147
        return $this->getData('app');
148
    }
149
150
    /**
151
     * Site app status.
152
     *
153
     * @return string | null
154
     */
155
    public function appStatus()
156
    {
157
        return $this->getData('app_status');
158
    }
159
160
    /**
161
     * Install new application on site.
162
     *
163
     * @param \Laravel\Forge\Contracts\ApplicationContract $application
164
     *
165
     * @return bool
166
     */
167
    public function install(ApplicationContract $application)
168
    {
169
        $this->getHttpClient()->request('POST', $this->apiUrl($application->type()), [
170
            'json' => $application->payload(),
171
        ]);
172
173
        return true;
174
    }
175
176
    /**
177
     * Uninstall application from site.
178
     *
179
     * @param \Laravel\Forge\Contracts\ApplicationContract $application
180
     *
181
     * @return bool
182
     */
183
    public function uninstall(ApplicationContract $application)
184
    {
185
        $this->getHttpClient()->request('DELETE', $this->apiUrl($application->type()));
186
187
        return true;
188
    }
189
190
    /**
191
     * Connect load balancer.
192
     *
193
     * @return bool
194
     */
195
    public function balance(array $serverIds)
196
    {
197
        $this->getHttpClient()->request('PUT', $this->apiUrl('/balancing'), [
198
            'json' => ['servers' => $serverIds]
199
        ]);
200
201
        return true;
202
    }
203
}
204