gitverse-sdk 1.2.0

Rust SDK for GitVerse API
Documentation
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
// Code generated by gitverse-codegen. DO NOT EDIT.

use crate::client::{Client, decode_response, handle_empty_response};
use crate::errors::Error;
use crate::types::*;

impl Client {
    /// Returns a list of self-hosted runners for an organization
    pub async fn list_org_runners(
        &self,
        org: &str,
        opts: Option<&QueryOptions>,
    ) -> Result<ActionRunners, Error> {
        let path = format!("/orgs/{}/actions/runners", org);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Creates a registration token for an organization runner
    pub async fn create_org_runner_registration_token(
        &self,
        org: &str,
    ) -> Result<RegistrationToken, Error> {
        let path = format!("/orgs/{}/actions/runners/registration-token", org);
        let resp = self.send_post(&path, Option::<&()>::None).await?;
        decode_response(resp).await
    }

    /// Gets a specific self-hosted runner for an organization
    pub async fn get_org_runner(&self, org: &str, runner_id: f64) -> Result<ActionRunner, Error> {
        let path = format!("/orgs/{}/actions/runners/{}", org, runner_id);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// Deletes a specific self-hosted runner from the organization
    pub async fn delete_org_runner(&self, org: &str, runner_id: f64) -> Result<(), Error> {
        let path = format!("/orgs/{}/actions/runners/{}", org, runner_id);
        let resp = self.send_delete(&path, Option::<&()>::None).await?;
        handle_empty_response(resp).await
    }

    /// List organization variables
    pub async fn list_org_variables(
        &self,
        org: &str,
        opts: Option<&QueryOptions>,
    ) -> Result<VariableList, Error> {
        let path = format!("/orgs/{}/actions/variables", org);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Create an organization variable
    pub async fn create_org_variable(
        &self,
        org: &str,
        params: &CreateVariableParams,
    ) -> Result<(), Error> {
        let path = format!("/orgs/{}/actions/variables", org);
        let resp = self.send_post(&path, Some(params)).await?;
        handle_empty_response(resp).await
    }

    /// Get an organization variable
    pub async fn get_org_variable(&self, org: &str, name: &str) -> Result<Variable, Error> {
        let path = format!("/orgs/{}/actions/variables/{}", org, name);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// Update an organization variable
    pub async fn update_org_variable(
        &self,
        org: &str,
        name: &str,
        params: &CreateVariableParams,
    ) -> Result<(), Error> {
        let path = format!("/orgs/{}/actions/variables/{}", org, name);
        let resp = self.send_patch(&path, Some(params)).await?;
        handle_empty_response(resp).await
    }

    /// Delete an organization variable
    pub async fn delete_org_variable(&self, org: &str, name: &str) -> Result<(), Error> {
        let path = format!("/orgs/{}/actions/variables/{}", org, name);
        let resp = self.send_delete(&path, Option::<&()>::None).await?;
        handle_empty_response(resp).await
    }

    /// Returns a list of artifacts in the repository
    pub async fn list_artifacts(
        &self,
        owner: &str,
        repo: &str,
        opts: Option<&QueryOptions>,
    ) -> Result<ActionArtifactList, Error> {
        let path = format!("/repos/{}/{}/actions/artifacts", owner, repo);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Returns a specific artifact from the repository
    pub async fn get_artifact(
        &self,
        owner: &str,
        repo: &str,
        artifact_id: &str,
    ) -> Result<ActionArtifact, Error> {
        let path = format!(
            "/repos/{}/{}/actions/artifacts/{}",
            owner, repo, artifact_id
        );
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// Deletes a specific artifact
    pub async fn delete_artifact(
        &self,
        owner: &str,
        repo: &str,
        artifact_id: &str,
    ) -> Result<(), Error> {
        let path = format!(
            "/repos/{}/{}/actions/artifacts/{}",
            owner, repo, artifact_id
        );
        let resp = self.send_delete(&path, Option::<&()>::None).await?;
        handle_empty_response(resp).await
    }

    /// Downloads a specific artifact as a ZIP archive
    pub async fn download_artifact(
        &self,
        owner: &str,
        repo: &str,
        artifact_id: &str,
    ) -> Result<(), Error> {
        let path = format!(
            "/repos/{}/{}/actions/artifacts/{}/zip",
            owner, repo, artifact_id
        );
        let resp = self.send_get(&path, None).await?;
        handle_empty_response(resp).await
    }

    /// Downloads the artifact ZIP archive directly
    pub async fn download_artifact_raw(
        &self,
        owner: &str,
        repo: &str,
        artifact_id: &str,
    ) -> Result<String, Error> {
        let path = format!(
            "/repos/{}/{}/actions/artifacts/{}/zip/raw",
            owner, repo, artifact_id
        );
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// Get a workflow run job
    pub async fn get_workflow_job(
        &self,
        owner: &str,
        repo: &str,
        job_id: f64,
    ) -> Result<ActionRunJob, Error> {
        let path = format!("/repos/{}/{}/actions/jobs/{}", owner, repo, job_id);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// Get workflow run job logs
    pub async fn get_workflow_job_logs(
        &self,
        owner: &str,
        repo: &str,
        job_id: f64,
    ) -> Result<(), Error> {
        let path = format!("/repos/{}/{}/actions/jobs/{}/logs", owner, repo, job_id);
        let resp = self.send_get(&path, None).await?;
        handle_empty_response(resp).await
    }

    /// Adds a link to an action run
    pub async fn create_action_link(
        &self,
        owner: &str,
        repo: &str,
        params: &CreateActionLinkParams,
    ) -> Result<ActionLink, Error> {
        let path = format!("/repos/{}/{}/actions/links", owner, repo);
        let resp = self.send_post(&path, Some(params)).await?;
        decode_response(resp).await
    }

    /// Returns a list of runners for the repository
    pub async fn list_repo_runners(
        &self,
        owner: &str,
        repo: &str,
        opts: Option<&QueryOptions>,
    ) -> Result<ActionRunners, Error> {
        let path = format!("/repos/{}/{}/actions/runners", owner, repo);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Creates a registration token for a repository runner
    pub async fn create_repo_runner_registration_token(
        &self,
        owner: &str,
        repo: &str,
    ) -> Result<RegistrationToken, Error> {
        let path = format!(
            "/repos/{}/{}/actions/runners/registration-token",
            owner, repo
        );
        let resp = self.send_post(&path, Option::<&()>::None).await?;
        decode_response(resp).await
    }

    /// Gets a specific runner for a repository
    pub async fn get_repo_runner(
        &self,
        owner: &str,
        repo: &str,
        runner_id: f64,
    ) -> Result<ActionRunner, Error> {
        let path = format!("/repos/{}/{}/actions/runners/{}", owner, repo, runner_id);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// Deletes a specific self-hosted runner from the repository
    pub async fn delete_repo_runner(
        &self,
        owner: &str,
        repo: &str,
        runner_id: f64,
    ) -> Result<(), Error> {
        let path = format!("/repos/{}/{}/actions/runners/{}", owner, repo, runner_id);
        let resp = self.send_delete(&path, Option::<&()>::None).await?;
        handle_empty_response(resp).await
    }

    /// List workflow runs
    pub async fn list_workflow_runs(
        &self,
        owner: &str,
        repo: &str,
        opts: Option<&QueryOptions>,
    ) -> Result<RunsResponse, Error> {
        let path = format!("/repos/{}/{}/actions/runs", owner, repo);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Get a workflow run by index
    pub async fn get_workflow_run_by_index(
        &self,
        owner: &str,
        repo: &str,
        run_index: f64,
    ) -> Result<ActionRun, Error> {
        let path = format!("/repos/{}/{}/actions/runs/index/{}", owner, repo, run_index);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// List workflow run jobs by index
    pub async fn list_workflow_run_jobs_by_index(
        &self,
        owner: &str,
        repo: &str,
        run_index: f64,
        opts: Option<&QueryOptions>,
    ) -> Result<JobsResponse, Error> {
        let path = format!(
            "/repos/{}/{}/actions/runs/index/{}/jobs",
            owner, repo, run_index
        );
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Get a workflow run
    pub async fn get_workflow_run(
        &self,
        owner: &str,
        repo: &str,
        run_id: f64,
    ) -> Result<ActionRun, Error> {
        let path = format!("/repos/{}/{}/actions/runs/{}", owner, repo, run_id);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// List workflow run jobs
    pub async fn list_workflow_run_jobs(
        &self,
        owner: &str,
        repo: &str,
        run_id: f64,
        opts: Option<&QueryOptions>,
    ) -> Result<JobsResponse, Error> {
        let path = format!("/repos/{}/{}/actions/runs/{}/jobs", owner, repo, run_id);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// List repository variables
    pub async fn list_repo_variables(
        &self,
        owner: &str,
        repo: &str,
        opts: Option<&QueryOptions>,
    ) -> Result<VariableList, Error> {
        let path = format!("/repos/{}/{}/actions/variables", owner, repo);
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Create a repository variable
    pub async fn create_repo_variable(
        &self,
        owner: &str,
        repo: &str,
        params: &CreateVariableParams,
    ) -> Result<(), Error> {
        let path = format!("/repos/{}/{}/actions/variables", owner, repo);
        let resp = self.send_post(&path, Some(params)).await?;
        handle_empty_response(resp).await
    }

    /// Get a repository variable
    pub async fn get_repo_variable(
        &self,
        owner: &str,
        repo: &str,
        name: &str,
    ) -> Result<Variable, Error> {
        let path = format!("/repos/{}/{}/actions/variables/{}", owner, repo, name);
        let resp = self.send_get(&path, None).await?;
        decode_response(resp).await
    }

    /// Update a repository variable
    pub async fn update_repo_variable(
        &self,
        owner: &str,
        repo: &str,
        name: &str,
        params: &CreateVariableParams,
    ) -> Result<(), Error> {
        let path = format!("/repos/{}/{}/actions/variables/{}", owner, repo, name);
        let resp = self.send_patch(&path, Some(params)).await?;
        handle_empty_response(resp).await
    }

    /// Delete a repository variable
    pub async fn delete_repo_variable(
        &self,
        owner: &str,
        repo: &str,
        name: &str,
    ) -> Result<(), Error> {
        let path = format!("/repos/{}/{}/actions/variables/{}", owner, repo, name);
        let resp = self.send_delete(&path, Option::<&()>::None).await?;
        handle_empty_response(resp).await
    }

    /// Get workflow_dispatch parameters
    pub async fn get_workflow_dispatch_inputs(
        &self,
        owner: &str,
        repo: &str,
        workflow: &str,
        opts: Option<&QueryOptions>,
    ) -> Result<WorkflowDispatchInputList, Error> {
        let path = format!(
            "/repos/{}/{}/actions/workflows/{}/dispatches",
            owner, repo, workflow
        );
        let resp = self.send_get(&path, opts).await?;
        decode_response(resp).await
    }

    /// Trigger workflow_dispatch
    pub async fn dispatch_workflow(
        &self,
        owner: &str,
        repo: &str,
        workflow: &str,
        params: &serde_json::Value,
        _opts: Option<&QueryOptions>,
    ) -> Result<(), Error> {
        let path = format!(
            "/repos/{}/{}/actions/workflows/{}/dispatches",
            owner, repo, workflow
        );
        let resp = self.send_post(&path, Some(params)).await?;
        handle_empty_response(resp).await
    }
}