-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.power
More file actions
118 lines (113 loc) · 3.17 KB
/
code.power
File metadata and controls
118 lines (113 loc) · 3.17 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
/**
* List an organization's repos.
*
* @param string $org The organization name.
* @param int $pageNumber The page number.
* @param int $pageSize The page size of results.
*
* @return array|null
* @since 3.2.0
**/
public function list(
string $org,
int $pageNumber = 1,
int $pageSize = 10
): ?array
{
// Build the request path.
$path = "/orgs/{$org}/repos";
// Configure the request URI.
$uri = $this->uri->get($path);
$uri->setVar('page', $pageNumber);
$uri->setVar('limit', $pageSize);
// Send the get request.
return $this->response->get(
$this->http->get($uri)
);
}
/**
* Create a repository in an organization.
*
* @param string $org The organization name.
* @param string $repoName The name of the repository.
* @param string|null $description The description of the repository (optional).
* @param bool|null $autoInit Whether the repository should be auto-initialized (optional).
* @param string|null $defaultBranch Default branch of the repository (optional).
* @param string|null $gitignores Gitignores to use (optional).
* @param string|null $issueLabels Label-set to use (optional).
* @param string|null $license License to use (optional).
* @param bool|null $private Whether the repository is private (optional).
* @param string|null $readme Readme of the repository to create (optional).
* @param bool|null $template Whether the repository is a template (optional).
* @param string|null $trustModel Trust model of the repository (optional).
*
* @return object|null
* @since 3.2.0
**/
public function create(
string $org,
string $repoName,
?string $description = null,
?bool $autoInit = null,
?string $defaultBranch = null,
?string $gitignores = null,
?string $issueLabels = null,
?string $license = null,
?bool $private = null,
?string $readme = null,
?bool $template = null,
?string $trustModel = null
): ?object
{
// Build the request path.
$path = "/orgs/{$org}/repos";
// Set the repository data.
$data = new \stdClass();
$data->name = $repoName;
if ($description !== null)
{
$data->description = $description;
}
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 ($private !== null)
{
$data->private = $private;
}
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)
)
);
}