-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathProjects.php
127 lines (110 loc) · 2.8 KB
/
Projects.php
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
declare(strict_types=1);
/*
* This file is part of the Bitbucket API Client.
*
* (c) Graham Campbell <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Bitbucket\Api\Workspaces;
use Bitbucket\Api\Workspaces\Projects\GroupPermissions;
use Bitbucket\Api\Workspaces\Projects\UserPermissions;
use Bitbucket\HttpClient\Util\UriBuilder;
/**
* The projects API class.
*
* @author Graham Campbell <[email protected]>
*/
class Projects extends AbstractWorkspacesApi
{
/**
* @param array $params
*
* @throws \Http\Client\Exception
*
* @return array
*/
public function list(array $params = [])
{
$uri = UriBuilder::appendSeparator($this->buildProjectsUri());
return $this->get($uri, $params);
}
/**
* @param array $params
*
* @throws \Http\Client\Exception
*
* @return array
*/
public function create(array $params = [])
{
$uri = UriBuilder::appendSeparator($this->buildProjectsUri());
return $this->post($uri, $params);
}
/**
* @param string $project
* @param array $params
*
* @throws \Http\Client\Exception
*
* @return array
*/
public function show(string $project, array $params = [])
{
$uri = $this->buildProjectsUri($project);
return $this->get($uri, $params);
}
/**
* @param string $project
* @param array $params
*
* @throws \Http\Client\Exception
*
* @return array
*/
public function update(string $project, array $params = [])
{
$uri = $this->buildProjectsUri($project);
return $this->put($uri, $params);
}
/**
* @param string $project
* @param array $params
*
* @throws \Http\Client\Exception
*
* @return array
*/
public function remove(string $project, array $params = [])
{
$uri = $this->buildProjectsUri($project);
return $this->delete($uri, $params);
}
/**
* @return UserPermissions
*/
public function userPermissions(string $project): UserPermissions
{
return new UserPermissions($this->getClient(), $this->workspace, $project);
}
/**
* @return GroupPermissions
*/
public function groupPermissions(string $project): GroupPermissions
{
return new GroupPermissions($this->getClient(), $this->workspace, $project);
}
/**
* Build the projects URI from the given parts.
*
* @param string ...$parts
*
* @return string
*/
protected function buildProjectsUri(string ...$parts)
{
return UriBuilder::build('workspaces', $this->workspace, 'projects', ...$parts);
}
}