-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathObservableActionsWorkflowsClient.cs
More file actions
281 lines (247 loc) · 13.2 KB
/
ObservableActionsWorkflowsClient.cs
File metadata and controls
281 lines (247 loc) · 13.2 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
using System;
using System.Reactive;
using System.Reactive.Threading.Tasks;
namespace Octokit.Reactive
{
public class ObservableActionsWorkflowsClient : IObservableActionsWorkflowsClient
{
readonly IActionsWorkflowsClient _client;
/// <summary>
/// Instantiate a new GitHub Actions Workflows API client.
/// </summary>
/// <param name="client">A GitHub client.</param>
public ObservableActionsWorkflowsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.Actions.Workflows;
Jobs = new ObservableActionsWorkflowJobsClient(client);
Runs = new ObservableActionsWorkflowRunsClient(client);
}
/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by slug.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowFileName">The workflow file name.</param>
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
public IObservable<Unit> CreateDispatch(string owner, string name, string workflowFileName, CreateWorkflowDispatch createDispatch)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));
return _client.CreateDispatch(owner, name, workflowFileName, createDispatch).ToObservable();
}
/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by slug.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowId">The Id of the workflow.</param>
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
public IObservable<Unit> CreateDispatch(string owner, string name, long workflowId, CreateWorkflowDispatch createDispatch)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));
return _client.CreateDispatch(owner, name, workflowId, createDispatch).ToObservable();
}
/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by slug.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
/// </remarks>
/// <param name="repositoryId">The Id of the repository.</param>
/// <param name="workflowFileName">The workflow file name.</param>
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
public IObservable<Unit> CreateDispatch(long repositoryId, string workflowFileName, CreateWorkflowDispatch createDispatch)
{
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));
return _client.CreateDispatch(repositoryId, workflowFileName, createDispatch).ToObservable();
}
/// <summary>
/// Manually triggers a GitHub Actions workflow run in a repository by Id.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#create-a-workflow-dispatch-event
/// </remarks>
/// <param name="repositoryId">The Id of the repository.</param>
/// <param name="workflowId">The Id of the workflow.</param>
/// <param name="createDispatch">The parameters to use to trigger the workflow run.</param>
public IObservable<Unit> CreateDispatch(long repositoryId, long workflowId, CreateWorkflowDispatch createDispatch)
{
Ensure.ArgumentNotNull(createDispatch, nameof(createDispatch));
return _client.CreateDispatch(repositoryId, workflowId, createDispatch).ToObservable();
}
/// <summary>
/// Disables a specific workflow in a repository by Id.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowFileName">The workflow file name.</param>
public IObservable<Unit> Disable(string owner, string name, string workflowFileName)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
return _client.Disable(owner, name, workflowFileName).ToObservable();
}
/// <summary>
/// Disables a specific workflow in a repository by Id.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#disable-a-workflow
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowId">The Id of the workflow.</param>
public IObservable<Unit> Disable(string owner, string name, long workflowId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return _client.Disable(owner, name, workflowId).ToObservable();
}
/// <summary>
/// Enables a specific workflow in a repository by Id.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowFileName">The workflow file name.</param>
public IObservable<Unit> Enable(string owner, string name, string workflowFileName)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
return _client.Enable(owner, name, workflowFileName).ToObservable();
}
/// <summary>
/// Enables a specific workflow in a repository by Id.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#enable-a-workflow
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowId">The Id of the workflow.</param>
public IObservable<Unit> Enable(string owner, string name, long workflowId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return _client.Enable(owner, name, workflowId).ToObservable();
}
/// <summary>
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowFileName">The workflow file name.</param>
public IObservable<Workflow> Get(string owner, string name, string workflowFileName)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
return _client.Get(owner, name, workflowFileName).ToObservable();
}
/// <summary>
/// Gets a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#get-a-workflow
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowId">The Id of the workflow.</param>
public IObservable<Workflow> Get(string owner, string name, long workflowId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return _client.Get(owner, name, workflowId).ToObservable();
}
/// <summary>
/// Gets usage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowFileName">The workflow file name.</param>
public IObservable<WorkflowUsage> GetUsage(string owner, string name, string workflowFileName)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(workflowFileName, nameof(workflowFileName));
return _client.GetUsage(owner, name, workflowFileName).ToObservable();
}
/// <summary>
/// Gets usage of a specific workflow in a repository by Id. Anyone with read access to the repository can use this endpoint.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#get-workflow-usage
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="workflowId">The Id of the workflow.</param>
public IObservable<WorkflowUsage> GetUsage(string owner, string name, long workflowId)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return _client.GetUsage(owner, name, workflowId).ToObservable();
}
/// <summary>
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
public IObservable<WorkflowsResponse> List(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return _client.List(owner, name).ToObservable();
}
/// <summary>
/// Lists the workflows in a repository. Anyone with read access to the repository can use this endpoint.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/actions/workflows/#list-repository-workflows
/// </remarks>
/// <param name="owner">The owner of the repository.</param>
/// <param name="name">The name of the repository.</param>
/// <param name="options">Options to change the API response.</param>
public IObservable<WorkflowsResponse> List(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return _client.List(owner, name, options).ToObservable();
}
/// <summary>
/// Client for the Workflow jobs API.
/// </summary>
public IObservableActionsWorkflowJobsClient Jobs { get; private set; }
/// <summary>
/// Client for the Workflow runs API.
/// </summary>
public IObservableActionsWorkflowRunsClient Runs { get; private set; }
}
}