Repository navigation
Expand file tree
/
Copy pathEnvironments.php
More file actions
95 lines (84 loc) · 2.72 KB
/
Copy pathEnvironments.php
File metadata and controls
95 lines (84 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
declare(strict_types=1);
/*
* This file is part of the Gitlab API library.
*
* (c) Matt Humphrey <matth@windsor-telecom.co.uk>
* (c) Graham Campbell <hello@gjcampbell.co.uk>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Gitlab\Api;
use Symfony\Component\OptionsResolver\OptionsResolver;
class Environments extends AbstractApi
{
/**
* @param int|string $project_id
* @param array $parameters
*
* @return mixed
*/
public function all($project_id, array $parameters = [])
{
$resolver = $this->createOptionsResolver();
$resolver->setDefined('name')
->setAllowedTypes('name', 'string');
$resolver->setDefined('search')
->setAllowedTypes('search', 'string');
$resolver->setDefined('states')
->setAllowedTypes('states', 'string')
->setAllowedValues('states', ['available', 'stopped']);
return $this->get($this->getProjectPath($project_id, 'environments'), $resolver->resolve($parameters));
}
/**
* @param int|string $project_id
* @param array $parameters {
*
* @var string $name The name of the environment
* @var string $external_url Place to link to for this environment
* }
*
* @return mixed
*/
public function create($project_id, array $parameters = [])
{
$resolver = new OptionsResolver();
$resolver->setDefined('name')
->setRequired('name')
->setAllowedTypes('name', 'string');
$resolver->setDefined('external_url')
->setAllowedTypes('external_url', 'string');
return $this->post($this->getProjectPath($project_id, 'environments'), $resolver->resolve($parameters));
}
/**
* @param int|string $project_id
* @param int $environment_id
*
* @return mixed
*/
public function remove($project_id, int $environment_id)
{
return $this->delete($this->getProjectPath($project_id, 'environments/'.$environment_id));
}
/**
* @param int|string $project_id
* @param int $environment_id
*
* @return mixed
*/
public function stop($project_id, int $environment_id)
{
return $this->post($this->getProjectPath($project_id, 'environments/'.self::encodePath($environment_id).'/stop'));
}
/**
* @param int|string $project_id
* @param int $environment_id
*
* @return mixed
*/
public function show($project_id, int $environment_id)
{
return $this->get($this->getProjectPath($project_id, 'environments/'.self::encodePath($environment_id)));
}
}