cnb 0.2.2

CNB (cnb.cool) API client for Rust — typed, async, production-ready
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
// @generated DO NOT EDIT.
//
// Generated from the CNB OpenAPI specification by `cnb-codegen`.
// Run `cargo run -p cnb-codegen --manifest-path codegen/Cargo.toml \
//      -- --spec codegen/spec/swagger.json --out src` to refresh.

#![allow(clippy::all)]
#![allow(missing_docs)]
#![allow(unused_imports)]
#![allow(unused_mut)]

use reqwest::Method;
use serde::Serialize;

use crate::error::{ApiError, Result};
use crate::http::HttpInner;
use crate::models;

// `Git` resource client (generated, 35 operations).

/// Resource client.
#[derive(Debug, Clone)]
pub struct GitClient {
    inner: HttpInner,
}

impl GitClient {
    /// Construct a new resource client. Normally obtained
    /// via [`crate::ApiClient`] rather than directly.
    pub fn new(inner: HttpInner) -> Self {
        Self { inner }
    }

    /// 创建一个 blob。Create a blob.
    ///
    /// `POST /{repo}/-/git/blobs`
    pub async fn create_blob(
        &self,
        repo: String,
        body: &crate::models::PostBlobForm,
    ) -> Result<crate::models::Blob> {
        let path = format!("/{}/-/git/blobs", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Blob, _>(Method::POST, url, body)
            .await
    }

    /// 创建新分支。Create a new branch based on a start point.
    ///
    /// `POST /{repo}/-/git/branches`
    pub async fn create_branch(
        &self,
        repo: String,
        body: &crate::models::CreateBranchForm,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/branches", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<serde_json::Value, _>(Method::POST, url, body)
            .await
    }

    /// 锁定分支
    ///
    /// `POST /{repo}/-/git/branch-locks/{branch}`
    pub async fn create_branch_lock(
        &self,
        repo: String,
        branch: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/branch-locks/{}", repo, branch);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::POST, url)
            .await
    }

    /// 创建一个 tag。Create a tag.
    ///
    /// `POST /{repo}/-/git/tags`
    pub async fn create_tag(
        &self,
        repo: String,
        body: &crate::models::PostTagFrom,
    ) -> Result<crate::models::Tag> {
        let path = format!("/{}/-/git/tags", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::Tag, _>(Method::POST, url, body)
            .await
    }

    /// 删除指定分支。Delete the specified branch.
    ///
    /// `DELETE /{repo}/-/git/branches/{branch}`
    pub async fn delete_branch(&self, repo: String, branch: String) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/branches/{}", repo, branch);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 解除锁定分支
    ///
    /// `DELETE /{repo}/-/git/branch-locks/{branch}`
    pub async fn delete_branch_lock(
        &self,
        repo: String,
        branch: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/branch-locks/{}", repo, branch);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除指定 commit 的元数据。Delete commit annotation.
    ///
    /// `DELETE /{repo}/-/git/commit-annotations/{sha}/{key}`
    pub async fn delete_commit_annotation(
        &self,
        repo: String,
        sha: String,
        key: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/commit-annotations/{}/{}", repo, sha, key);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除指定 commit 的附件。Delete commit asset.
    ///
    /// `DELETE /{repo}/-/git/commit-assets/{sha1}/{asset_id}`
    pub async fn delete_commit_asset(
        &self,
        repo: String,
        sha1: String,
        asset_id: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/commit-assets/{}/{}", repo, sha1, asset_id);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除指定 tag。Delete the specified tag.
    ///
    /// `DELETE /{repo}/-/git/tags/{tag}`
    pub async fn delete_tag(&self, repo: String, tag: String) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/tags/{}", repo, tag);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 删除指定 tag 的元数据。Delete the metadata of the specified tag.
    ///
    /// `DELETE /{repo}/-/git/tag-annotations/{tag_with_key}`
    pub async fn delete_tag_annotation(
        &self,
        repo: String,
        tag_with_key: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/tag-annotations/{}", repo, tag_with_key);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::DELETE, url)
            .await
    }

    /// 下载仓库内容
    ///
    /// `GET /{repo}/-/git/archive/{ref_with_path}`
    pub async fn get_archive(
        &self,
        repo: String,
        ref_with_path: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/archive/{}", repo, ref_with_path);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 打包下载 commit 变更文件。Download archive of changed files for a commit.
    ///
    /// `GET /{repo}/-/git/archive-commit-changed-files/{sha1}`
    pub async fn get_archive_commit_changed_files(
        &self,
        repo: String,
        sha1: String,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/archive-commit-changed-files/{}", repo, sha1);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 打包下载两次 ref 之间的变更文件。Download archive of changed files for a compare.
    ///
    /// `GET /{repo}/-/git/archive-compare-changed-files/{base_head}`
    pub async fn get_archive_compare_changed_files(
        &self,
        repo: String,
        base_head: String,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/{}/-/git/archive-compare-changed-files/{}",
            repo, base_head
        );
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 查询指定分支。Get a branch.
    ///
    /// `GET /{repo}/-/git/branches/{branch}`
    pub async fn get_branch(
        &self,
        repo: String,
        branch: String,
    ) -> Result<crate::models::BranchDetail> {
        let path = format!("/{}/-/git/branches/{}", repo, branch);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::BranchDetail>(Method::GET, url)
            .await
    }

    /// 查询指定 commit。Get a commit.
    ///
    /// `GET /{repo}/-/git/commits/{ref}`
    pub async fn get_commit(&self, repo: String, ref_: String) -> Result<crate::models::Commit> {
        let path = format!("/{}/-/git/commits/{}", repo, ref_);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::Commit>(Method::GET, url)
            .await
    }

    /// 查询指定 commit 的元数据。Get commit annotations.
    ///
    /// `GET /{repo}/-/git/commit-annotations/{sha}`
    pub async fn get_commit_annotations(
        &self,
        repo: String,
        sha: String,
    ) -> Result<Vec<crate::models::CommitAnnotation>> {
        let path = format!("/{}/-/git/commit-annotations/{}", repo, sha);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::CommitAnnotation>>(Method::GET, url)
            .await
    }

    /// 查询指定 commit 的元数据。Get commit annotations in batch.
    ///
    /// `POST /{repo}/-/git/commit-annotations-in-batch`
    pub async fn get_commit_annotations_in_batch(
        &self,
        repo: String,
        body: &crate::models::GetCommitAnnotationsInBatchForm,
    ) -> Result<Vec<crate::models::CommitAnnotationInBatch>> {
        let path = format!("/{}/-/git/commit-annotations-in-batch", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<Vec<crate::models::CommitAnnotationInBatch>, _>(
                Method::POST,
                url,
                body,
            )
            .await
    }

    /// 发起一个获取 commits 附件的请求, 302到有一定效期的下载地址。Get a request to fetch a commit assets and returns 302 redirect to the assets URL with specific valid time.
    ///
    /// `GET /{repo}/-/commit-assets/download/{commit_id}/{filename}`
    pub async fn get_commit_assets(
        &self,
        repo: String,
        commit_id: String,
        filename: String,
        query: &GetCommitAssetsQuery,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/{}/-/commit-assets/download/{}/{}",
            repo, commit_id, filename
        );
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.share {
                pairs.append_pair("share", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 查询指定 commit 的附件。List commit assets.
    ///
    /// `GET /{repo}/-/git/commit-assets/{sha1}`
    pub async fn get_commit_assets_by_sha(
        &self,
        repo: String,
        sha1: String,
    ) -> Result<Vec<crate::models::CommitAsset>> {
        let path = format!("/{}/-/git/commit-assets/{}", repo, sha1);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::CommitAsset>>(Method::GET, url)
            .await
    }

    /// 查询指定 commit 的提交状态。List commit check statuses.
    ///
    /// `GET /{repo}/-/git/commit-statuses/{commitish}`
    pub async fn get_commit_statuses(
        &self,
        repo: String,
        commitish: String,
    ) -> Result<Vec<crate::models::CommitStatus>> {
        let path = format!("/{}/-/git/commit-statuses/{}", repo, commitish);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::CommitStatus>>(Method::GET, url)
            .await
    }

    /// 比较两个提交、分支或标签之间差异的接口。Compare two commits, branches, or tags.
    ///
    /// `GET /{repo}/-/git/compare/{base_head}`
    pub async fn get_compare_commits(
        &self,
        repo: String,
        base_head: String,
    ) -> Result<crate::models::CompareResponse> {
        let path = format!("/{}/-/git/compare/{}", repo, base_head);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::CompareResponse>(Method::GET, url)
            .await
    }

    /// 查询仓库文件列表或文件。List repository files or file.
    ///
    /// `GET /{repo}/-/git/contents/{file_path}`
    pub async fn get_content(
        &self,
        repo: String,
        file_path: String,
        query: &GetContentQuery,
    ) -> Result<crate::models::Content> {
        let path = format!("/{}/-/git/contents/{}", repo, file_path);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.ref_ {
                pairs.append_pair("ref", v);
            }
            drop(pairs);
        }
        self.inner
            .execute::<crate::models::Content>(Method::GET, url)
            .await
    }

    /// 查询仓库文件和目录内容。List repository files and directories.
    ///
    /// `GET /{repo}/-/git/contents`
    pub async fn get_content_without_path(
        &self,
        repo: String,
        query: &GetContentWithoutPathQuery,
    ) -> Result<crate::models::Content> {
        let path = format!("/{}/-/git/contents", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.ref_ {
                pairs.append_pair("ref", v);
            }
            drop(pairs);
        }
        self.inner
            .execute::<crate::models::Content>(Method::GET, url)
            .await
    }

    /// 获取仓库默认分支。Get the default branch of the repository.
    ///
    /// `GET /{repo}/-/git/head`
    pub async fn get_head(&self, repo: String) -> Result<crate::models::HeadRef> {
        let path = format!("/{}/-/git/head", repo);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::HeadRef>(Method::GET, url)
            .await
    }

    /// 获取 git lfs 文件下载链接
    ///
    /// `GET /{slug}/-/lfs/{oid}`
    pub async fn get_presigned_lfs_download_link(
        &self,
        slug: String,
        oid: String,
        query: &GetPresignedLFSDownloadLinkQuery,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/lfs/{}", slug, oid);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.name {
                pairs.append_pair("name", v);
            }
            drop(pairs);
        }
        self.inner
            .execute::<serde_json::Value>(Method::GET, url)
            .await
    }

    /// 获得仓库指定文件内容
    ///
    /// `GET /{repo}/-/git/raw/{ref_with_path}`
    pub async fn get_raw(
        &self,
        repo: String,
        ref_with_path: String,
        query: &GetRawQuery,
    ) -> Result<String> {
        let path = format!("/{}/-/git/raw/{}", repo, ref_with_path);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.max_in_byte {
                pairs.append_pair("max_in_byte", &v.to_string());
            }
            drop(pairs);
        }
        self.inner.execute::<String>(Method::GET, url).await
    }

    /// 查询指定 tag。Get a tag.
    ///
    /// `GET /{repo}/-/git/tags/{tag}`
    pub async fn get_tag(&self, repo: String, tag: String) -> Result<crate::models::Tag> {
        let path = format!("/{}/-/git/tags/{}", repo, tag);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<crate::models::Tag>(Method::GET, url)
            .await
    }

    /// 查询指定 tag 的元数据。Query the metadata of the specified tag.
    ///
    /// `GET /{repo}/-/git/tag-annotations/{tag}`
    pub async fn get_tag_annotations(
        &self,
        repo: String,
        tag: String,
    ) -> Result<Vec<crate::models::TagAnnotation>> {
        let path = format!("/{}/-/git/tag-annotations/{}", repo, tag);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute::<Vec<crate::models::TagAnnotation>>(Method::GET, url)
            .await
    }

    /// 查询分支列表。List branches.
    ///
    /// `GET /{repo}/-/git/branches`
    pub async fn list_branches(
        &self,
        repo: String,
        query: &ListBranchesQuery,
    ) -> Result<Vec<crate::models::Branch>> {
        let path = format!("/{}/-/git/branches", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.page {
                pairs.append_pair("page", &v.to_string());
            }
            if let Some(v) = query.page_size {
                pairs.append_pair("page_size", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<Vec<crate::models::Branch>>(Method::GET, url)
            .await
    }

    /// 查询 commit 列表。List commits.
    ///
    /// `GET /{repo}/-/git/commits`
    pub async fn list_commits(
        &self,
        repo: String,
        query: &ListCommitsQuery,
    ) -> Result<Vec<crate::models::Commit>> {
        let path = format!("/{}/-/git/commits", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(ref v) = query.sha {
                pairs.append_pair("sha", v);
            }
            if let Some(ref v) = query.author {
                pairs.append_pair("author", v);
            }
            if let Some(ref v) = query.committer {
                pairs.append_pair("committer", v);
            }
            if let Some(ref v) = query.since {
                pairs.append_pair("since", v);
            }
            if let Some(ref v) = query.until {
                pairs.append_pair("until", v);
            }
            if let Some(v) = query.page {
                pairs.append_pair("page", &v.to_string());
            }
            if let Some(v) = query.page_size {
                pairs.append_pair("page_size", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<Vec<crate::models::Commit>>(Method::GET, url)
            .await
    }

    /// 查询 tag 列表。List tags.
    ///
    /// `GET /{repo}/-/git/tags`
    pub async fn list_tags(
        &self,
        repo: String,
        query: &ListTagsQuery,
    ) -> Result<Vec<crate::models::Tag>> {
        let path = format!("/{}/-/git/tags", repo);
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.page {
                pairs.append_pair("page", &v.to_string());
            }
            if let Some(v) = query.page_size {
                pairs.append_pair("page_size", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<Vec<crate::models::Tag>>(Method::GET, url)
            .await
    }

    /// 确认 commit 附件上传完成。Confirm commit asset upload.
    ///
    /// `POST /{repo}/-/git/commit-assets/{sha1}/asset-upload-confirmation/{upload_token}/{asset_path}`
    pub async fn post_commit_asset_upload_confirmation(
        &self,
        repo: String,
        sha1: String,
        upload_token: String,
        asset_path: String,
        query: &PostCommitAssetUploadConfirmationQuery,
    ) -> Result<serde_json::Value> {
        let path = format!(
            "/{}/-/git/commit-assets/{}/asset-upload-confirmation/{}/{}",
            repo, sha1, upload_token, asset_path
        );
        let mut url = self.inner.url(&path)?;
        {
            let mut pairs = url.query_pairs_mut();
            if let Some(v) = query.ttl {
                pairs.append_pair("ttl", &v.to_string());
            }
            drop(pairs);
        }
        self.inner
            .execute::<serde_json::Value>(Method::POST, url)
            .await
    }

    /// 新增一个 commit 附件。Create a commit asset.
    ///
    /// `POST /{repo}/-/git/commit-assets/{sha1}/asset-upload-url`
    pub async fn post_commit_asset_upload_url(
        &self,
        repo: String,
        sha1: String,
        body: &crate::models::PostCommitAssetUploadUrlForm,
    ) -> Result<crate::models::CommitAssetUploadUrl> {
        let path = format!("/{}/-/git/commit-assets/{}/asset-upload-url", repo, sha1);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<crate::models::CommitAssetUploadUrl, _>(Method::POST, url, body)
            .await
    }

    /// 设定指定 commit 的元数据。Put commit annotations.
    ///
    /// `PUT /{repo}/-/git/commit-annotations/{sha}`
    pub async fn put_commit_annotations(
        &self,
        repo: String,
        sha: String,
        body: &crate::models::PutCommitAnnotationsForm,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/commit-annotations/{}", repo, sha);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<serde_json::Value, _>(Method::PUT, url, body)
            .await
    }

    /// 设定指定 tag 的元数据。Set the metadata of the specified tag.
    ///
    /// `PUT /{repo}/-/git/tag-annotations/{tag}`
    pub async fn put_tag_annotations(
        &self,
        repo: String,
        tag: String,
        body: &crate::models::PutTagAnnotationsForm,
    ) -> Result<serde_json::Value> {
        let path = format!("/{}/-/git/tag-annotations/{}", repo, tag);
        let mut url = self.inner.url(&path)?;
        self.inner
            .execute_with_body::<serde_json::Value, _>(Method::PUT, url, body)
            .await
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct GetCommitAssetsQuery {
    /// 是否可以下载,true表示302的下载地址有效期12小时,最多下载10次。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub share: Option<bool>,
}

impl GetCommitAssetsQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `share` query parameter.
    pub fn share(mut self, v: impl Into<bool>) -> Self {
        self.share = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct GetContentQuery {
    /// 提交的哈希值或分支名称。
    #[serde(rename = "ref", default, skip_serializing_if = "Option::is_none")]
    pub ref_: Option<String>,
}

impl GetContentQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `ref` query parameter.
    pub fn ref_(mut self, v: impl Into<String>) -> Self {
        self.ref_ = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct GetContentWithoutPathQuery {
    /// 提交的哈希值或分支名称。
    #[serde(rename = "ref", default, skip_serializing_if = "Option::is_none")]
    pub ref_: Option<String>,
}

impl GetContentWithoutPathQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `ref` query parameter.
    pub fn ref_(mut self, v: impl Into<String>) -> Self {
        self.ref_ = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct GetPresignedLFSDownloadLinkQuery {
    /// LFS文件名称。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
}

impl GetPresignedLFSDownloadLinkQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `name` query parameter.
    pub fn name(mut self, v: impl Into<String>) -> Self {
        self.name = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct GetRawQuery {
    /// 获得文件内容大小限制(字节),0表示使用gitConfig.RawFileLimitInByte配置值。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub max_in_byte: Option<i64>,
}

impl GetRawQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `max_in_byte` query parameter.
    pub fn max_in_byte(mut self, v: impl Into<i64>) -> Self {
        self.max_in_byte = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct ListBranchesQuery {
    /// 分页页码。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// 分页页大小。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page_size: Option<i64>,
}

impl ListBranchesQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `page` query parameter.
    pub fn page(mut self, v: impl Into<i64>) -> Self {
        self.page = Some(v.into());
        self
    }
    /// Set `page_size` query parameter.
    pub fn page_size(mut self, v: impl Into<i64>) -> Self {
        self.page_size = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct ListCommitsQuery {
    /// 提交标识符。格式:`分支名称`,`提交哈希值`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sha: Option<String>,
    /// 作者匹配模式,支持Git原生正则表达式匹配作者信息。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub author: Option<String>,
    /// 提交者匹配模式,支持Git原生正则表达式匹配提交者信息。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub committer: Option<String>,
    /// 提交时间起始范围。示例:`2025-01-01T00:00:00Z`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub since: Option<String>,
    /// 提交时间结束范围。示例:`2025-12-31T23:59:59Z`
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub until: Option<String>,
    /// 分页页码。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// 分页页大小。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page_size: Option<i64>,
}

impl ListCommitsQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `sha` query parameter.
    pub fn sha(mut self, v: impl Into<String>) -> Self {
        self.sha = Some(v.into());
        self
    }
    /// Set `author` query parameter.
    pub fn author(mut self, v: impl Into<String>) -> Self {
        self.author = Some(v.into());
        self
    }
    /// Set `committer` query parameter.
    pub fn committer(mut self, v: impl Into<String>) -> Self {
        self.committer = Some(v.into());
        self
    }
    /// Set `since` query parameter.
    pub fn since(mut self, v: impl Into<String>) -> Self {
        self.since = Some(v.into());
        self
    }
    /// Set `until` query parameter.
    pub fn until(mut self, v: impl Into<String>) -> Self {
        self.until = Some(v.into());
        self
    }
    /// Set `page` query parameter.
    pub fn page(mut self, v: impl Into<i64>) -> Self {
        self.page = Some(v.into());
        self
    }
    /// Set `page_size` query parameter.
    pub fn page_size(mut self, v: impl Into<i64>) -> Self {
        self.page_size = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct ListTagsQuery {
    /// 分页页码。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// 分页页大小。
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub page_size: Option<i64>,
}

impl ListTagsQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `page` query parameter.
    pub fn page(mut self, v: impl Into<i64>) -> Self {
        self.page = Some(v.into());
        self
    }
    /// Set `page_size` query parameter.
    pub fn page_size(mut self, v: impl Into<i64>) -> Self {
        self.page_size = Some(v.into());
        self
    }
}

/// Query parameters for the matching method on the resource client.
#[derive(Debug, Clone, Default, Serialize)]
#[non_exhaustive]
pub struct PostCommitAssetUploadConfirmationQuery {
    /// 附件保持的天数。0 表示永久,最大不能超过 180 天
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub ttl: Option<i64>,
}

impl PostCommitAssetUploadConfirmationQuery {
    /// Construct an empty query.
    pub fn new() -> Self {
        Self::default()
    }
    /// Set `ttl` query parameter.
    pub fn ttl(mut self, v: impl Into<i64>) -> Self {
        self.ttl = Some(v.into());
        self
    }
}