-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.power
More file actions
412 lines (362 loc) · 11.5 KB
/
Copy pathcode.power
File metadata and controls
412 lines (362 loc) · 11.5 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
/**
* Search for repositories.
*
* @param string $q The search query.
* @param array $options Additional search options (optional).
* @param int $page The page number (optional).
* @param int $limit The number of items per page (optional).
* @param string $sort The sort order (optional).
* @param string $order The order direction (optional).
*
* @return object|null
* @since 3.2.0
**/
public function search(
string $q,
array $options = [],
int $page = 1,
int $limit = 10,
string $sort = 'alpha',
string $order = 'asc'
): ?object
{
// Build the request path.
$path = '/repos/search';
// Create the URI object and set URL values.
$uri = $this->uri->get($path);
$uri->setVar('q', $q);
$uri->setVar('page', $page);
$uri->setVar('limit', $limit);
$uri->setVar('sort', $sort);
$uri->setVar('order', $order);
foreach ($options as $key => $val)
{
$uri->setVar($key, $val);
}
// Send the get request.
return $this->response->get(
$this->http->get($uri)
);
}
/**
* Get a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
*
* @return object|null
* @since 3.2.0
**/
public function get(string $owner, string $repo): ?object
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}";
// Send the get request.
return $this->response->get(
$this->http->get(
$this->uri->get($path)
)
);
}
/**
* Get a repository by owner and repo name.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
*
* @return object|null
* @since 3.2.0
**/
public function id(string $owner, string $repo): ?object
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}";
// Send the get request.
return $this->response->get(
$this->http->get(
$this->uri->get($path)
)
);
}
/**
* Delete a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
*
* @return string
* @since 3.2.0
**/
public function delete(string $owner, string $repo): string
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}";
// Send the delete request.
return $this->response->get(
$this->http->delete(
$this->uri->get($path)
), 204, 'success'
);
}
/**
* Edit a repository's properties.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string|null $description The repository description (optional).
* @param string|null $website The repository website (optional).
* @param bool|null $private Set the repository to private (optional).
* @param bool|null $hasIssues Set the repository to have issues (optional).
* @param bool|null $hasWiki Set the repository to have a wiki (optional).
* @param bool|null $hasProjects Set the repository to have projects (optional).
* @param bool|null $allowManualMerge Allow manual merge of pull requests (optional).
* @param bool|null $allowMergeCommits Allow merge commits for pull requests (optional).
* @param bool|null $allowRebase Allow rebase-merging pull requests (optional).
* @param bool|null $allowRebaseExplicit Allow rebase with explicit merge commits (optional).
* @param bool|null $allowRebaseUpdate Allow updating pull request branch by rebase (optional).
* @param bool|null $allowSquashMerge Allow squash-merging pull requests (optional).
* @param bool|null $archived
* @param bool|null $archived Set to true to archive this repository (optional).
* @param bool|null $autodetectManualMerge Enable AutodetectManualMerge (optional).
* @param string|null $defaultBranch Sets the default branch for this repository (optional).
* @param bool|null $defaultDeleteBranchAfterMerge Set to true to delete pr branch after merge by default (optional).
* @param string|null $defaultMergeStyle Set to a merge style to be used by this repository (optional).
* @param bool|null $enablePrune Enable prune - remove obsolete remote-tracking references (optional).
* @param object|null $externalTracker External tracker settings (optional).
* @param object|null $externalWiki External wiki settings (optional).
* @param bool|null $hasPullRequests Set the repository to have pull requests (optional).
* @param bool|null $ignoreWhitespaceConflicts Ignore whitespace for conflicts (optional).
* @param object|null $internalTracker Internal tracker settings (optional).
* @param string|null $mirrorInterval Set the mirror interval time (optional).
* @param bool|null $template Set to true to make this repository a template (optional).
*
* @return object|null
* @since 3.2.0
**/
public function edit(
string $owner,
string $repo,
?string $description = null,
?string $website = null,
?bool $private = null,
?bool $hasIssues = null,
?bool $hasWiki = null,
?bool $hasProjects = null,
?bool $allowManualMerge = null,
?bool $allowMergeCommits = null,
?bool $allowRebase = null,
?bool $allowRebaseExplicit = null,
?bool $allowRebaseUpdate = null,
?bool $allowSquashMerge = null,
?bool $archived = null,
?bool $autodetectManualMerge = null,
?string $defaultBranch = null,
?bool $defaultDeleteBranchAfterMerge = null,
?string $defaultMergeStyle = null,
?bool $enablePrune = null,
?object $externalTracker = null,
?object $externalWiki = null,
?bool $hasPullRequests = null,
?bool $ignoreWhitespaceConflicts = null,
?object $internalTracker = null,
?string $mirrorInterval = null,
?bool $template = null
): ?object
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}";
// Set the repository properties to update.
$data = new \stdClass();
if ($description !== null)
{
$data->description = $description;
}
if ($website !== null)
{
$data->website = $website;
}
if ($private !== null)
{
$data->private = $private;
}
if ($hasIssues !== null)
{
$data->has_issues = $hasIssues;
}
if ($hasWiki !== null)
{
$data->has_wiki = $hasWiki;
}
if ($hasProjects !== null)
{
$data->has_projects = $hasProjects;
}
// Add the additional properties to update.
if ($allowManualMerge !== null)
{
$data->allow_manual_merge = $allowManualMerge;
}
if ($allowMergeCommits !== null)
{
$data->allow_merge_commits = $allowMergeCommits;
}
if ($allowRebase !== null)
{
$data->allow_rebase = $allowRebase;
}
if ($allowRebaseExplicit !== null)
{
$data->allow_rebase_explicit = $allowRebaseExplicit;
}
if ($allowRebaseUpdate !== null)
{
$data->allow_rebase_update = $allowRebaseUpdate;
}
if ($allowSquashMerge !== null)
{
$data->allow_squash_merge = $allowSquashMerge;
}
if ($archived !== null)
{
$data->archived = $archived;
}
if ($autodetectManualMerge !== null)
{
$data->autodetect_manual_merge = $autodetectManualMerge;
}
if ($defaultBranch !== null)
{
$data->default_branch = $defaultBranch;
}
if ($defaultDeleteBranchAfterMerge !== null)
{
$data->default_delete_branch_after_merge = $defaultDeleteBranchAfterMerge;
}
if ($defaultMergeStyle !==
null)
{
$data->default_merge_style = $defaultMergeStyle;
}
if ($enablePrune !== null)
{
$data->enable_prune = $enablePrune;
}
if ($externalTracker !== null)
{
$data->external_tracker = $externalTracker;
}
if ($externalWiki !== null)
{
$data->external_wiki = $externalWiki;
}
if ($hasPullRequests !== null)
{
$data->has_pull_requests = $hasPullRequests;
}
if ($ignoreWhitespaceConflicts !== null)
{
$data->ignore_whitespace_conflicts = $ignoreWhitespaceConflicts;
}
if ($internalTracker !== null)
{
$data->internal_tracker = $internalTracker;
}
if ($mirrorInterval !== null)
{
$data->mirror_interval = $mirrorInterval;
}
if ($template !== null)
{
$data->template = $template;
}
// Send the patch request.
return $this->response->get(
$this->http->patch(
$this->uri->get($path), json_encode($data)
)
);
}
/**
* Create a repository.
*
* @param string $name The name of the new repository.
* @param string|null $description Optional. The description of the new repository.
* @param bool|null $private Optional. Set to true if the new repository should be private.
* @param bool|null $autoInit Optional. Set to true to initialize the repository with a README.
* @param string|null $defaultBranch Optional. Default branch of the repository (used when initializes and in template).
* @param string|null $gitignores Optional. The desired .gitignore templates to apply.
* @param string|null $issueLabels Optional. Label-Set to use.
* @param string|null $license Optional. The desired license for the repository.
* @param string|null $readme Optional. Readme of the repository to create.
* @param bool|null $template Optional. Set to true if the repository is a template.
* @param string|null $trustModel Optional. TrustModel of the repository.
*
* @return object|null
* @since 3.2.0
**/
public function create(
string $name,
?string $description = null,
?bool $private = null,
?bool $autoInit = null,
?string $defaultBranch = null,
?string $gitignores = null,
?string $issueLabels = null,
?string $license = null,
?string $readme = null,
?bool $template = null,
?string $trustModel = null
): ?object {
// Build the request path.
$path = "/user/repos";
// Set the repo data.
$data = new \stdClass();
$data->name = $name;
if ($description !== null)
{
$data->description = $description;
}
if ($private !== null)
{
$data->private = $private;
}
if ($autoInit !== null)
{
$data->auto_init = $autoInit;
}
if ($defaultBranch !== null)
{
$data->default_branch = $defaultBranch;
}
if ($gitignores !== null)
{
$data->gitignores = $gitignores;
}
if ($issueLabels !== null)
{
$data->issue_labels = $issueLabels;
}
if ($license !== null)
{
$data->license = $license;
}
if ($readme !== null)
{
$data->readme = $readme;
}
if ($template !== null)
{
$data->template = $template;
}
if ($trustModel !== null)
{
$data->trust_model = $trustModel;
}
// Send the post request.
return $this->response->get(
$this->http->post(
$this->uri->get($path),
json_encode($data)
), 201
);
}