We have detected an error in your notification set-up
(Event-ID dab39dc24f564ec7bd4628d1305fd03c).
Currently, we cannot inform you about inspection progress.
Please check that the user
557058:bca11929-8c2d-43f2-8a82-c5416880d395
still has access to your repository or
update the API account.
1 | <?php |
||
22 | class Repository extends API\Api |
||
23 | { |
||
24 | /** |
||
25 | * Get information associated with an individual repository. |
||
26 | * |
||
27 | * @access public |
||
28 | * @param string $account The team or individual account owning the repository. |
||
29 | * @param string $repo The repository identifier. |
||
30 | * @return MessageInterface |
||
31 | */ |
||
32 | 1 | public function get($account, $repo) |
|
33 | { |
||
34 | 1 | return $this->getClient()->setApiVersion('2.0')->get( |
|
35 | 1 | sprintf('repositories/%s/%s', $account, $repo) |
|
36 | ); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Create a new repository |
||
41 | * |
||
42 | * If `$params` are omitted, a private git repository will be created, |
||
43 | * with a "no forking" policy. |
||
44 | * |
||
45 | * @access public |
||
46 | * @param string $account The team or individual account owning the repository. |
||
47 | * @param string $repo The repository identifier. |
||
48 | * @param array|string $params Additional parameters as array or JSON string |
||
49 | * @return MessageInterface |
||
50 | * |
||
51 | * @throws \InvalidArgumentException If invalid JSON is provided. |
||
52 | * |
||
53 | * @see https://confluence.atlassian.com/x/WwZAGQ |
||
54 | */ |
||
55 | 13 | public function create($account, $repo, $params = array()) |
|
56 | { |
||
57 | // Keep BC for now. |
||
58 | // @todo[gtl]: to be removed. |
||
59 | 13 | if (is_array($repo)) { |
|
60 | 1 | return $this->createLegacy($account, $repo); |
|
|
|||
61 | } |
||
62 | |||
63 | $defaults = array( |
||
64 | 12 | 'scm' => 'git', |
|
65 | 12 | 'name' => $repo, |
|
66 | 'is_private' => true, |
||
67 | 12 | 'description' => 'My secret repo', |
|
68 | 12 | 'fork_policy' => 'no_forks', |
|
69 | ); |
||
70 | |||
71 | // allow developer to directly specify params as json if (s)he wants. |
||
72 | 12 | if ('array' !== gettype($params)) { |
|
73 | 10 | if (empty($params)) { |
|
74 | 1 | throw new \InvalidArgumentException('Invalid JSON provided.'); |
|
75 | } |
||
76 | |||
77 | 9 | $params = $this->decodeJSON($params); |
|
78 | } |
||
79 | |||
80 | 3 | $params = json_encode(array_merge($defaults, $params)); |
|
81 | |||
82 | 3 | return $this->getClient()->setApiVersion('2.0')->post( |
|
83 | 3 | sprintf('repositories/%s/%s', $account, $repo), |
|
84 | 3 | $params, |
|
85 | 3 | array('Content-Type' => 'application/json') |
|
86 | ); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Create a new repository |
||
91 | * |
||
92 | * Available `$params`: |
||
93 | * |
||
94 | * <example> |
||
95 | * 'description' (string) = A description of the repository. |
||
96 | * 'scm' (string) = A value of git or hg. The default is git if you leave this parameter unspecified. |
||
97 | * 'language' (string) = The language used for source code in the repository. |
||
98 | * 'is_private' (bool) = The repository is private (true) or public (false). The default is false. |
||
99 | * </example> |
||
100 | * |
||
101 | * @access public |
||
102 | * @param string $name The name of the repository |
||
103 | * @param array $params Additional parameters |
||
104 | * @return MessageInterface |
||
105 | * |
||
106 | * @deprecated This API 1.0 endpoint is deprecated. |
||
107 | * @see $this->create() Sintax for using API 2.0 endpoint |
||
108 | */ |
||
109 | private function createLegacy($name, array $params = array()) |
||
110 | { |
||
111 | $params['name'] = $name; |
||
112 | |||
113 | return $this->requestPost( |
||
114 | sprintf('repositories'), |
||
115 | $params |
||
116 | ); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Update a repository |
||
121 | * |
||
122 | * @access public |
||
123 | * @param string $account The team or individual account owning the repository. |
||
124 | * @param string $repo The repository identifier. |
||
125 | * @param array $params Additional parameters |
||
126 | * @return MessageInterface |
||
127 | * |
||
128 | * @see https://confluence.atlassian.com/x/WwZAGQ |
||
129 | */ |
||
130 | 1 | public function update($account, $repo, array $params = array()) |
|
137 | |||
138 | /** |
||
139 | * Delete a repository |
||
140 | * |
||
141 | * @access public |
||
142 | * @param string $account The team or individual account owning the repository. |
||
143 | * @param string $repo The repository identifier. |
||
144 | * @return MessageInterface |
||
145 | */ |
||
146 | 1 | public function delete($account, $repo) |
|
147 | { |
||
148 | 1 | return $this->getClient()->setApiVersion('2.0')->delete( |
|
149 | 1 | sprintf('repositories/%s/%s', $account, $repo) |
|
150 | ); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * Gets the list of accounts watching a repository. |
||
155 | * |
||
156 | * @access public |
||
157 | * @param string $account The team or individual account owning the repository. |
||
158 | * @param string $repo The repository identifier. |
||
159 | * @return MessageInterface |
||
160 | */ |
||
161 | 1 | public function watchers($account, $repo) |
|
162 | { |
||
163 | 1 | return $this->getClient()->setApiVersion('2.0')->get( |
|
164 | 1 | sprintf('repositories/%s/%s/watchers', $account, $repo) |
|
165 | ); |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * Gets the list of repository forks. |
||
170 | * |
||
171 | * @access public |
||
172 | * @param string $account The team or individual account owning the repository. |
||
173 | * @param string $repo The repository identifier. |
||
174 | * @return MessageInterface |
||
175 | */ |
||
176 | 1 | public function forks($account, $repo) |
|
177 | { |
||
178 | 1 | return $this->getClient()->setApiVersion('2.0')->get( |
|
179 | 1 | sprintf('repositories/%s/%s/forks', $account, $repo) |
|
180 | ); |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * Fork a repository |
||
185 | * |
||
186 | * @access public |
||
187 | * @param string $account The team or individual account owning the repository. |
||
188 | * @param string $repo The repository identifier. |
||
189 | * @param string $name Fork name |
||
190 | * @param array $params Additional parameters |
||
191 | * @return MessageInterface |
||
192 | * |
||
193 | * @see https://confluence.atlassian.com/display/BITBUCKET/repository+Resource#repositoryResource-POSTanewfork |
||
194 | */ |
||
195 | 1 | public function fork($account, $repo, $name, array $params = array()) |
|
204 | |||
205 | /** |
||
206 | * Get a list of branches associated with a repository. |
||
207 | * |
||
208 | * @access public |
||
209 | * @param string $account The team or individual account owning the repository. |
||
210 | * @param string $repo The repository identifier. |
||
211 | * @return MessageInterface |
||
212 | */ |
||
213 | 1 | public function branches($account, $repo) |
|
219 | |||
220 | /** |
||
221 | * Get the repository's main branch |
||
222 | * |
||
223 | * @access public |
||
224 | * @param string $account The team or individual account owning the repository. |
||
225 | * @param string $repo The repository identifier. |
||
226 | * @return MessageInterface |
||
227 | */ |
||
228 | 1 | public function branch($account, $repo) |
|
234 | |||
235 | /** |
||
236 | * Get the repository manifest |
||
237 | * |
||
238 | * @access public |
||
239 | * @param string $account The team or individual account owning the repository. |
||
240 | * @param string $repo The repository identifier. |
||
241 | * @param string $revision A revision to get such as default or master. |
||
242 | * @return MessageInterface |
||
243 | */ |
||
244 | 1 | public function manifest($account, $repo, $revision) |
|
250 | |||
251 | /** |
||
252 | * Get a list of tags |
||
253 | * |
||
254 | * @access public |
||
255 | * @param string $account The team or individual account owning the repository. |
||
256 | * @param string $repo The repository identifier. |
||
257 | * @return MessageInterface |
||
258 | */ |
||
259 | 1 | public function tags($account, $repo) |
|
265 | |||
266 | /** |
||
267 | * Get the raw source |
||
268 | * |
||
269 | * Get the raw content of a file or directory. |
||
270 | * |
||
271 | * @access public |
||
272 | * @param string $account The team or individual account owning the repository. |
||
273 | * @param string $repo The repository identifier. |
||
274 | * @param string $rev A value representing the revision or branch to list. |
||
275 | * @param string $path The path can be a filename or a directory path. |
||
276 | * @return MessageInterface |
||
277 | */ |
||
278 | 1 | public function raw($account, $repo, $rev, $path) |
|
284 | |||
285 | /** |
||
286 | * Get the history of a file in a changeset |
||
287 | * |
||
288 | * Returns the history of a file starting from the provided changeset. |
||
289 | * |
||
290 | * @access public |
||
291 | * @param string $account The team or individual account owning the repository. |
||
292 | * @param string $repo The repository identifier. |
||
293 | * @param string $node The simple changeset node id. |
||
294 | * @param string $path Filename. |
||
295 | * @return MessageInterface |
||
296 | */ |
||
297 | 1 | public function filehistory($account, $repo, $node, $path) |
|
303 | } |
||
304 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.