From e16066f652521938300d6449cce9a8fa64b36f6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jan 2026 13:21:19 +0000 Subject: [PATCH] Bump gitlab.com/gitlab-org/api/client-go from 1.9.1 to 1.19.0 Bumps [gitlab.com/gitlab-org/api/client-go](https://gitlab.com/gitlab-org/api/client-go) from 1.9.1 to 1.19.0. - [Release notes](https://gitlab.com/gitlab-org/api/client-go/tags) - [Changelog](https://gitlab.com/gitlab-org/api/client-go/blob/main/CHANGELOG.md) - [Commits](https://gitlab.com/gitlab-org/api/client-go/compare/v1.9.1...v1.19.0) --- updated-dependencies: - dependency-name: gitlab.com/gitlab-org/api/client-go dependency-version: 1.19.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 +- go.sum | 10 +- .../google/go-querystring/query/encode.go | 73 +- .../gitlab-org/api/client-go/.gitignore | 1 + .../gitlab-org/api/client-go/.gitlab-ci.yml | 4 +- .../gitlab-org/api/client-go/.golangci.yml | 6 + .../gitlab-org/api/client-go/.tool-versions | 4 +- .../gitlab-org/api/client-go/AGENTS.md | 19 +- .../gitlab-org/api/client-go/CHANGELOG.md | 197 +++ .../gitlab-org/api/client-go/Makefile | 2 +- .../api/client-go/client_options.go | 4 +- .../gitlab-org/api/client-go/commits.go | 4 +- .../api/client-go/dependency_list_export.go | 7 +- .../api/client-go/dependency_proxy.go | 23 +- .../gitlab-org/api/client-go/deploy_tokens.go | 191 +-- .../gitlab-org/api/client-go/discussions.go | 758 ++-------- .../api/client-go/dockerfile_templates.go | 41 +- .../api/client-go/error_tracking.go | 115 +- .../gitlab-org/api/client-go/event_parsing.go | 3 +- .../api/client-go/external_status_checks.go | 291 ++-- .../gitlab-org/api/client-go/feature_flags.go | 69 +- .../api/client-go/freeze_periods.go | 112 +- .../gitlab-org/api/client-go/geo_nodes.go | 145 +- .../gitlab-org/api/client-go/gitlab.go | 42 +- .../gitlab-org/api/client-go/group_badges.go | 139 +- .../gitlab-org/api/client-go/group_hooks.go | 221 +-- .../api/client-go/group_import_export.go | 7 +- .../api/client-go/group_integrations.go | 184 +++ .../api/client-go/group_iterations.go | 29 +- .../gitlab-org/api/client-go/group_labels.go | 122 +- .../api/client-go/group_milestones.go | 180 +-- .../api/client-go/group_serviceaccounts.go | 180 +-- .../gitlab-org/api/client-go/groups.go | 16 +- .../gitlab-org/api/client-go/integrations.go | 212 ++- .../gitlab-org/api/client-go/issue_links.go | 1 + .../gitlab-org/api/client-go/keys.go | 41 +- .../gitlab-org/api/client-go/labels.go | 144 +- .../gitlab-org/api/client-go/license.go | 49 +- .../api/client-go/license_templates.go | 41 +- .../gitlab-org/api/client-go/markdown.go | 18 +- .../api/client-go/merge_request_approvals.go | 221 +-- .../api/client-go/merge_requests.go | 3 + .../gitlab-org/api/client-go/metadata.go | 18 +- .../gitlab-org/api/client-go/notes.go | 446 ++---- .../gitlab-org/api/client-go/notifications.go | 131 +- .../gitlab-org/api/client-go/pagination.go | 2 - .../api/client-go/pipeline_schedules.go | 247 +--- .../gitlab-org/api/client-go/pipelines.go | 247 +--- .../gitlab-org/api/client-go/plan_limits.go | 35 +- .../api/client-go/project_templates.go | 50 +- .../gitlab-org/api/client-go/projects.go | 20 +- .../api/client-go/protected_branches.go | 117 +- .../gitlab-org/api/client-go/releaselinks.go | 129 +- .../gitlab-org/api/client-go/repositories.go | 134 +- .../api/client-go/request_handler.go | 13 + .../api/client-go/runner_controller_tokens.go | 113 ++ .../api/client-go/runner_controllers.go | 137 ++ .../gitlab-org/api/client-go/search.go | 15 +- .../gitlab-org/api/client-go/secure_files.go | 7 +- .../gitlab-org/api/client-go/services.go | 1309 +++++------------ .../gitlab-org/api/client-go/settings.go | 36 +- .../api/client-go/sidekiq_metrics.go | 65 +- .../gitlab-org/api/client-go/system_hooks.go | 85 +- .../gitlab-org/api/client-go/tags.go | 111 +- .../api/client-go/terraform_states.go | 13 +- .../gitlab-org/api/client-go/todos.go | 44 +- .../gitlab-org/api/client-go/validate.go | 52 +- .../gitlab-org/api/client-go/version.go | 18 +- vendor/modules.txt | 6 +- 69 files changed, 2587 insertions(+), 4946 deletions(-) create mode 100644 vendor/gitlab.com/gitlab-org/api/client-go/group_integrations.go create mode 100644 vendor/gitlab.com/gitlab-org/api/client-go/runner_controller_tokens.go create mode 100644 vendor/gitlab.com/gitlab-org/api/client-go/runner_controllers.go diff --git a/go.mod b/go.mod index 4226df8..68ecc8f 100644 --- a/go.mod +++ b/go.mod @@ -17,12 +17,12 @@ require ( golang.org/x/time v0.14.0 // indirect ) -require gitlab.com/gitlab-org/api/client-go v1.9.1 +require gitlab.com/gitlab-org/api/client-go v1.19.0 require ( github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/go-querystring v1.1.0 // indirect + github.com/google/go-querystring v1.2.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect google.golang.org/protobuf v1.36.11 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect diff --git a/go.sum b/go.sum index ded4820..672b658 100644 --- a/go.sum +++ b/go.sum @@ -28,11 +28,11 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= +github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0= +github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU= github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8= github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= @@ -69,8 +69,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -gitlab.com/gitlab-org/api/client-go v1.9.1 h1:tZm+URa36sVy8UCEHQyGGJ8COngV4YqMHpM6k9O5tK8= -gitlab.com/gitlab-org/api/client-go v1.9.1/go.mod h1:71yTJk1lnHCWcZLvM5kPAXzeJ2fn5GjaoV8gTOPd4ME= +gitlab.com/gitlab-org/api/client-go v1.19.0 h1:6gRiXuoVeXbX2ijhpHtgYPWrrmNq0i2eG111O8L7+N4= +gitlab.com/gitlab-org/api/client-go v1.19.0/go.mod h1:ctGKgv9bErQHO0NOrfhoyFtKMAkBhUE7y53F2xHFAkE= go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= diff --git a/vendor/github.com/google/go-querystring/query/encode.go b/vendor/github.com/google/go-querystring/query/encode.go index 91198f8..c936954 100644 --- a/vendor/github.com/google/go-querystring/query/encode.go +++ b/vendor/github.com/google/go-querystring/query/encode.go @@ -6,22 +6,21 @@ // // As a simple example: // -// type Options struct { -// Query string `url:"q"` -// ShowAll bool `url:"all"` -// Page int `url:"page"` -// } +// type Options struct { +// Query string `url:"q"` +// ShowAll bool `url:"all"` +// Page int `url:"page"` +// } // -// opt := Options{ "foo", true, 2 } -// v, _ := query.Values(opt) -// fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2" +// opt := Options{ "foo", true, 2 } +// v, _ := query.Values(opt) +// fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2" // // The exact mapping between Go values and url.Values is described in the // documentation for the Values() function. package query import ( - "bytes" "fmt" "net/url" "reflect" @@ -47,8 +46,8 @@ type Encoder interface { // // Each exported struct field is encoded as a URL parameter unless // -// - the field's tag is "-", or -// - the field is empty and its tag specifies the "omitempty" option +// - the field's tag is "-", or +// - the field is empty and its tag specifies the "omitempty" option // // The empty values are false, 0, any nil pointer or interface value, any array // slice, map, or string of length zero, and any type (such as time.Time) that @@ -59,19 +58,19 @@ type Encoder interface { // field's tag value is the key name, followed by an optional comma and // options. For example: // -// // Field is ignored by this package. -// Field int `url:"-"` +// // Field is ignored by this package. +// Field int `url:"-"` // -// // Field appears as URL parameter "myName". -// Field int `url:"myName"` +// // Field appears as URL parameter "myName". +// Field int `url:"myName"` // -// // Field appears as URL parameter "myName" and the field is omitted if -// // its value is empty -// Field int `url:"myName,omitempty"` +// // Field appears as URL parameter "myName" and the field is omitted if +// // its value is empty +// Field int `url:"myName,omitempty"` // -// // Field appears as URL parameter "Field" (the default), but the field -// // is skipped if empty. Note the leading comma. -// Field int `url:",omitempty"` +// // Field appears as URL parameter "Field" (the default), but the field +// // is skipped if empty. Note the leading comma. +// Field int `url:",omitempty"` // // For encoding individual field values, the following type-dependent rules // apply: @@ -88,8 +87,8 @@ type Encoder interface { // "url" tag) will use the value of the "layout" tag as a layout passed to // time.Format. For example: // -// // Encode a time.Time as YYYY-MM-DD -// Field time.Time `layout:"2006-01-02"` +// // Encode a time.Time as YYYY-MM-DD +// Field time.Time `layout:"2006-01-02"` // // Slice and Array values default to encoding as multiple URL values of the // same name. Including the "comma" option signals that the field should be @@ -103,9 +102,9 @@ type Encoder interface { // from the "url" tag) will use the value of the "del" tag as the delimiter. // For example: // -// // Encode a slice of bools as ints ("1" for true, "0" for false), -// // separated by exclamation points "!". -// Field []bool `url:",int" del:"!"` +// // Encode a slice of bools as ints ("1" for true, "0" for false), +// // separated by exclamation points "!". +// Field []bool `url:",int" del:"!"` // // Anonymous struct fields are usually encoded as if their inner exported // fields were fields in the outer struct, subject to the standard Go @@ -114,10 +113,10 @@ type Encoder interface { // // Non-nil pointer values are encoded as the value pointed to. // -// Nested structs are encoded including parent fields in value names for -// scoping. e.g: +// Nested structs have their fields processed recursively and are encoded +// including parent fields in value names for scoping. For example, // -// "user[name]=acme&user[addr][postcode]=1234&user[addr][city]=SFO" +// "user[name]=acme&user[addr][postcode]=1234&user[addr][city]=SFO" // // All other values are encoded using their default string representation. // @@ -125,6 +124,11 @@ type Encoder interface { // as multiple URL values of the same name. func Values(v interface{}) (url.Values, error) { values := make(url.Values) + + if v == nil { + return values, nil + } + val := reflect.ValueOf(v) for val.Kind() == reflect.Ptr { if val.IsNil() { @@ -133,10 +137,6 @@ func Values(v interface{}) (url.Values, error) { val = val.Elem() } - if v == nil { - return values, nil - } - if val.Kind() != reflect.Struct { return nil, fmt.Errorf("query: Values() expects struct input. Got %v", val.Kind()) } @@ -209,6 +209,11 @@ func reflectValue(values url.Values, val reflect.Value, scope string) error { } if sv.Kind() == reflect.Slice || sv.Kind() == reflect.Array { + if sv.Len() == 0 { + // skip if slice or array is empty + continue + } + var del string if opts.Contains("comma") { del = "," @@ -223,7 +228,7 @@ func reflectValue(values url.Values, val reflect.Value, scope string) error { } if del != "" { - s := new(bytes.Buffer) + s := new(strings.Builder) first := true for i := 0; i < sv.Len(); i++ { if first { diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/.gitignore b/vendor/gitlab.com/gitlab-org/api/client-go/.gitignore index 49b0175..6dc065c 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/.gitignore +++ b/vendor/gitlab.com/gitlab-org/api/client-go/.gitignore @@ -40,3 +40,4 @@ gl-code-quality-report.json .mise/ Gitlab-license.txt +.vscode/ diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/.gitlab-ci.yml b/vendor/gitlab.com/gitlab-org/api/client-go/.gitlab-ci.yml index d5e1a08..1188b7e 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/.gitlab-ci.yml +++ b/vendor/gitlab.com/gitlab-org/api/client-go/.gitlab-ci.yml @@ -121,7 +121,7 @@ golangci-lint: needs: [] variables: REPORT_FILENAME: "gl-code-quality-report.json" - image: golangci/golangci-lint:v2.7.2 + image: golangci/golangci-lint:v2.8.0 script: - golangci-lint run artifacts: @@ -199,7 +199,7 @@ tests:integration: image: golang:1.25-bookworm timeout: 2 hours services: - - docker:29.1.3-dind + - docker:29.1.5-dind variables: # Docker-in-docker configuration DOCKER_HOST: tcp://docker:2376 diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/.golangci.yml b/vendor/gitlab.com/gitlab-org/api/client-go/.golangci.yml index 79d506c..c6d1a61 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/.golangci.yml +++ b/vendor/gitlab.com/gitlab-org/api/client-go/.golangci.yml @@ -33,6 +33,7 @@ linters: - testifylint - unconvert - usestdlibvars + - usetesting - whitespace - tparallel - paralleltest @@ -55,6 +56,7 @@ linters: - name: struct-tag - name: time-date - name: unused-parameter + - name: use-errors-new - name: var-naming staticcheck: checks: @@ -85,6 +87,10 @@ linters: http-method: false http-status-code: false time-date-month: true + usetesting: + context-background: true + context-todo: true + os-temp-dir: true # List of regexps of issue texts to exclude. exclusions: diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/.tool-versions b/vendor/gitlab.com/gitlab-org/api/client-go/.tool-versions index 1704438..d209d61 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/.tool-versions +++ b/vendor/gitlab.com/gitlab-org/api/client-go/.tool-versions @@ -1,5 +1,5 @@ golang 1.24 -golangci-lint 2.6.1 +golangci-lint 2.8.0 gofumpt 0.8.0 buf 1.55.1 -node 24.8.0 \ No newline at end of file +node 24.8.0 diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/AGENTS.md b/vendor/gitlab.com/gitlab-org/api/client-go/AGENTS.md index 234019d..26c8909 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/AGENTS.md +++ b/vendor/gitlab.com/gitlab-org/api/client-go/AGENTS.md @@ -37,14 +37,31 @@ mise exec -- make reviewable ### Test Patterns -- All tests use the `testing` package with `testify/assert` - Tests are parallelized using `t.Parallel()` - Mock HTTP handlers are used for API testing - Test data is stored in `testdata/` directory - Each service method should have corresponding test coverage - **CRITICAL** - When fixing bugs or creating new features, ensure new test scenarios are added to cover the new logic. - When writing a test, write Gherkin comments in-line with the test to make the tests easier to read. This means adding GIVEN/WHEN/THEN comments in tests. +- All tests use the `testing` package with `testify/assert` + +Do not use `reflect.DeepEqual` in tests, use testify instead. +```go +// This is an example of the incorrect test setup +want := &MyStruct{ + MyField: "Meow Kitty" +} +if !reflect.DeepEqual(want, otherStruct) { + t.Errorf("MyStruct returned %+v, want %+v", otherStruct, want) +} + +// Instead, use this +want := &MyStruct{ + MyField: "Meow Kitty" +} +assert.Equal(t, want, otherStruct) +``` ### Test Structure Example diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/CHANGELOG.md b/vendor/gitlab.com/gitlab-org/api/client-go/CHANGELOG.md index 65d0139..a91e62b 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/CHANGELOG.md +++ b/vendor/gitlab.com/gitlab-org/api/client-go/CHANGELOG.md @@ -1,3 +1,200 @@ +## 1.19.0 + +### 🚀 Features + +- feat(integrations): Add Chat & Notify integrations ([!2691](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2691)) by [Hamza Hassanain](https://gitlab.com/HamzaHassanain) + +### 🔄 Other Changes + +- refactor: use do function for requests ([!2674](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2674)) by [Timo Furrer](https://gitlab.com/timofurrer) +- chore(docs): Update adding API support guide for new coding patterns ([!2688](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2688)) by [Heidi Berry](https://gitlab.com/heidi.berry) + + + +# [1.19.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.18.0...v1.19.0) (2026-01-26) + + +### Features + +* **integrations:** Add Chat & Notify integrations ([cc692ed](https://gitlab.com/gitlab-org/api/client-go/commit/cc692edd6d8dfed55fd411559af7e53b55d4e2dd)) +* **mocks:** add streaming methods for various services ([889b407](https://gitlab.com/gitlab-org/api/client-go/commit/889b407e48432b32b4c1589102ceed6fadb857db)) + +## 1.18.0 + +### 🚀 Features + +- feat(settings): Added support for inactive_resource_access_tokens_delete_after_days to the... ([!2686](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2686)) by [Preethi Atchudan](https://gitlab.com/preethiatchudan) + +### 🔄 Other Changes + +- Add missing tests for refactored functions ([!2676](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2676)) by [Patrick Rice](https://gitlab.com/PatrickRice) + + + +# [1.18.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.17.0...v1.18.0) (2026-01-25) + + +### Features + +* **settings:** Added support for inactive_resource_access_tokens_delete_after_days to the... ([52b60c3](https://gitlab.com/gitlab-org/api/client-go/commit/52b60c3345ef56cc18ae7e8e1e2dd7c9f7f71344)) + +## 1.17.0 + +### 🚀 Features + +- Add support for Group Mattermost integrations ([!2675](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2675)) by [Hamza Hassanain](https://gitlab.com/HamzaHassanain) + + + +# [1.17.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.16.0...v1.17.0) (2026-01-23) + +## 1.16.0 + +### 🚀 Features + +- Add environment, deployed_after, and deployed_before params to merge requests options struct ([!2672](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2672)) by [Filip Aleksic](https://gitlab.com/faleksic) + +### 🔄 Other Changes + +- chore(deps): update module golang.org/x/oauth2 to v0.34.0 ([!2640](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2640)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) + + + +# [1.16.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.15.0...v1.16.0) (2026-01-20) + +## 1.15.0 + +### 🚀 Features + +- Add ExpiresAt field to ProjectSharedWithGroup struct ([!2671](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2671)) by [cindy](https://gitlab.com/wscix) + +### 🔄 Other Changes + +- feat: convert examples to testable examples for pkg.go.dev ([!2655](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2655)) by [Amer Khaled](https://gitlab.com/amrkhald777) +- refactor(no-release): enable usetesting linter ([!2664](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2664)) by [Oleksandr Redko](https://gitlab.com/alexandear) +- chore(deps): update docker docker tag to v29.1.5 ([!2665](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2665)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) +- Draft: Users: Fix GetUsersOptions naming inconsistency ([!2667](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2667)) by [Seif Hatem](https://gitlab.com/seif-hatem) + + + +# [1.15.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.14.0...v1.15.0) (2026-01-20) + + +### Bug Fixes + +* Deprecate incorrect fields returned in response for Emails on Push integration ([71d747d](https://gitlab.com/gitlab-org/api/client-go/commit/71d747da9a297451911b0c4eb4850632a588e3e8)) + + +### Features + +* convert examples to testable examples for pkg.go.dev ([fee39f1](https://gitlab.com/gitlab-org/api/client-go/commit/fee39f1f21b264765bbbed80ba23265bd3f633a9)) +* **issue_links:** Add ID field to IssueLink struct ([8f813a8](https://gitlab.com/gitlab-org/api/client-go/commit/8f813a8a2e73c41bc81403aceb82d7d94e9ff684)) + +## 1.14.0 + +### 🚀 Features + +- feat(hooks): Add project hook support for vulnerability events and branch filter strategy ([!2658](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2658)) by [Heidi Berry](https://gitlab.com/heidi.berry) +- Add max_artifacts_size parameter to groups and projects ([!2652](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2652)) by [Betty Godier](https://gitlab.com/betty-godier) + + + +# [1.14.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.13.0...v1.14.0) (2026-01-13) + + +### Features + +* **hooks:** Add project hook support for vulnerability events and branch filter strategy ([4f6d252](https://gitlab.com/gitlab-org/api/client-go/commit/4f6d252a47411602ac6757400e6b5479d807cdb8)) + +## 1.13.0 + +### 🚀 Features + +- feat(groups): add Active parameter to ListGroupProjects ([!2657](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2657)) by [Kai Armstrong](https://gitlab.com/phikai) + +### 🔄 Other Changes + +- chore(deps): update docker docker tag to v29.1.4 ([!2651](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2651)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) + + + +# [1.13.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.12.0...v1.13.0) (2026-01-12) + + +### Features + +* **groups:** add Active parameter to ListGroupProjects ([dec511a](https://gitlab.com/gitlab-org/api/client-go/commit/dec511a199b0adb7ba87f5a02a50651049b68b71)) + +## 1.12.0 + +### 🚀 Features + +- feat: add EmojiEvents field support to Project Webhooks ([!2653](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2653)) by [Yugan](https://gitlab.com/yugannkt) + +### 🔄 Other Changes + +- chore(deps): update dependency golangci-lint to v2.8.0 ([!2650](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2650)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) +- refactor(no-release): use errors.New instead of fmt.Errorf ([!2644](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2644)) by [Oleksandr Redko](https://gitlab.com/alexandear) + + + +# [1.12.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.11.0...v1.12.0) (2026-01-11) + + +### Features + +* add EmojiEvents field support to Project Webhooks ([2bcfa1f](https://gitlab.com/gitlab-org/api/client-go/commit/2bcfa1fd77756a3ccdb2bcf685736ee839b745be)) + +## 1.11.0 + +### 🚀 Features + +- feat(groups): add support for merge related settings ([!2625](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2625)) by [Zubeen](https://gitlab.com/syedzubeen) + +### 🐛 Bug Fixes + +- fix(api): typo in ms teams slug ([!2643](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2643)) by [aishahsofea](https://gitlab.com/aishahsofea) + +### 🔄 Other Changes + +- chore(deps): update module golang.org/x/text to v0.32.0 ([!2642](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2642)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) +- chore(deps): update module golang.org/x/sys to v0.39.0 ([!2641](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2641)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) +- chore(deps): update module github.com/godbus/dbus/v5 to v5.2.2 ([!2637](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2637)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) +- chore(deps): update module github.com/google/go-querystring to v1.2.0 ([!2638](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2638)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) + + + +# [1.11.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.10.0...v1.11.0) (2026-01-05) + + +### Bug Fixes + +* **api:** typo in ms teams slug ([1ed6c95](https://gitlab.com/gitlab-org/api/client-go/commit/1ed6c9509b23db53c3988a2dde2f11d22c8be5f9)) + + +### Features + +* **groups:** add support for merge related settings ([cb8412f](https://gitlab.com/gitlab-org/api/client-go/commit/cb8412fc495d19ee6e44819a2f69fd213d19a199)) + +## 1.10.0 + +### 🚀 Features + +- feat: implement Runner Controller API ([!2634](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2634)) by [Duo Developer](https://gitlab.com/duo-developer) + +### 🔄 Other Changes + +- chore(deps): update module github.com/godbus/dbus/v5 to v5.2.1 ([!2635](https://gitlab.com/gitlab-org/api/client-go/-/merge_requests/2635)) by [GitLab Dependency Bot](https://gitlab.com/gitlab-dependency-update-bot) + + + +# [1.10.0](https://gitlab.com/gitlab-org/api/client-go/compare/v1.9.1...v1.10.0) (2025-12-19) + + +### Features + +* implement Runner Controller API ([66f19f4](https://gitlab.com/gitlab-org/api/client-go/commit/66f19f4073ce87566c7751e0987f857eeb008849)) + ## 1.9.1 ### 🐛 Bug Fixes diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/Makefile b/vendor/gitlab.com/gitlab-org/api/client-go/Makefile index 4c6a189..9568285 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/Makefile +++ b/vendor/gitlab.com/gitlab-org/api/client-go/Makefile @@ -10,7 +10,7 @@ reviewable: setup generate fmt lint test ## Run before committing. fmt: ## Format code @buf format -w - @gofumpt -l -w *.go testing/*.go examples/*.go + @gofumpt -l -w *.go testing/*.go lint: ## Run linter @golangci-lint run diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/client_options.go b/vendor/gitlab.com/gitlab-org/api/client-go/client_options.go index 57a7f20..501d702 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/client_options.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/client_options.go @@ -17,7 +17,7 @@ package gitlab import ( - "fmt" + "errors" "net/http" "time" @@ -163,7 +163,7 @@ func WithCookieJar(jar http.CookieJar) ClientOptionFunc { func WithInterceptor(i Interceptor) ClientOptionFunc { return func(c *Client) error { if i == nil { - return fmt.Errorf("interceptor cannot be nil") + return errors.New("interceptor cannot be nil") } c.interceptors = append(c.interceptors, i) return nil diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/commits.go b/vendor/gitlab.com/gitlab-org/api/client-go/commits.go index 5a53fd9..36e6784 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/commits.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/commits.go @@ -17,7 +17,7 @@ package gitlab import ( - "fmt" + "errors" "net/http" "time" ) @@ -221,7 +221,7 @@ type GetCommitOptions struct { func (s *CommitsService) GetCommit(pid any, sha string, opt *GetCommitOptions, options ...RequestOptionFunc) (*Commit, *Response, error) { if sha == "" { - return nil, nil, fmt.Errorf("SHA must be a non-empty string") + return nil, nil, errors.New("SHA must be a non-empty string") } return do[*Commit](s.client, diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/dependency_list_export.go b/vendor/gitlab.com/gitlab-org/api/client-go/dependency_list_export.go index e6c21d9..248b2f2 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/dependency_list_export.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/dependency_list_export.go @@ -1,7 +1,6 @@ package gitlab import ( - "bytes" "fmt" "io" "net/http" @@ -128,11 +127,11 @@ func (s *DependencyListExportService) DownloadDependencyListExport(id int64, opt return nil, nil, err } - var sbomBuffer bytes.Buffer - resp, err := s.client.Do(req, &sbomBuffer) + preserver := &bodyPreserver{} + resp, err := s.client.Do(req, preserver) if err != nil { return nil, resp, err } - return &sbomBuffer, resp, nil + return preserver.body, resp, nil } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/dependency_proxy.go b/vendor/gitlab.com/gitlab-org/api/client-go/dependency_proxy.go index c210e8e..a9516e6 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/dependency_proxy.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/dependency_proxy.go @@ -14,10 +14,7 @@ package gitlab -import ( - "fmt" - "net/http" -) +import "net/http" type ( DependencyProxyServiceInterface interface { @@ -41,16 +38,10 @@ type ( var _ DependencyProxyServiceInterface = (*DependencyProxyService)(nil) func (s *DependencyProxyService) PurgeGroupDependencyProxy(gid any, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/dependency_proxy/cache", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/dependency_proxy/cache", GroupID{gid}), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/deploy_tokens.go b/vendor/gitlab.com/gitlab-org/api/client-go/deploy_tokens.go index c43394b..8083c84 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/deploy_tokens.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/deploy_tokens.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -114,18 +113,10 @@ func (k DeployToken) String() string { } func (s *DeployTokensService) ListAllDeployTokens(options ...RequestOptionFunc) ([]*DeployToken, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "deploy_tokens", nil, options) - if err != nil { - return nil, nil, err - } - - var ts []*DeployToken - resp, err := s.client.Do(req, &ts) - if err != nil { - return nil, resp, err - } - - return ts, resp, nil + return do[[]*DeployToken](s.client, + withPath("deploy_tokens"), + withRequestOpts(options...), + ) } // ListProjectDeployTokensOptions represents the available ListProjectDeployTokens() @@ -138,45 +129,18 @@ type ListProjectDeployTokensOptions struct { } func (s *DeployTokensService) ListProjectDeployTokens(pid any, opt *ListProjectDeployTokensOptions, options ...RequestOptionFunc) ([]*DeployToken, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/deploy_tokens", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var ts []*DeployToken - resp, err := s.client.Do(req, &ts) - if err != nil { - return nil, resp, err - } - - return ts, resp, nil + return do[[]*DeployToken](s.client, + withPath("projects/%s/deploy_tokens", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *DeployTokensService) GetProjectDeployToken(pid any, deployToken int64, options ...RequestOptionFunc) (*DeployToken, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/deploy_tokens/%d", PathEscape(project), deployToken) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - t := new(DeployToken) - resp, err := s.client.Do(req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[*DeployToken](s.client, + withPath("projects/%s/deploy_tokens/%d", ProjectID{pid}, deployToken), + withRequestOpts(options...), + ) } // CreateProjectDeployTokenOptions represents the available CreateProjectDeployToken() options. @@ -191,39 +155,21 @@ type CreateProjectDeployTokenOptions struct { } func (s *DeployTokensService) CreateProjectDeployToken(pid any, opt *CreateProjectDeployTokenOptions, options ...RequestOptionFunc) (*DeployToken, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/deploy_tokens", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - t := new(DeployToken) - resp, err := s.client.Do(req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[*DeployToken](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/deploy_tokens", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *DeployTokensService) DeleteProjectDeployToken(pid any, deployToken int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/deploy_tokens/%d", PathEscape(project), deployToken) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/deploy_tokens/%d", ProjectID{pid}, deployToken), + withRequestOpts(options...), + ) + return resp, err } // ListGroupDeployTokensOptions represents the available ListGroupDeployTokens() @@ -236,45 +182,18 @@ type ListGroupDeployTokensOptions struct { } func (s *DeployTokensService) ListGroupDeployTokens(gid any, opt *ListGroupDeployTokensOptions, options ...RequestOptionFunc) ([]*DeployToken, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/deploy_tokens", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var ts []*DeployToken - resp, err := s.client.Do(req, &ts) - if err != nil { - return nil, resp, err - } - - return ts, resp, nil + return do[[]*DeployToken](s.client, + withPath("groups/%s/deploy_tokens", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *DeployTokensService) GetGroupDeployToken(gid any, deployToken int64, options ...RequestOptionFunc) (*DeployToken, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/deploy_tokens/%d", PathEscape(group), deployToken) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - t := new(DeployToken) - resp, err := s.client.Do(req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[*DeployToken](s.client, + withPath("groups/%s/deploy_tokens/%d", GroupID{gid}, deployToken), + withRequestOpts(options...), + ) } // CreateGroupDeployTokenOptions represents the available CreateGroupDeployToken() options. @@ -289,37 +208,19 @@ type CreateGroupDeployTokenOptions struct { } func (s *DeployTokensService) CreateGroupDeployToken(gid any, opt *CreateGroupDeployTokenOptions, options ...RequestOptionFunc) (*DeployToken, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/deploy_tokens", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - t := new(DeployToken) - resp, err := s.client.Do(req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[*DeployToken](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/deploy_tokens", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *DeployTokensService) DeleteGroupDeployToken(gid any, deployToken int64, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/deploy_tokens/%d", PathEscape(group), deployToken) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/deploy_tokens/%d", GroupID{gid}, deployToken), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/discussions.go b/vendor/gitlab.com/gitlab-org/api/client-go/discussions.go index 72d8ddf..e305dca 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/discussions.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/discussions.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -260,49 +259,18 @@ type ListIssueDiscussionsOptions struct { } func (s *DiscussionsService) ListIssueDiscussions(pid any, issue int64, opt *ListIssueDiscussionsOptions, options ...RequestOptionFunc) ([]*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/discussions", PathEscape(project), issue) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var ds []*Discussion - resp, err := s.client.Do(req, &ds) - if err != nil { - return nil, resp, err - } - - return ds, resp, nil + return do[[]*Discussion](s.client, + withPath("projects/%s/issues/%d/discussions", ProjectID{pid}, issue), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *DiscussionsService) GetIssueDiscussion(pid any, issue int64, discussion string, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/discussions/%s", - PathEscape(project), - issue, - discussion, + return do[*Discussion](s.client, + withPath("projects/%s/issues/%d/discussions/%s", ProjectID{pid}, issue, discussion), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // CreateIssueDiscussionOptions represents the available CreateIssueDiscussion() @@ -316,24 +284,12 @@ type CreateIssueDiscussionOptions struct { } func (s *DiscussionsService) CreateIssueDiscussion(pid any, issue int64, opt *CreateIssueDiscussionOptions, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/discussions", PathEscape(project), issue) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil + return do[*Discussion](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/issues/%d/discussions", ProjectID{pid}, issue), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // AddIssueDiscussionNoteOptions represents the available AddIssueDiscussionNote() @@ -347,28 +303,12 @@ type AddIssueDiscussionNoteOptions struct { } func (s *DiscussionsService) AddIssueDiscussionNote(pid any, issue int64, discussion string, opt *AddIssueDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/discussions/%s/notes", - PathEscape(project), - issue, - discussion, + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/issues/%d/discussions/%s/notes", ProjectID{pid}, issue, discussion), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } // UpdateIssueDiscussionNoteOptions represents the available @@ -382,49 +322,21 @@ type UpdateIssueDiscussionNoteOptions struct { } func (s *DiscussionsService) UpdateIssueDiscussionNote(pid any, issue int64, discussion string, note int64, opt *UpdateIssueDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/discussions/%s/notes/%d", - PathEscape(project), - issue, - discussion, - note, + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/issues/%d/discussions/%s/notes/%d", ProjectID{pid}, issue, discussion, note), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } func (s *DiscussionsService) DeleteIssueDiscussionNote(pid any, issue int64, discussion string, note int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/discussions/%s/notes/%d", - PathEscape(project), - issue, - discussion, - note, + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/issues/%d/discussions/%s/notes/%d", ProjectID{pid}, issue, discussion, note), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + return resp, err } // ListSnippetDiscussionsOptions represents the available ListSnippetDiscussions() @@ -437,49 +349,18 @@ type ListSnippetDiscussionsOptions struct { } func (s *DiscussionsService) ListSnippetDiscussions(pid any, snippet int64, opt *ListSnippetDiscussionsOptions, options ...RequestOptionFunc) ([]*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/discussions", PathEscape(project), snippet) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var ds []*Discussion - resp, err := s.client.Do(req, &ds) - if err != nil { - return nil, resp, err - } - - return ds, resp, nil + return do[[]*Discussion](s.client, + withPath("projects/%s/snippets/%d/discussions", ProjectID{pid}, snippet), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *DiscussionsService) GetSnippetDiscussion(pid any, snippet int64, discussion string, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/discussions/%s", - PathEscape(project), - snippet, - discussion, + return do[*Discussion](s.client, + withPath("projects/%s/snippets/%d/discussions/%s", ProjectID{pid}, snippet, discussion), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // CreateSnippetDiscussionOptions represents the available @@ -493,24 +374,12 @@ type CreateSnippetDiscussionOptions struct { } func (s *DiscussionsService) CreateSnippetDiscussion(pid any, snippet int64, opt *CreateSnippetDiscussionOptions, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/discussions", PathEscape(project), snippet) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil + return do[*Discussion](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/snippets/%d/discussions", ProjectID{pid}, snippet), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // AddSnippetDiscussionNoteOptions represents the available @@ -524,28 +393,12 @@ type AddSnippetDiscussionNoteOptions struct { } func (s *DiscussionsService) AddSnippetDiscussionNote(pid any, snippet int64, discussion string, opt *AddSnippetDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/discussions/%s/notes", - PathEscape(project), - snippet, - discussion, + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/snippets/%d/discussions/%s/notes", ProjectID{pid}, snippet, discussion), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } // UpdateSnippetDiscussionNoteOptions represents the available @@ -559,49 +412,21 @@ type UpdateSnippetDiscussionNoteOptions struct { } func (s *DiscussionsService) UpdateSnippetDiscussionNote(pid any, snippet int64, discussion string, note int64, opt *UpdateSnippetDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/discussions/%s/notes/%d", - PathEscape(project), - snippet, - discussion, - note, + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/snippets/%d/discussions/%s/notes/%d", ProjectID{pid}, snippet, discussion, note), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } func (s *DiscussionsService) DeleteSnippetDiscussionNote(pid any, snippet int64, discussion string, note int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/discussions/%s/notes/%d", - PathEscape(project), - snippet, - discussion, - note, + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/snippets/%d/discussions/%s/notes/%d", ProjectID{pid}, snippet, discussion, note), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + return resp, err } // ListGroupEpicDiscussionsOptions represents the available @@ -614,52 +439,18 @@ type ListGroupEpicDiscussionsOptions struct { } func (s *DiscussionsService) ListGroupEpicDiscussions(gid any, epic int64, opt *ListGroupEpicDiscussionsOptions, options ...RequestOptionFunc) ([]*Discussion, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/discussions", - PathEscape(group), - epic, + return do[[]*Discussion](s.client, + withPath("groups/%s/epics/%d/discussions", GroupID{gid}, epic), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var ds []*Discussion - resp, err := s.client.Do(req, &ds) - if err != nil { - return nil, resp, err - } - - return ds, resp, nil } func (s *DiscussionsService) GetEpicDiscussion(gid any, epic int64, discussion string, options ...RequestOptionFunc) (*Discussion, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/discussions/%s", - PathEscape(group), - epic, - discussion, + return do[*Discussion](s.client, + withPath("groups/%s/epics/%d/discussions/%s", GroupID{gid}, epic, discussion), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // CreateEpicDiscussionOptions represents the available CreateEpicDiscussion() @@ -673,27 +464,12 @@ type CreateEpicDiscussionOptions struct { } func (s *DiscussionsService) CreateEpicDiscussion(gid any, epic int64, opt *CreateEpicDiscussionOptions, options ...RequestOptionFunc) (*Discussion, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/discussions", - PathEscape(group), - epic, + return do[*Discussion](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/epics/%d/discussions", GroupID{gid}, epic), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // AddEpicDiscussionNoteOptions represents the available @@ -707,28 +483,12 @@ type AddEpicDiscussionNoteOptions struct { } func (s *DiscussionsService) AddEpicDiscussionNote(gid any, epic int64, discussion string, opt *AddEpicDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/discussions/%s/notes", - PathEscape(group), - epic, - discussion, + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/epics/%d/discussions/%s/notes", GroupID{gid}, epic, discussion), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } // UpdateEpicDiscussionNoteOptions represents the available UpdateEpicDiscussion() @@ -742,49 +502,21 @@ type UpdateEpicDiscussionNoteOptions struct { } func (s *DiscussionsService) UpdateEpicDiscussionNote(gid any, epic int64, discussion string, note int64, opt *UpdateEpicDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/discussions/%s/notes/%d", - PathEscape(group), - epic, - discussion, - note, + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("groups/%s/epics/%d/discussions/%s/notes/%d", GroupID{gid}, epic, discussion, note), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } func (s *DiscussionsService) DeleteEpicDiscussionNote(gid any, epic int64, discussion string, note int64, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/discussions/%s/notes/%d", - PathEscape(group), - epic, - discussion, - note, + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/epics/%d/discussions/%s/notes/%d", GroupID{gid}, epic, discussion, note), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + return resp, err } // ListMergeRequestDiscussionsOptions represents the available @@ -797,52 +529,18 @@ type ListMergeRequestDiscussionsOptions struct { } func (s *DiscussionsService) ListMergeRequestDiscussions(pid any, mergeRequest int64, opt *ListMergeRequestDiscussionsOptions, options ...RequestOptionFunc) ([]*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/discussions", - PathEscape(project), - mergeRequest, + return do[[]*Discussion](s.client, + withPath("projects/%s/merge_requests/%d/discussions", ProjectID{pid}, mergeRequest), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var ds []*Discussion - resp, err := s.client.Do(req, &ds) - if err != nil { - return nil, resp, err - } - - return ds, resp, nil } func (s *DiscussionsService) GetMergeRequestDiscussion(pid any, mergeRequest int64, discussion string, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/discussions/%s", - PathEscape(project), - mergeRequest, - discussion, + return do[*Discussion](s.client, + withPath("projects/%s/merge_requests/%d/discussions/%s", ProjectID{pid}, mergeRequest, discussion), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // CreateMergeRequestDiscussionOptions represents the available @@ -889,27 +587,12 @@ type LinePositionOptions struct { } func (s *DiscussionsService) CreateMergeRequestDiscussion(pid any, mergeRequest int64, opt *CreateMergeRequestDiscussionOptions, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/discussions", - PathEscape(project), - mergeRequest, + return do[*Discussion](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/discussions", ProjectID{pid}, mergeRequest), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // ResolveMergeRequestDiscussionOptions represents the available @@ -922,28 +605,12 @@ type ResolveMergeRequestDiscussionOptions struct { } func (s *DiscussionsService) ResolveMergeRequestDiscussion(pid any, mergeRequest int64, discussion string, opt *ResolveMergeRequestDiscussionOptions, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/discussions/%s", - PathEscape(project), - mergeRequest, - discussion, + return do[*Discussion](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/merge_requests/%d/discussions/%s", ProjectID{pid}, mergeRequest, discussion), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // AddMergeRequestDiscussionNoteOptions represents the available @@ -957,28 +624,12 @@ type AddMergeRequestDiscussionNoteOptions struct { } func (s *DiscussionsService) AddMergeRequestDiscussionNote(pid any, mergeRequest int64, discussion string, opt *AddMergeRequestDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/discussions/%s/notes", - PathEscape(project), - mergeRequest, - discussion, + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/discussions/%s/notes", ProjectID{pid}, mergeRequest, discussion), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } // UpdateMergeRequestDiscussionNoteOptions represents the available @@ -993,49 +644,21 @@ type UpdateMergeRequestDiscussionNoteOptions struct { } func (s *DiscussionsService) UpdateMergeRequestDiscussionNote(pid any, mergeRequest int64, discussion string, note int64, opt *UpdateMergeRequestDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/discussions/%s/notes/%d", - PathEscape(project), - mergeRequest, - discussion, - note, + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/merge_requests/%d/discussions/%s/notes/%d", ProjectID{pid}, mergeRequest, discussion, note), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } func (s *DiscussionsService) DeleteMergeRequestDiscussionNote(pid any, mergeRequest int64, discussion string, note int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/discussions/%s/notes/%d", - PathEscape(project), - mergeRequest, - discussion, - note, + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/merge_requests/%d/discussions/%s/notes/%d", ProjectID{pid}, mergeRequest, discussion, note), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + return resp, err } // ListCommitDiscussionsOptions represents the available @@ -1048,52 +671,18 @@ type ListCommitDiscussionsOptions struct { } func (s *DiscussionsService) ListCommitDiscussions(pid any, commit string, opt *ListCommitDiscussionsOptions, options ...RequestOptionFunc) ([]*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/commits/%s/discussions", - PathEscape(project), - commit, + return do[[]*Discussion](s.client, + withPath("projects/%s/repository/commits/%s/discussions", ProjectID{pid}, commit), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var ds []*Discussion - resp, err := s.client.Do(req, &ds) - if err != nil { - return nil, resp, err - } - - return ds, resp, nil } func (s *DiscussionsService) GetCommitDiscussion(pid any, commit string, discussion string, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/commits/%s/discussions/%s", - PathEscape(project), - commit, - discussion, + return do[*Discussion](s.client, + withPath("projects/%s/repository/commits/%s/discussions/%s", ProjectID{pid}, commit, discussion), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // CreateCommitDiscussionOptions represents the available @@ -1108,27 +697,12 @@ type CreateCommitDiscussionOptions struct { } func (s *DiscussionsService) CreateCommitDiscussion(pid any, commit string, opt *CreateCommitDiscussionOptions, options ...RequestOptionFunc) (*Discussion, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/commits/%s/discussions", - PathEscape(project), - commit, + return do[*Discussion](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/repository/commits/%s/discussions", ProjectID{pid}, commit), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - d := new(Discussion) - resp, err := s.client.Do(req, d) - if err != nil { - return nil, resp, err - } - - return d, resp, nil } // AddCommitDiscussionNoteOptions represents the available @@ -1142,28 +716,12 @@ type AddCommitDiscussionNoteOptions struct { } func (s *DiscussionsService) AddCommitDiscussionNote(pid any, commit string, discussion string, opt *AddCommitDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/commits/%s/discussions/%s/notes", - PathEscape(project), - commit, - discussion, + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/repository/commits/%s/discussions/%s/notes", ProjectID{pid}, commit, discussion), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } // UpdateCommitDiscussionNoteOptions represents the available @@ -1177,47 +735,19 @@ type UpdateCommitDiscussionNoteOptions struct { } func (s *DiscussionsService) UpdateCommitDiscussionNote(pid any, commit string, discussion string, note int64, opt *UpdateCommitDiscussionNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/commits/%s/discussions/%s/notes/%d", - PathEscape(project), - commit, - discussion, - note, + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/repository/commits/%s/discussions/%s/notes/%d", ProjectID{pid}, commit, discussion, note), + withAPIOpts(opt), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil } func (s *DiscussionsService) DeleteCommitDiscussionNote(pid any, commit string, discussion string, note int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/repository/commits/%s/discussions/%s/notes/%d", - PathEscape(project), - commit, - discussion, - note, + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/repository/commits/%s/discussions/%s/notes/%d", ProjectID{pid}, commit, discussion, note), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/dockerfile_templates.go b/vendor/gitlab.com/gitlab-org/api/client-go/dockerfile_templates.go index ba71346..438cba9 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/dockerfile_templates.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/dockerfile_templates.go @@ -16,12 +16,6 @@ package gitlab -import ( - "fmt" - "net/http" - "net/url" -) - type ( // DockerfileTemplatesServiceInterface defines all the API methods for the DockerfileTemplatesService DockerfileTemplatesServiceInterface interface { @@ -74,33 +68,16 @@ type ListDockerfileTemplatesOptions struct { } func (s *DockerfileTemplatesService) ListTemplates(opt *ListDockerfileTemplatesOptions, options ...RequestOptionFunc) ([]*DockerfileTemplateListItem, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "templates/dockerfiles", opt, options) - if err != nil { - return nil, nil, err - } - - var gs []*DockerfileTemplateListItem - resp, err := s.client.Do(req, &gs) - if err != nil { - return nil, resp, err - } - - return gs, resp, nil + return do[[]*DockerfileTemplateListItem](s.client, + withPath("templates/dockerfiles"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *DockerfileTemplatesService) GetTemplate(key string, options ...RequestOptionFunc) (*DockerfileTemplate, *Response, error) { - u := fmt.Sprintf("templates/dockerfiles/%s", url.PathEscape(key)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - g := new(DockerfileTemplate) - resp, err := s.client.Do(req, g) - if err != nil { - return nil, resp, err - } - - return g, resp, nil + return do[*DockerfileTemplate](s.client, + withPath("templates/dockerfiles/%s", key), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/error_tracking.go b/vendor/gitlab.com/gitlab-org/api/client-go/error_tracking.go index 5512b2e..d39a106 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/error_tracking.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/error_tracking.go @@ -16,10 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" -) +import "net/http" type ( // ErrorTrackingServiceInterface defines all the API methods for the ErrorTrackingService @@ -98,24 +95,10 @@ func (p ErrorTrackingSettings) String() string { } func (s *ErrorTrackingService) GetErrorTrackingSettings(pid any, options ...RequestOptionFunc) (*ErrorTrackingSettings, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/error_tracking/settings", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - ets := new(ErrorTrackingSettings) - resp, err := s.client.Do(req, ets) - if err != nil { - return nil, resp, err - } - - return ets, resp, nil + return do[*ErrorTrackingSettings](s.client, + withPath("projects/%s/error_tracking/settings", ProjectID{pid}), + withRequestOpts(options...), + ) } // EnableDisableErrorTrackingOptions represents the available @@ -129,24 +112,12 @@ type EnableDisableErrorTrackingOptions struct { } func (s *ErrorTrackingService) EnableDisableErrorTracking(pid any, opt *EnableDisableErrorTrackingOptions, options ...RequestOptionFunc) (*ErrorTrackingSettings, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/error_tracking/settings", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPatch, u, opt, options) - if err != nil { - return nil, nil, err - } - - ets := new(ErrorTrackingSettings) - resp, err := s.client.Do(req, &ets) - if err != nil { - return nil, resp, err - } - - return ets, resp, nil + return do[*ErrorTrackingSettings](s.client, + withMethod(http.MethodPatch), + withPath("projects/%s/error_tracking/settings", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // ListClientKeysOptions represents the available ListClientKeys() options. @@ -158,45 +129,19 @@ type ListClientKeysOptions struct { } func (s *ErrorTrackingService) ListClientKeys(pid any, opt *ListClientKeysOptions, options ...RequestOptionFunc) ([]*ErrorTrackingClientKey, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/error_tracking/client_keys", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var cks []*ErrorTrackingClientKey - resp, err := s.client.Do(req, &cks) - if err != nil { - return nil, resp, err - } - - return cks, resp, nil + return do[[]*ErrorTrackingClientKey](s.client, + withPath("projects/%s/error_tracking/client_keys", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *ErrorTrackingService) CreateClientKey(pid any, options ...RequestOptionFunc) (*ErrorTrackingClientKey, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/error_tracking/client_keys", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, nil, err - } - - ck := new(ErrorTrackingClientKey) - resp, err := s.client.Do(req, ck) - if err != nil { - return nil, resp, err - } - - return ck, resp, nil + return do[*ErrorTrackingClientKey](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/error_tracking/client_keys", ProjectID{pid}), + withRequestOpts(options...), + ) } // DeleteClientKey removes a client key from the project. @@ -204,16 +149,10 @@ func (s *ErrorTrackingService) CreateClientKey(pid any, options ...RequestOption // GitLab API docs: // https://docs.gitlab.com/api/error_tracking/#delete-a-client-key func (s *ErrorTrackingService) DeleteClientKey(pid any, keyID int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/error_tracking/client_keys/%d", PathEscape(project), keyID) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/error_tracking/client_keys/%d", ProjectID{pid}, keyID), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/event_parsing.go b/vendor/gitlab.com/gitlab-org/api/client-go/event_parsing.go index 803608b..4c43334 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/event_parsing.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/event_parsing.go @@ -18,6 +18,7 @@ package gitlab import ( "encoding/json" + "errors" "fmt" "net/http" ) @@ -278,7 +279,7 @@ func ParseWebhook(eventType EventType, payload []byte) (event any, err error) { case projectEvent: event = &ProjectResourceAccessTokenEvent{} default: - return nil, fmt.Errorf("unexpected resource access token payload") + return nil, errors.New("unexpected resource access token payload") } case EventTypeServiceHook: service := &serviceEvent{} diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/external_status_checks.go b/vendor/gitlab.com/gitlab-org/api/client-go/external_status_checks.go index 7bfbcf0..227f17b 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/external_status_checks.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/external_status_checks.go @@ -1,7 +1,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -146,24 +145,11 @@ type StatusCheckProtectedBranch struct { // GitLab API docs: // https://docs.gitlab.com/api/status_checks/#list-status-checks-for-a-merge-request func (s *ExternalStatusChecksService) ListMergeStatusChecks(pid any, mr int64, opt *ListOptions, options ...RequestOptionFunc) ([]*MergeStatusCheck, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/status_checks", PathEscape(project), mr) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var mscs []*MergeStatusCheck - resp, err := s.client.Do(req, &mscs) - if err != nil { - return nil, resp, err - } - - return mscs, resp, nil + return do[[]*MergeStatusCheck](s.client, + withPath("projects/%s/merge_requests/%d/status_checks", ProjectID{pid}, mr), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // SetExternalStatusCheckStatusOptions represents the available @@ -184,39 +170,21 @@ type SetExternalStatusCheckStatusOptions struct { // Gitlab API docs: // https://docs.gitlab.com/api/status_checks/#set-status-of-an-external-status-check func (s *ExternalStatusChecksService) SetExternalStatusCheckStatus(pid any, mergeRequest int64, opt *SetExternalStatusCheckStatusOptions, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/status_check_responses", PathEscape(project), mergeRequest) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/status_check_responses", ProjectID{pid}, mergeRequest), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } func (s *ExternalStatusChecksService) ListProjectStatusChecks(pid any, opt *ListOptions, options ...RequestOptionFunc) ([]*ProjectStatusCheck, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/external_status_checks", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var pscs []*ProjectStatusCheck - resp, err := s.client.Do(req, &pscs) - if err != nil { - return nil, resp, err - } - - return pscs, resp, nil + return do[[]*ProjectStatusCheck](s.client, + withPath("projects/%s/external_status_checks", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // CreateExternalStatusCheckOptions represents the available @@ -232,18 +200,13 @@ type CreateExternalStatusCheckOptions struct { } func (s *ExternalStatusChecksService) CreateExternalStatusCheck(pid any, opt *CreateExternalStatusCheckOptions, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/external_status_checks", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/external_status_checks", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } // DeleteExternalStatusCheck deletes an external status check. @@ -252,18 +215,12 @@ func (s *ExternalStatusChecksService) CreateExternalStatusCheck(pid any, opt *Cr // Gitlab API docs: // https://docs.gitlab.com/api/status_checks/#delete-external-status-check-service func (s *ExternalStatusChecksService) DeleteExternalStatusCheck(pid any, check int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/external_status_checks/%d", PathEscape(project), check) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/external_status_checks/%d", ProjectID{pid}, check), + withRequestOpts(options...), + ) + return resp, err } // UpdateExternalStatusCheckOptions represents the available @@ -284,18 +241,13 @@ type UpdateExternalStatusCheckOptions struct { // Gitlab API docs: // https://docs.gitlab.com/api/status_checks/#update-external-status-check-service func (s *ExternalStatusChecksService) UpdateExternalStatusCheck(pid any, check int64, opt *UpdateExternalStatusCheckOptions, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/external_status_checks/%d", PathEscape(project), check) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/external_status_checks/%d", ProjectID{pid}, check), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } // RetryFailedStatusCheckForAMergeRequest retries the specified failed external status check. @@ -304,18 +256,12 @@ func (s *ExternalStatusChecksService) UpdateExternalStatusCheck(pid any, check i // Gitlab API docs: // https://docs.gitlab.com/api/status_checks/#retry-failed-status-check-for-a-merge-request func (s *ExternalStatusChecksService) RetryFailedStatusCheckForAMergeRequest(pid any, mergeRequest int64, externalStatusCheck int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/status_checks/%d/retry", PathEscape(project), mergeRequest, externalStatusCheck) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/status_checks/%d/retry", ProjectID{pid}, mergeRequest, externalStatusCheck), + withRequestOpts(options...), + ) + return resp, err } // ListProjectMergeRequestExternalStatusChecksOptions represents the available @@ -333,24 +279,11 @@ type ListProjectMergeRequestExternalStatusChecksOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/status_checks/#list-status-checks-for-a-merge-request func (s *ExternalStatusChecksService) ListProjectMergeRequestExternalStatusChecks(pid any, mr int64, opt *ListProjectMergeRequestExternalStatusChecksOptions, options ...RequestOptionFunc) ([]*MergeStatusCheck, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/status_checks", PathEscape(project), mr) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var mscs []*MergeStatusCheck - resp, err := s.client.Do(req, &mscs) - if err != nil { - return nil, resp, err - } - - return mscs, resp, nil + return do[[]*MergeStatusCheck](s.client, + withPath("projects/%s/merge_requests/%d/status_checks", ProjectID{pid}, mr), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // ListProjectExternalStatusChecksOptions represents the available @@ -363,24 +296,11 @@ type ListProjectExternalStatusChecksOptions struct { } func (s *ExternalStatusChecksService) ListProjectExternalStatusChecks(pid any, opt *ListProjectExternalStatusChecksOptions, options ...RequestOptionFunc) ([]*ProjectStatusCheck, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/external_status_checks", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var pscs []*ProjectStatusCheck - resp, err := s.client.Do(req, &pscs) - if err != nil { - return nil, resp, err - } - - return pscs, resp, nil + return do[[]*ProjectStatusCheck](s.client, + withPath("projects/%s/external_status_checks", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // CreateProjectExternalStatusCheckOptions represents the available @@ -396,24 +316,12 @@ type CreateProjectExternalStatusCheckOptions struct { } func (s *ExternalStatusChecksService) CreateProjectExternalStatusCheck(pid any, opt *CreateProjectExternalStatusCheckOptions, options ...RequestOptionFunc) (*ProjectStatusCheck, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/external_status_checks", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - statusCheck := new(ProjectStatusCheck) - resp, err := s.client.Do(req, statusCheck) - if err != nil { - return nil, resp, err - } - - return statusCheck, resp, nil + return do[*ProjectStatusCheck](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/external_status_checks", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteProjectExternalStatusCheckOptions represents the available @@ -428,18 +336,13 @@ type DeleteProjectExternalStatusCheckOptions struct{} // Gitlab API docs: // https://docs.gitlab.com/api/status_checks/#delete-external-status-check-service func (s *ExternalStatusChecksService) DeleteProjectExternalStatusCheck(pid any, check int64, opt *DeleteProjectExternalStatusCheckOptions, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/external_status_checks/%d", PathEscape(project), check) - - req, err := s.client.NewRequest(http.MethodDelete, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/external_status_checks/%d", ProjectID{pid}, check), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } // UpdateProjectExternalStatusCheckOptions represents the available @@ -459,24 +362,12 @@ type UpdateProjectExternalStatusCheckOptions struct { // Gitlab API docs: // https://docs.gitlab.com/api/status_checks/#update-external-status-check-service func (s *ExternalStatusChecksService) UpdateProjectExternalStatusCheck(pid any, check int64, opt *UpdateProjectExternalStatusCheckOptions, options ...RequestOptionFunc) (*ProjectStatusCheck, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/external_status_checks/%d", PathEscape(project), check) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - statusCheck := new(ProjectStatusCheck) - resp, err := s.client.Do(req, statusCheck) - if err != nil { - return nil, resp, err - } - - return statusCheck, resp, nil + return do[*ProjectStatusCheck](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/external_status_checks/%d", ProjectID{pid}, check), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // RetryFailedExternalStatusCheckForProjectMergeRequestOptions represents the available @@ -491,18 +382,13 @@ type RetryFailedExternalStatusCheckForProjectMergeRequestOptions struct{} // Gitlab API docs: // https://docs.gitlab.com/api/status_checks/#retry-failed-status-check-for-a-merge-request func (s *ExternalStatusChecksService) RetryFailedExternalStatusCheckForProjectMergeRequest(pid any, mergeRequest int64, externalStatusCheck int64, opt *RetryFailedExternalStatusCheckForProjectMergeRequestOptions, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/status_checks/%d/retry", PathEscape(project), mergeRequest, externalStatusCheck) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/status_checks/%d/retry", ProjectID{pid}, mergeRequest, externalStatusCheck), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } // SetProjectMergeRequestExternalStatusCheckStatusOptions represents the available @@ -521,16 +407,11 @@ type SetProjectMergeRequestExternalStatusCheckStatusOptions struct { // Gitlab API docs: // https://docs.gitlab.com/api/status_checks/#set-status-of-an-external-status-check func (s *ExternalStatusChecksService) SetProjectMergeRequestExternalStatusCheckStatus(pid any, mergeRequest int64, opt *SetProjectMergeRequestExternalStatusCheckStatusOptions, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/status_check_responses", PathEscape(project), mergeRequest) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/status_check_responses", ProjectID{pid}, mergeRequest), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/feature_flags.go b/vendor/gitlab.com/gitlab-org/api/client-go/feature_flags.go index d0a5d84..9fa0d30 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/feature_flags.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/feature_flags.go @@ -16,11 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" - "net/url" -) +import "net/http" type ( // FeaturesServiceInterface defines all the API methods for the FeaturesService @@ -69,17 +65,10 @@ func (f Feature) String() string { // GitLab API docs: // https://docs.gitlab.com/api/features/#list-all-features func (s *FeaturesService) ListFeatures(options ...RequestOptionFunc) ([]*Feature, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "features", nil, options) - if err != nil { - return nil, nil, err - } - - var f []*Feature - resp, err := s.client.Do(req, &f) - if err != nil { - return nil, resp, err - } - return f, resp, nil + return do[[]*Feature](s.client, + withPath("features"), + withRequestOpts(options...), + ) } // FeatureDefinition represents a Feature Definition. @@ -106,17 +95,10 @@ func (fd FeatureDefinition) String() string { // GitLab API docs: // https://docs.gitlab.com/api/features/#list-all-feature-definitions func (s *FeaturesService) ListFeatureDefinitions(options ...RequestOptionFunc) ([]*FeatureDefinition, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "features/definitions", nil, options) - if err != nil { - return nil, nil, err - } - - var fd []*FeatureDefinition - resp, err := s.client.Do(req, &fd) - if err != nil { - return nil, resp, err - } - return fd, resp, nil + return do[[]*FeatureDefinition](s.client, + withPath("features/definitions"), + withRequestOpts(options...), + ) } // SetFeatureFlagOptions represents the available options for @@ -141,19 +123,12 @@ type SetFeatureFlagOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/features/#set-or-create-a-feature func (s *FeaturesService) SetFeatureFlag(name string, opt *SetFeatureFlagOptions, options ...RequestOptionFunc) (*Feature, *Response, error) { - u := fmt.Sprintf("features/%s", url.PathEscape(name)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - f := &Feature{} - resp, err := s.client.Do(req, f) - if err != nil { - return nil, resp, err - } - return f, resp, nil + return do[*Feature](s.client, + withMethod(http.MethodPost), + withPath("features/%s", name), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteFeatureFlag deletes a feature flag. @@ -161,12 +136,10 @@ func (s *FeaturesService) SetFeatureFlag(name string, opt *SetFeatureFlagOptions // GitLab API docs: // https://docs.gitlab.com/api/features/#delete-a-feature func (s *FeaturesService) DeleteFeatureFlag(name string, options ...RequestOptionFunc) (*Response, error) { - u := fmt.Sprintf("features/%s", url.PathEscape(name)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("features/%s", name), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/freeze_periods.go b/vendor/gitlab.com/gitlab-org/api/client-go/freeze_periods.go index ef12aca..bb41500 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/freeze_periods.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/freeze_periods.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -74,24 +73,11 @@ type ListFreezePeriodsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/freeze_periods/#list-freeze-periods func (s *FreezePeriodsService) ListFreezePeriods(pid any, opt *ListFreezePeriodsOptions, options ...RequestOptionFunc) ([]*FreezePeriod, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/freeze_periods", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var fp []*FreezePeriod - resp, err := s.client.Do(req, &fp) - if err != nil { - return nil, resp, err - } - - return fp, resp, nil + return do[[]*FreezePeriod](s.client, + withPath("projects/%s/freeze_periods", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetFreezePeriod gets a specific freeze period for a project. @@ -99,24 +85,10 @@ func (s *FreezePeriodsService) ListFreezePeriods(pid any, opt *ListFreezePeriods // GitLab API docs: // https://docs.gitlab.com/api/freeze_periods/#get-a-freeze-period-by-a-freeze_period_id func (s *FreezePeriodsService) GetFreezePeriod(pid any, freezePeriod int64, options ...RequestOptionFunc) (*FreezePeriod, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/freeze_periods/%d", PathEscape(project), freezePeriod) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - fp := new(FreezePeriod) - resp, err := s.client.Do(req, fp) - if err != nil { - return nil, resp, err - } - - return fp, resp, nil + return do[*FreezePeriod](s.client, + withPath("projects/%s/freeze_periods/%d", ProjectID{pid}, freezePeriod), + withRequestOpts(options...), + ) } // CreateFreezePeriodOptions represents the available CreateFreezePeriodOptions() @@ -135,24 +107,12 @@ type CreateFreezePeriodOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/freeze_periods/#create-a-freeze-period func (s *FreezePeriodsService) CreateFreezePeriodOptions(pid any, opt *CreateFreezePeriodOptions, options ...RequestOptionFunc) (*FreezePeriod, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/freeze_periods", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - fp := new(FreezePeriod) - resp, err := s.client.Do(req, fp) - if err != nil { - return nil, resp, err - } - - return fp, resp, nil + return do[*FreezePeriod](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/freeze_periods", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateFreezePeriodOptions represents the available UpdateFreezePeriodOptions() @@ -171,24 +131,12 @@ type UpdateFreezePeriodOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/freeze_periods/#update-a-freeze-period func (s *FreezePeriodsService) UpdateFreezePeriodOptions(pid any, freezePeriod int64, opt *UpdateFreezePeriodOptions, options ...RequestOptionFunc) (*FreezePeriod, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/freeze_periods/%d", PathEscape(project), freezePeriod) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - fp := new(FreezePeriod) - resp, err := s.client.Do(req, fp) - if err != nil { - return nil, resp, err - } - - return fp, resp, nil + return do[*FreezePeriod](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/freeze_periods/%d", ProjectID{pid}, freezePeriod), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteFreezePeriod removes a freeze period from a project. This is an @@ -198,16 +146,10 @@ func (s *FreezePeriodsService) UpdateFreezePeriodOptions(pid any, freezePeriod i // GitLab API docs: // https://docs.gitlab.com/api/freeze_periods/#delete-a-freeze-period func (s *FreezePeriodsService) DeleteFreezePeriod(pid any, freezePeriod int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/freeze_periods/%d", PathEscape(project), freezePeriod) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/freeze_periods/%d", ProjectID{pid}, freezePeriod), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/geo_nodes.go b/vendor/gitlab.com/gitlab-org/api/client-go/geo_nodes.go index 720731a..670343a 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/geo_nodes.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/geo_nodes.go @@ -16,10 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" -) +import "net/http" type ( // Deprecated: will be removed in v5 of the API, use Geo Sites API instead @@ -120,18 +117,12 @@ type CreateGeoNodesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/geo_nodes/#create-a-new-geo-node func (s *GeoNodesService) CreateGeoNode(opt *CreateGeoNodesOptions, options ...RequestOptionFunc) (*GeoNode, *Response, error) { - req, err := s.client.NewRequest(http.MethodPost, "geo_nodes", opt, options) - if err != nil { - return nil, nil, err - } - - g := new(GeoNode) - resp, err := s.client.Do(req, g) - if err != nil { - return nil, resp, err - } - - return g, resp, nil + return do[*GeoNode](s.client, + withMethod(http.MethodPost), + withPath("geo_nodes"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // ListGeoNodesOptions represents the available ListGeoNodes() options. @@ -149,18 +140,11 @@ type ListGeoNodesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/geo_nodes/#retrieve-configuration-about-all-geo-nodes func (s *GeoNodesService) ListGeoNodes(opt *ListGeoNodesOptions, options ...RequestOptionFunc) ([]*GeoNode, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "geo_nodes", opt, options) - if err != nil { - return nil, nil, err - } - - var gs []*GeoNode - resp, err := s.client.Do(req, &gs) - if err != nil { - return nil, resp, err - } - - return gs, resp, nil + return do[[]*GeoNode](s.client, + withPath("geo_nodes"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetGeoNode gets a specific geo node. @@ -169,20 +153,10 @@ func (s *GeoNodesService) ListGeoNodes(opt *ListGeoNodesOptions, options ...Requ // GitLab API docs: // https://docs.gitlab.com/api/geo_nodes/#retrieve-configuration-about-a-specific-geo-node func (s *GeoNodesService) GetGeoNode(id int64, options ...RequestOptionFunc) (*GeoNode, *Response, error) { - u := fmt.Sprintf("geo_nodes/%d", id) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - g := new(GeoNode) - resp, err := s.client.Do(req, g) - if err != nil { - return nil, resp, err - } - - return g, resp, nil + return do[*GeoNode](s.client, + withPath("geo_nodes/%d", id), + withRequestOpts(options...), + ) } // UpdateGeoNodesOptions represents the available EditGeoNode() options. @@ -213,20 +187,12 @@ type UpdateGeoNodesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/geo_nodes/#edit-a-geo-node func (s *GeoNodesService) EditGeoNode(id int64, opt *UpdateGeoNodesOptions, options ...RequestOptionFunc) (*GeoNode, *Response, error) { - u := fmt.Sprintf("geo_nodes/%d", id) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - g := new(GeoNode) - resp, err := s.client.Do(req, g) - if err != nil { - return nil, resp, err - } - - return g, resp, nil + return do[*GeoNode](s.client, + withMethod(http.MethodPut), + withPath("geo_nodes/%d", id), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteGeoNode removes the Geo node. @@ -235,14 +201,12 @@ func (s *GeoNodesService) EditGeoNode(id int64, opt *UpdateGeoNodesOptions, opti // GitLab API docs: // https://docs.gitlab.com/api/geo_nodes/#delete-a-geo-node func (s *GeoNodesService) DeleteGeoNode(id int64, options ...RequestOptionFunc) (*Response, error) { - u := fmt.Sprintf("geo_nodes/%d", id) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("geo_nodes/%d", id), + withRequestOpts(options...), + ) + return resp, err } // RepairGeoNode to repair the OAuth authentication of a Geo node. @@ -251,20 +215,11 @@ func (s *GeoNodesService) DeleteGeoNode(id int64, options ...RequestOptionFunc) // GitLab API docs: // https://docs.gitlab.com/api/geo_nodes/#repair-a-geo-node func (s *GeoNodesService) RepairGeoNode(id int64, options ...RequestOptionFunc) (*GeoNode, *Response, error) { - u := fmt.Sprintf("geo_nodes/%d/repair", id) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, nil, err - } - - g := new(GeoNode) - resp, err := s.client.Do(req, g) - if err != nil { - return nil, resp, err - } - - return g, resp, nil + return do[*GeoNode](s.client, + withMethod(http.MethodPost), + withPath("geo_nodes/%d/repair", id), + withRequestOpts(options...), + ) } // GeoNodeStatus represents the status of Geo Node. @@ -438,18 +393,10 @@ type GeoNodeStatus struct { // GitLab API docs: // https://docs.gitlab.com/api/geo_nodes/#retrieve-status-about-all-geo-nodes func (s *GeoNodesService) RetrieveStatusOfAllGeoNodes(options ...RequestOptionFunc) ([]*GeoNodeStatus, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "geo_nodes/status", nil, options) - if err != nil { - return nil, nil, err - } - - var gnss []*GeoNodeStatus - resp, err := s.client.Do(req, &gnss) - if err != nil { - return nil, resp, err - } - - return gnss, resp, nil + return do[[]*GeoNodeStatus](s.client, + withPath("geo_nodes/status"), + withRequestOpts(options...), + ) } // RetrieveStatusOfGeoNode get the of status of a specific Geo Nodes. @@ -458,18 +405,8 @@ func (s *GeoNodesService) RetrieveStatusOfAllGeoNodes(options ...RequestOptionFu // GitLab API docs: // https://docs.gitlab.com/api/geo_nodes/#retrieve-status-about-a-specific-geo-node func (s *GeoNodesService) RetrieveStatusOfGeoNode(id int64, options ...RequestOptionFunc) (*GeoNodeStatus, *Response, error) { - u := fmt.Sprintf("geo_nodes/%d/status", id) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - gns := new(GeoNodeStatus) - resp, err := s.client.Do(req, gns) - if err != nil { - return nil, resp, err - } - - return gns, resp, nil + return do[*GeoNodeStatus](s.client, + withPath("geo_nodes/%d/status", id), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/gitlab.go b/vendor/gitlab.com/gitlab-org/api/client-go/gitlab.go index dd67b1f..ea3e146 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/gitlab.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/gitlab.go @@ -255,6 +255,8 @@ type Client struct { ResourceMilestoneEvents ResourceMilestoneEventsServiceInterface ResourceStateEvents ResourceStateEventsServiceInterface ResourceWeightEvents ResourceWeightEventsServiceInterface + RunnerControllers RunnerControllersServiceInterface + RunnerControllerTokens RunnerControllerTokensServiceInterface Runners RunnersServiceInterface Search SearchServiceInterface SecureFiles SecureFilesServiceInterface @@ -571,6 +573,8 @@ func NewAuthSourceClient(as AuthSource, options ...ClientOptionFunc) (*Client, e c.ResourceMilestoneEvents = &ResourceMilestoneEventsService{client: c} c.ResourceStateEvents = &ResourceStateEventsService{client: c} c.ResourceWeightEvents = &ResourceWeightEventsService{client: c} + c.RunnerControllers = &RunnerControllersService{client: c} + c.RunnerControllerTokens = &RunnerControllerTokensService{client: c} c.Runners = &RunnersService{client: c} c.Search = &SearchService{client: c} c.SecureFiles = &SecureFilesService{client: c} @@ -1055,11 +1059,25 @@ func (r *Response) populateLinkValues() { } } +// bodyPreserver is a special type that signals to Client.Do that we want to +// preserve the response body without copying it. The body field will be set +// to the actual response body, and the caller is responsible for closing it. +type bodyPreserver struct { + body io.ReadCloser +} + +// Write implements io.Writer but does nothing. This prevents Client.Do from +// copying the body content. +func (bp *bodyPreserver) Write(_ []byte) (n int, err error) { + return 0, nil +} + // Do sends an API request and returns the API response. The API response is // JSON decoded and stored in the value pointed to by v, or returned as an // error if an API error has occurred. If v implements the io.Writer // interface, the raw response body will be written to v, without attempting to -// first decode it. +// first decode it. If v is a *bodyPreserver, the response body is preserved +// without copying and the caller is responsible for closing it. func (c *Client) Do(req *retryablehttp.Request, v any) (*Response, error) { // Wait will block until the limiter can obtain a new token. err := c.limiter.Wait(req.Context()) @@ -1095,10 +1113,14 @@ func (c *Client) Do(req *retryablehttp.Request, v any) (*Response, error) { return nil, err } - defer func() { - io.Copy(io.Discard, resp.Body) - resp.Body.Close() - }() + // Check if v is a bodyPreserver before setting up the defer + preserver, isPreserver := v.(*bodyPreserver) + if !isPreserver { + defer func() { + io.Copy(io.Discard, resp.Body) + resp.Body.Close() + }() + } // If not yet configured, try to configure the rate limiter // using the response headers we just received. Fail silently @@ -1111,11 +1133,19 @@ func (c *Client) Do(req *retryablehttp.Request, v any) (*Response, error) { if err != nil { // Even though there was an error, we still return the response // in case the caller wants to inspect it further. + // If using bodyPreserver, still need to close the body on error + if isPreserver { + io.Copy(io.Discard, resp.Body) + resp.Body.Close() + } return response, err } if v != nil { - if w, ok := v.(io.Writer); ok { + if isPreserver { + // Preserve the body without copying + preserver.body = resp.Body + } else if w, ok := v.(io.Writer); ok { _, err = io.Copy(w, resp.Body) } else { err = json.NewDecoder(resp.Body).Decode(v) diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/group_badges.go b/vendor/gitlab.com/gitlab-org/api/client-go/group_badges.go index 39d639c..614fe02 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/group_badges.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/group_badges.go @@ -16,10 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" -) +import "net/http" type ( // GroupBadgesServiceInterface defines all the API methods for the GroupBadgesService @@ -80,24 +77,11 @@ type ListGroupBadgesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_badges/#list-all-badges-of-a-group func (s *GroupBadgesService) ListGroupBadges(gid any, opt *ListGroupBadgesOptions, options ...RequestOptionFunc) ([]*GroupBadge, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/badges", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var gb []*GroupBadge - resp, err := s.client.Do(req, &gb) - if err != nil { - return nil, resp, err - } - - return gb, resp, nil + return do[[]*GroupBadge](s.client, + withPath("groups/%s/badges", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetGroupBadge gets a group badge. @@ -105,24 +89,10 @@ func (s *GroupBadgesService) ListGroupBadges(gid any, opt *ListGroupBadgesOption // GitLab API docs: // https://docs.gitlab.com/api/group_badges/#get-a-badge-of-a-group func (s *GroupBadgesService) GetGroupBadge(gid any, badge int64, options ...RequestOptionFunc) (*GroupBadge, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/badges/%d", PathEscape(group), badge) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - gb := new(GroupBadge) - resp, err := s.client.Do(req, gb) - if err != nil { - return nil, resp, err - } - - return gb, resp, nil + return do[*GroupBadge](s.client, + withPath("groups/%s/badges/%d", GroupID{gid}, badge), + withRequestOpts(options...), + ) } // AddGroupBadgeOptions represents the available AddGroupBadge() options. @@ -140,24 +110,12 @@ type AddGroupBadgeOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_badges/#add-a-badge-to-a-group func (s *GroupBadgesService) AddGroupBadge(gid any, opt *AddGroupBadgeOptions, options ...RequestOptionFunc) (*GroupBadge, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/badges", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - gb := new(GroupBadge) - resp, err := s.client.Do(req, gb) - if err != nil { - return nil, resp, err - } - - return gb, resp, nil + return do[*GroupBadge](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/badges", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // EditGroupBadgeOptions represents the available EditGroupBadge() options. @@ -175,24 +133,12 @@ type EditGroupBadgeOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_badges/#edit-a-badge-of-a-group func (s *GroupBadgesService) EditGroupBadge(gid any, badge int64, opt *EditGroupBadgeOptions, options ...RequestOptionFunc) (*GroupBadge, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/badges/%d", PathEscape(group), badge) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - gb := new(GroupBadge) - resp, err := s.client.Do(req, gb) - if err != nil { - return nil, resp, err - } - - return gb, resp, nil + return do[*GroupBadge](s.client, + withMethod(http.MethodPut), + withPath("groups/%s/badges/%d", GroupID{gid}, badge), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteGroupBadge removes a badge from a group. @@ -200,18 +146,12 @@ func (s *GroupBadgesService) EditGroupBadge(gid any, badge int64, opt *EditGroup // GitLab API docs: // https://docs.gitlab.com/api/group_badges/#remove-a-badge-from-a-group func (s *GroupBadgesService) DeleteGroupBadge(gid any, badge int64, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/badges/%d", PathEscape(group), badge) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/badges/%d", GroupID{gid}, badge), + withRequestOpts(options...), + ) + return resp, err } // GroupBadgePreviewOptions represents the available PreviewGroupBadge() options. @@ -230,22 +170,9 @@ type GroupBadgePreviewOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_badges/#preview-a-badge-from-a-group func (s *GroupBadgesService) PreviewGroupBadge(gid any, opt *GroupBadgePreviewOptions, options ...RequestOptionFunc) (*GroupBadge, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/badges/render", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - gb := new(GroupBadge) - resp, err := s.client.Do(req, &gb) - if err != nil { - return nil, resp, err - } - - return gb, resp, nil + return do[*GroupBadge](s.client, + withPath("groups/%s/badges/render", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/group_hooks.go b/vendor/gitlab.com/gitlab-org/api/client-go/group_hooks.go index 30c8818..05b8236 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/group_hooks.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/group_hooks.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -75,23 +74,11 @@ type ListGroupHooksOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#list-group-hooks func (s *GroupsService) ListGroupHooks(gid any, opt *ListGroupHooksOptions, options ...RequestOptionFunc) ([]*GroupHook, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/hooks", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - var gh []*GroupHook - resp, err := s.client.Do(req, &gh) - if err != nil { - return nil, resp, err - } - - return gh, resp, nil + return do[[]*GroupHook](s.client, + withPath("groups/%s/hooks", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetGroupHook gets a specific hook for a group. @@ -99,24 +86,10 @@ func (s *GroupsService) ListGroupHooks(gid any, opt *ListGroupHooksOptions, opti // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#get-a-group-hook func (s *GroupsService) GetGroupHook(gid any, hook int64, options ...RequestOptionFunc) (*GroupHook, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d", PathEscape(group), hook) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - gh := new(GroupHook) - resp, err := s.client.Do(req, gh) - if err != nil { - return nil, resp, err - } - - return gh, resp, nil + return do[*GroupHook](s.client, + withPath("groups/%s/hooks/%d", GroupID{gid}, hook), + withRequestOpts(options...), + ) } // ResendGroupHookEvent resends a specific hook event. @@ -124,18 +97,12 @@ func (s *GroupsService) GetGroupHook(gid any, hook int64, options ...RequestOpti // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#resend-group-hook-event func (s *GroupsService) ResendGroupHookEvent(gid any, hook int64, hookEventID int64, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d/events/%d/resend", PathEscape(group), hook, hookEventID) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/hooks/%d/events/%d/resend", GroupID{gid}, hook, hookEventID), + withRequestOpts(options...), + ) + return resp, err } // AddGroupHookOptions represents the available AddGroupHook() options. @@ -179,24 +146,12 @@ type AddGroupHookOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#add-a-group-hook func (s *GroupsService) AddGroupHook(gid any, opt *AddGroupHookOptions, options ...RequestOptionFunc) (*GroupHook, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/hooks", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - gh := new(GroupHook) - resp, err := s.client.Do(req, gh) - if err != nil { - return nil, resp, err - } - - return gh, resp, nil + return do[*GroupHook](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/hooks", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // EditGroupHookOptions represents the available EditGroupHook() options. @@ -241,24 +196,12 @@ type EditGroupHookOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#edit-group-hook func (s *GroupsService) EditGroupHook(gid any, hook int64, opt *EditGroupHookOptions, options ...RequestOptionFunc) (*GroupHook, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d", PathEscape(group), hook) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - gh := new(GroupHook) - resp, err := s.client.Do(req, gh) - if err != nil { - return nil, resp, err - } - - return gh, resp, nil + return do[*GroupHook](s.client, + withMethod(http.MethodPut), + withPath("groups/%s/hooks/%d", GroupID{gid}, hook), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteGroupHook removes a hook from a group. This is an idempotent @@ -267,18 +210,12 @@ func (s *GroupsService) EditGroupHook(gid any, hook int64, opt *EditGroupHookOpt // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#delete-a-group-hook func (s *GroupsService) DeleteGroupHook(gid any, hook int64, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d", PathEscape(group), hook) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/hooks/%d", GroupID{gid}, hook), + withRequestOpts(options...), + ) + return resp, err } // TriggerTestGroupHook triggers a test hook for a specified group. @@ -286,18 +223,12 @@ func (s *GroupsService) DeleteGroupHook(gid any, hook int64, options ...RequestO // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#trigger-a-test-group-hook func (s *GroupsService) TriggerTestGroupHook(pid any, hook int64, trigger GroupHookTrigger, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d/test/%s", PathEscape(group), hook, trigger) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/hooks/%d/test/%s", GroupID{pid}, hook, NoEscape{string(trigger)}), + withRequestOpts(options...), + ) + return resp, err } // SetGroupCustomHeader creates or updates a group custom webhook header. @@ -305,18 +236,13 @@ func (s *GroupsService) TriggerTestGroupHook(pid any, hook int64, trigger GroupH // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#set-a-custom-header func (s *GroupsService) SetGroupCustomHeader(gid any, hook int64, key string, opt *SetHookCustomHeaderOptions, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d/custom_headers/%s", PathEscape(group), hook, key) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPut), + withPath("groups/%s/hooks/%d/custom_headers/%s", GroupID{gid}, hook, key), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } // DeleteGroupCustomHeader deletes a group custom webhook header. @@ -324,18 +250,12 @@ func (s *GroupsService) SetGroupCustomHeader(gid any, hook int64, key string, op // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#delete-a-custom-header func (s *GroupsService) DeleteGroupCustomHeader(gid any, hook int64, key string, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d/custom_headers/%s", PathEscape(group), hook, key) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/hooks/%d/custom_headers/%s", GroupID{gid}, hook, key), + withRequestOpts(options...), + ) + return resp, err } // SetHookURLVariableOptions represents the available SetGroupHookURLVariable() @@ -352,18 +272,13 @@ type SetHookURLVariableOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#set-a-url-variable func (s *GroupsService) SetGroupHookURLVariable(gid any, hook int64, key string, opt *SetHookURLVariableOptions, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d/url_variables/%s", PathEscape(group), hook, key) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPut), + withPath("groups/%s/hooks/%d/url_variables/%s", GroupID{gid}, hook, key), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } // DeleteGroupHookURLVariable sets a group hook URL variable. @@ -371,16 +286,10 @@ func (s *GroupsService) SetGroupHookURLVariable(gid any, hook int64, key string, // GitLab API docs: // https://docs.gitlab.com/api/group_webhooks/#delete-a-url-variable func (s *GroupsService) DeleteGroupHookURLVariable(gid any, hook int64, key string, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/hooks/%d/url_variables/%s", PathEscape(group), hook, key) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/hooks/%d/url_variables/%s", GroupID{gid}, hook, key), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/group_import_export.go b/vendor/gitlab.com/gitlab-org/api/client-go/group_import_export.go index 77b74f0..6911493 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/group_import_export.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/group_import_export.go @@ -18,6 +18,7 @@ package gitlab import ( "bytes" + "errors" "fmt" "io" "mime/multipart" @@ -101,13 +102,13 @@ type GroupImportFileOptions struct { func (s *GroupImportExportService) ImportFile(opt *GroupImportFileOptions, options ...RequestOptionFunc) (*Response, error) { // First check if we got all required options. if opt.Name == nil || *opt.Name == "" { - return nil, fmt.Errorf("missing required option: Name") + return nil, errors.New("missing required option: Name") } if opt.Path == nil || *opt.Path == "" { - return nil, fmt.Errorf("missing required option: Path") + return nil, errors.New("missing required option: Path") } if opt.File == nil || *opt.File == "" { - return nil, fmt.Errorf("missing required option: File") + return nil, errors.New("missing required option: File") } f, err := os.Open(*opt.File) diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/group_integrations.go b/vendor/gitlab.com/gitlab-org/api/client-go/group_integrations.go new file mode 100644 index 0000000..bf3f87e --- /dev/null +++ b/vendor/gitlab.com/gitlab-org/api/client-go/group_integrations.go @@ -0,0 +1,184 @@ +package gitlab + +import ( + "net/http" + "time" +) + +// GroupMattermostIntegration represents a Mattermost integration for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-notifications +type GroupMattermostIntegration struct { + Integration + NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines"` + BranchesToBeNotified string `json:"branches_to_be_notified"` + LabelsToBeNotified string `json:"labels_to_be_notified"` + LabelsToBeNotifiedBehavior string `json:"labels_to_be_notified_behavior"` + NotifyOnlyDefaultBranch bool `json:"notify_only_default_branch"` + Properties *GroupMattermostIntegrationProperties `json:"properties"` +} + +type GroupMattermostIntegrationProperties struct { + WebHook string `json:"webhook"` + Username string `json:"username"` + Channel string `json:"channel"` + PushChannel string `json:"push_channel"` + IssueChannel string `json:"issue_channel"` + ConfidentialIssueChannel string `json:"confidential_issue_channel"` + MergeRequestChannel string `json:"merge_request_channel"` + NoteChannel string `json:"note_channel"` + ConfidentialNoteChannel string `json:"confidential_note_channel"` + TagPushChannel string `json:"tag_push_channel"` + PipelineChannel string `json:"pipeline_channel"` + WikiPageChannel string `json:"wiki_page_channel"` + DeploymentChannel string `json:"deployment_channel"` + AlertChannel string `json:"alert_channel"` + VulnerabilityChannel string `json:"vulnerability_channel"` +} + +// GroupMattermostIntegrationOptions represents the available options for +// creating or updating a Mattermost integration for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-notifications +type GroupMattermostIntegrationOptions struct { + WebHook *string `url:"webhook,omitempty" json:"webhook,omitempty"` + Username *string `url:"username,omitempty" json:"username,omitempty"` + Channel *string `url:"channel,omitempty" json:"channel,omitempty"` + NotifyOnlyBrokenPipelines *bool `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"` + BranchesToBeNotified *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"` + PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` + IssuesEvents *bool `url:"issues_events,omitempty" json:"issues_events,omitempty"` + ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"` + MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` + TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` + NoteEvents *bool `url:"note_events,omitempty" json:"note_events,omitempty"` + ConfidentialNoteEvents *bool `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"` + PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"` + WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"` + DeploymentEvents *bool `url:"deployment_events,omitempty" json:"deployment_events,omitempty"` + AlertEvents *bool `url:"alert_events,omitempty" json:"alert_events,omitempty"` + VulnerabilityEvents *bool `url:"vulnerability_events,omitempty" json:"vulnerability_events,omitempty"` + PushChannel *string `url:"push_channel,omitempty" json:"push_channel,omitempty"` + IssueChannel *string `url:"issue_channel,omitempty" json:"issue_channel,omitempty"` + ConfidentialIssueChannel *string `url:"confidential_issue_channel,omitempty" json:"confidential_issue_channel,omitempty"` + MergeRequestChannel *string `url:"merge_request_channel,omitempty" json:"merge_request_channel,omitempty"` + NoteChannel *string `url:"note_channel,omitempty" json:"note_channel,omitempty"` + ConfidentialNoteChannel *string `url:"confidential_note_channel,omitempty" json:"confidential_note_channel,omitempty"` + TagPushChannel *string `url:"tag_push_channel,omitempty" json:"tag_push_channel,omitempty"` + PipelineChannel *string `url:"pipeline_channel,omitempty" json:"pipeline_channel,omitempty"` + WikiPageChannel *string `url:"wiki_page_channel,omitempty" json:"wiki_page_channel,omitempty"` + DeploymentChannel *string `url:"deployment_channel,omitempty" json:"deployment_channel,omitempty"` + AlertChannel *string `url:"alert_channel,omitempty" json:"alert_channel,omitempty"` + VulnerabilityChannel *string `url:"vulnerability_channel,omitempty" json:"vulnerability_channel,omitempty"` + LabelsToBeNotified *string `url:"labels_to_be_notified,omitempty" json:"labels_to_be_notified,omitempty"` + LabelsToBeNotifiedBehavior *string `url:"labels_to_be_notified_behavior,omitempty" json:"labels_to_be_notified_behavior,omitempty"` + NotifyOnlyDefaultBranch *bool `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"` + UseInheritedSettings *bool `url:"use_inherited_settings,omitempty" json:"use_inherited_settings,omitempty"` +} + +// GetGroupMattermostIntegration retrieves the Mattermost integration for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-notifications +func (s *IntegrationsService) GetGroupMattermostIntegration(gid any, options ...RequestOptionFunc) (*GroupMattermostIntegration, *Response, error) { + return do[*GroupMattermostIntegration]( + s.client, + withPath("groups/%s/integrations/mattermost", GroupID{gid}), + withMethod(http.MethodGet), + withRequestOpts(options...), + ) +} + +// SetGroupMattermostIntegration creates or updates the Mattermost integration for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-notifications +func (s *IntegrationsService) SetGroupMattermostIntegration(gid any, opt *GroupMattermostIntegrationOptions, options ...RequestOptionFunc) (*GroupMattermostIntegration, *Response, error) { + return do[*GroupMattermostIntegration]( + s.client, + withPath("groups/%s/integrations/mattermost", GroupID{gid}), + withMethod(http.MethodPut), + withAPIOpts(opt), + withRequestOpts(options...), + ) +} + +// DeleteGroupMattermostIntegration removes the Mattermost integration from a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-notifications +func (s *IntegrationsService) DeleteGroupMattermostIntegration(gid any, options ...RequestOptionFunc) (*Response, error) { + _, resp, err := do[none]( + s.client, + withPath("groups/%s/integrations/mattermost", GroupID{gid}), + withMethod(http.MethodDelete), + withRequestOpts(options...), + ) + return resp, err +} + +// GroupMattermostSlashCommandsIntegration represents a Mattermost slash commands integration for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-slash-commands +type GroupMattermostSlashCommandsIntegration struct { + ID int `json:"id"` + Title string `json:"title"` + Slug string `json:"slug"` + CreatedAt *time.Time `json:"created_at"` + UpdatedAt *time.Time `json:"updated_at"` + Token string `json:"token"` +} + +// GroupMattermostSlashCommandsIntegrationOptions represents the available options for +// creating or updating a Mattermost slash commands integration for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-slash-commands +type GroupMattermostSlashCommandsIntegrationOptions struct { + Token *string `url:"token,omitempty" json:"token,omitempty"` + UseInheritedSettings *bool `url:"use_inherited_settings,omitempty" json:"use_inherited_settings,omitempty"` +} + +// GetGroupMattermostSlashCommandsIntegration retrieves the Mattermost slash commands integration for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-slash-commands +func (s *IntegrationsService) GetGroupMattermostSlashCommandsIntegration(gid any, options ...RequestOptionFunc) (*GroupMattermostSlashCommandsIntegration, *Response, error) { + return do[*GroupMattermostSlashCommandsIntegration]( + s.client, + withPath("groups/%s/integrations/mattermost-slash-commands", GroupID{gid}), + withMethod(http.MethodGet), + withRequestOpts(options...), + ) +} + +// SetGroupMattermostSlashCommandsIntegration creates or updates the Mattermost slash commands integration for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-slash-commands +func (s *IntegrationsService) SetGroupMattermostSlashCommandsIntegration(gid any, opt *GroupMattermostSlashCommandsIntegrationOptions, options ...RequestOptionFunc) (*GroupMattermostSlashCommandsIntegration, *Response, error) { + return do[*GroupMattermostSlashCommandsIntegration]( + s.client, + withPath("groups/%s/integrations/mattermost-slash-commands", GroupID{gid}), + withMethod(http.MethodPut), + withAPIOpts(opt), + withRequestOpts(options...), + ) +} + +// DeleteGroupMattermostSlashCommandsIntegration removes the Mattermost slash commands integration from a group. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-slash-commands +func (s *IntegrationsService) DeleteGroupMattermostSlashCommandsIntegration(gid any, options ...RequestOptionFunc) (*Response, error) { + _, resp, err := do[none]( + s.client, + withPath("groups/%s/integrations/mattermost-slash-commands", GroupID{gid}), + withMethod(http.MethodDelete), + withRequestOpts(options...), + ) + return resp, err +} diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/group_iterations.go b/vendor/gitlab.com/gitlab-org/api/client-go/group_iterations.go index 7f7b84a..2b14b1b 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/group_iterations.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/group_iterations.go @@ -16,11 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" - "time" -) +import "time" type ( GroupIterationsServiceInterface interface { @@ -77,22 +73,9 @@ type ListGroupIterationsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_iterations/#list-group-iterations func (s *GroupIterationsService) ListGroupIterations(gid any, opt *ListGroupIterationsOptions, options ...RequestOptionFunc) ([]*GroupIteration, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/iterations", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var gis []*GroupIteration - resp, err := s.client.Do(req, &gis) - if err != nil { - return nil, nil, err - } - - return gis, resp, nil + return do[[]*GroupIteration](s.client, + withPath("groups/%s/iterations", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/group_labels.go b/vendor/gitlab.com/gitlab-org/api/client-go/group_labels.go index 4411848..ca3d628 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/group_labels.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/group_labels.go @@ -69,24 +69,11 @@ type ListGroupLabelsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#list-group-labels func (s *GroupLabelsService) ListGroupLabels(gid any, opt *ListGroupLabelsOptions, options ...RequestOptionFunc) ([]*GroupLabel, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/labels", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var l []*GroupLabel - resp, err := s.client.Do(req, &l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[[]*GroupLabel](s.client, + withPath("groups/%s/labels", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetGroupLabel get a single label for a given group. @@ -94,28 +81,10 @@ func (s *GroupLabelsService) ListGroupLabels(gid any, opt *ListGroupLabelsOption // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#get-a-single-group-label func (s *GroupLabelsService) GetGroupLabel(gid any, lid any, options ...RequestOptionFunc) (*GroupLabel, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - label, err := parseID(lid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/labels/%s", PathEscape(group), PathEscape(label)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var l *GroupLabel - resp, err := s.client.Do(req, &l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*GroupLabel](s.client, + withPath("groups/%s/labels/%s", GroupID{gid}, LabelID{lid}), + withRequestOpts(options...), + ) } // CreateGroupLabelOptions represents the available CreateGroupLabel() options. @@ -135,24 +104,12 @@ type CreateGroupLabelOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#create-a-new-group-label func (s *GroupLabelsService) CreateGroupLabel(gid any, opt *CreateGroupLabelOptions, options ...RequestOptionFunc) (*GroupLabel, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/labels", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - l := new(GroupLabel) - resp, err := s.client.Do(req, l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*GroupLabel](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/labels", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteGroupLabelOptions represents the available DeleteGroupLabel() options. @@ -243,28 +200,11 @@ func (s *GroupLabelsService) UpdateGroupLabel(gid any, lid any, opt *UpdateGroup // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#subscribe-to-a-group-label func (s *GroupLabelsService) SubscribeToGroupLabel(gid any, lid any, options ...RequestOptionFunc) (*GroupLabel, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - label, err := parseID(lid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/labels/%s/subscribe", PathEscape(group), PathEscape(label)) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, nil, err - } - - l := new(GroupLabel) - resp, err := s.client.Do(req, l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*GroupLabel](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/labels/%s/subscribe", GroupID{gid}, LabelID{lid}), + withRequestOpts(options...), + ) } // UnsubscribeFromGroupLabel unsubscribes the authenticated user from a label to not @@ -274,20 +214,10 @@ func (s *GroupLabelsService) SubscribeToGroupLabel(gid any, lid any, options ... // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#unsubscribe-from-a-group-label func (s *GroupLabelsService) UnsubscribeFromGroupLabel(gid any, lid any, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - label, err := parseID(lid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/labels/%s/unsubscribe", PathEscape(group), PathEscape(label)) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/labels/%s/unsubscribe", GroupID{gid}, LabelID{lid}), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/group_milestones.go b/vendor/gitlab.com/gitlab-org/api/client-go/group_milestones.go index 2a687ab..0607e25 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/group_milestones.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/group_milestones.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -95,24 +94,11 @@ type ListGroupMilestonesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_milestones/#list-group-milestones func (s *GroupMilestonesService) ListGroupMilestones(gid any, opt *ListGroupMilestonesOptions, options ...RequestOptionFunc) ([]*GroupMilestone, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/milestones", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var m []*GroupMilestone - resp, err := s.client.Do(req, &m) - if err != nil { - return nil, resp, err - } - - return m, resp, nil + return do[[]*GroupMilestone](s.client, + withPath("groups/%s/milestones", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetGroupMilestone gets a single group milestone. @@ -120,24 +106,10 @@ func (s *GroupMilestonesService) ListGroupMilestones(gid any, opt *ListGroupMile // GitLab API docs: // https://docs.gitlab.com/api/group_milestones/#get-single-milestone func (s *GroupMilestonesService) GetGroupMilestone(gid any, milestone int64, options ...RequestOptionFunc) (*GroupMilestone, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/milestones/%d", PathEscape(group), milestone) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - m := new(GroupMilestone) - resp, err := s.client.Do(req, m) - if err != nil { - return nil, resp, err - } - - return m, resp, nil + return do[*GroupMilestone](s.client, + withPath("groups/%s/milestones/%d", GroupID{gid}, milestone), + withRequestOpts(options...), + ) } // CreateGroupMilestoneOptions represents the available CreateGroupMilestone() options. @@ -156,24 +128,12 @@ type CreateGroupMilestoneOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_milestones/#create-new-milestone func (s *GroupMilestonesService) CreateGroupMilestone(gid any, opt *CreateGroupMilestoneOptions, options ...RequestOptionFunc) (*GroupMilestone, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/milestones", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - m := new(GroupMilestone) - resp, err := s.client.Do(req, m) - if err != nil { - return nil, resp, err - } - - return m, resp, nil + return do[*GroupMilestone](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/milestones", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateGroupMilestoneOptions represents the available UpdateGroupMilestone() options. @@ -193,24 +153,12 @@ type UpdateGroupMilestoneOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_milestones/#edit-milestone func (s *GroupMilestonesService) UpdateGroupMilestone(gid any, milestone int64, opt *UpdateGroupMilestoneOptions, options ...RequestOptionFunc) (*GroupMilestone, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/milestones/%d", PathEscape(group), milestone) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - m := new(GroupMilestone) - resp, err := s.client.Do(req, m) - if err != nil { - return nil, resp, err - } - - return m, resp, nil + return do[*GroupMilestone](s.client, + withMethod(http.MethodPut), + withPath("groups/%s/milestones/%d", GroupID{gid}, milestone), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteGroupMilestone deletes a specified group milestone. @@ -218,17 +166,12 @@ func (s *GroupMilestonesService) UpdateGroupMilestone(gid any, milestone int64, // GitLab API docs: // https://docs.gitlab.com/api/group_milestones/#delete-group-milestone func (s *GroupMilestonesService) DeleteGroupMilestone(pid any, milestone int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/milestones/%d", PathEscape(project), milestone) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/milestones/%d", GroupID{pid}, milestone), + withRequestOpts(options...), + ) + return resp, err } // GetGroupMilestoneIssuesOptions represents the available GetGroupMilestoneIssues() options. @@ -244,24 +187,11 @@ type GetGroupMilestoneIssuesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_milestones/#get-all-issues-assigned-to-a-single-milestone func (s *GroupMilestonesService) GetGroupMilestoneIssues(gid any, milestone int64, opt *GetGroupMilestoneIssuesOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/milestones/%d/issues", PathEscape(group), milestone) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var i []*Issue - resp, err := s.client.Do(req, &i) - if err != nil { - return nil, resp, err - } - - return i, resp, nil + return do[[]*Issue](s.client, + withPath("groups/%s/milestones/%d/issues", GroupID{gid}, milestone), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetGroupMilestoneMergeRequestsOptions represents the available @@ -279,24 +209,11 @@ type GetGroupMilestoneMergeRequestsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_milestones/#get-all-merge-requests-assigned-to-a-single-milestone func (s *GroupMilestonesService) GetGroupMilestoneMergeRequests(gid any, milestone int64, opt *GetGroupMilestoneMergeRequestsOptions, options ...RequestOptionFunc) ([]*BasicMergeRequest, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/milestones/%d/merge_requests", PathEscape(group), milestone) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var mr []*BasicMergeRequest - resp, err := s.client.Do(req, &mr) - if err != nil { - return nil, resp, err - } - - return mr, resp, nil + return do[[]*BasicMergeRequest](s.client, + withPath("groups/%s/milestones/%d/merge_requests", GroupID{gid}, milestone), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // BurndownChartEvent represents a burnout chart event. @@ -324,22 +241,9 @@ type GetGroupMilestoneBurndownChartEventsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_milestones/#get-all-burndown-chart-events-for-a-single-milestone func (s *GroupMilestonesService) GetGroupMilestoneBurndownChartEvents(gid any, milestone int64, opt *GetGroupMilestoneBurndownChartEventsOptions, options ...RequestOptionFunc) ([]*BurndownChartEvent, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/milestones/%d/burndown_events", PathEscape(group), milestone) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var be []*BurndownChartEvent - resp, err := s.client.Do(req, &be) - if err != nil { - return nil, resp, err - } - - return be, resp, nil + return do[[]*BurndownChartEvent](s.client, + withPath("groups/%s/milestones/%d/burndown_events", GroupID{gid}, milestone), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/group_serviceaccounts.go b/vendor/gitlab.com/gitlab-org/api/client-go/group_serviceaccounts.go index b4e3134..f8cd5bf 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/group_serviceaccounts.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/group_serviceaccounts.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -48,24 +47,11 @@ type ListServiceAccountsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/service_accounts/#list-all-group-service-accounts func (s *GroupsService) ListServiceAccounts(gid any, opt *ListServiceAccountsOptions, options ...RequestOptionFunc) ([]*GroupServiceAccount, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/service_accounts", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var sa []*GroupServiceAccount - resp, err := s.client.Do(req, &sa) - if err != nil { - return nil, resp, err - } - - return sa, resp, nil + return do[[]*GroupServiceAccount](s.client, + withPath("groups/%s/service_accounts", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // CreateServiceAccountOptions represents the available CreateServiceAccount() options. @@ -85,24 +71,12 @@ type CreateServiceAccountOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/service_accounts/#create-a-group-service-account func (s *GroupsService) CreateServiceAccount(gid any, opt *CreateServiceAccountOptions, options ...RequestOptionFunc) (*GroupServiceAccount, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/service_accounts", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - sa := new(GroupServiceAccount) - resp, err := s.client.Do(req, sa) - if err != nil { - return nil, resp, err - } - - return sa, resp, nil + return do[*GroupServiceAccount](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/service_accounts", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateServiceAccountOptions represents the available UpdateServiceAccount() options. @@ -122,24 +96,12 @@ type UpdateServiceAccountOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/service_accounts/#update-a-group-service-account func (s *GroupsService) UpdateServiceAccount(gid any, serviceAccount int64, opt *UpdateServiceAccountOptions, options ...RequestOptionFunc) (*GroupServiceAccount, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/service_accounts/%d", PathEscape(group), serviceAccount) - - req, err := s.client.NewRequest(http.MethodPatch, u, opt, options) - if err != nil { - return nil, nil, err - } - - sa := new(GroupServiceAccount) - resp, err := s.client.Do(req, sa) - if err != nil { - return nil, resp, err - } - - return sa, resp, nil + return do[*GroupServiceAccount](s.client, + withMethod(http.MethodPatch), + withPath("groups/%s/service_accounts/%d", GroupID{gid}, serviceAccount), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteServiceAccountOptions represents the available DeleteServiceAccount() options. @@ -157,18 +119,13 @@ type DeleteServiceAccountOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/service_accounts/#delete-a-group-service-account func (s *GroupsService) DeleteServiceAccount(gid any, serviceAccount int64, opt *DeleteServiceAccountOptions, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/service_accounts/%d", PathEscape(group), serviceAccount) - - req, err := s.client.NewRequest(http.MethodDelete, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/service_accounts/%d", GroupID{gid}, serviceAccount), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } // ListServiceAccountPersonalAccessTokensOptions represents the available @@ -197,24 +154,11 @@ type ListServiceAccountPersonalAccessTokensOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/service_accounts/#list-all-personal-access-tokens-for-a-group-service-account func (s *GroupsService) ListServiceAccountPersonalAccessTokens(gid any, serviceAccount int64, opt *ListServiceAccountPersonalAccessTokensOptions, options ...RequestOptionFunc) ([]*PersonalAccessToken, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/service_accounts/%d/personal_access_tokens", PathEscape(group), serviceAccount) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var pats []*PersonalAccessToken - resp, err := s.client.Do(req, &pats) - if err != nil { - return nil, resp, err - } - - return pats, resp, nil + return do[[]*PersonalAccessToken](s.client, + withPath("groups/%s/service_accounts/%d/personal_access_tokens", GroupID{gid}, serviceAccount), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // CreateServiceAccountPersonalAccessTokenOptions represents the available @@ -235,24 +179,12 @@ type CreateServiceAccountPersonalAccessTokenOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/service_accounts/#create-a-personal-access-token-for-a-group-service-account func (s *GroupsService) CreateServiceAccountPersonalAccessToken(gid any, serviceAccount int64, opt *CreateServiceAccountPersonalAccessTokenOptions, options ...RequestOptionFunc) (*PersonalAccessToken, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/service_accounts/%d/personal_access_tokens", PathEscape(group), serviceAccount) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - pat := new(PersonalAccessToken) - resp, err := s.client.Do(req, pat) - if err != nil { - return nil, resp, err - } - - return pat, resp, nil + return do[*PersonalAccessToken](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/service_accounts/%d/personal_access_tokens", GroupID{gid}, serviceAccount), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // RevokeServiceAccountPersonalAccessToken revokes a personal access token for an @@ -261,18 +193,12 @@ func (s *GroupsService) CreateServiceAccountPersonalAccessToken(gid any, service // GitLab API docs: // https://docs.gitlab.com/api/service_accounts/#revoke-a-personal-access-token-for-a-group-service-account func (s *GroupsService) RevokeServiceAccountPersonalAccessToken(gid any, serviceAccount, token int64, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/service_accounts/%d/personal_access_tokens/%d", PathEscape(group), serviceAccount, token) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/service_accounts/%d/personal_access_tokens/%d", GroupID{gid}, serviceAccount, token), + withRequestOpts(options...), + ) + return resp, err } // RotateServiceAccountPersonalAccessTokenOptions represents the available RotateServiceAccountPersonalAccessToken() @@ -290,22 +216,10 @@ type RotateServiceAccountPersonalAccessTokenOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/service_accounts/#rotate-a-personal-access-token-for-a-group-service-account func (s *GroupsService) RotateServiceAccountPersonalAccessToken(gid any, serviceAccount, token int64, opt *RotateServiceAccountPersonalAccessTokenOptions, options ...RequestOptionFunc) (*PersonalAccessToken, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/service_accounts/%d/personal_access_tokens/%d/rotate", PathEscape(group), serviceAccount, token) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - pat := new(PersonalAccessToken) - resp, err := s.client.Do(req, pat) - if err != nil { - return nil, resp, err - } - - return pat, resp, nil + return do[*PersonalAccessToken](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/service_accounts/%d/personal_access_tokens/%d/rotate", GroupID{gid}, serviceAccount, token), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/groups.go b/vendor/gitlab.com/gitlab-org/api/client-go/groups.go index 8800288..967da26 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/groups.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/groups.go @@ -19,6 +19,7 @@ package gitlab import ( "bytes" "encoding/json" + "errors" "fmt" "io" "net/http" @@ -116,6 +117,7 @@ type Group struct { MembershipLock bool `json:"membership_lock"` Visibility VisibilityValue `json:"visibility"` LFSEnabled bool `json:"lfs_enabled"` + MaxArtifactsSize int64 `json:"max_artifacts_size"` DefaultBranch string `json:"default_branch"` DefaultBranchProtectionDefaults *BranchProtectionDefaults `json:"default_branch_protection_defaults"` AvatarURL string `json:"avatar_url"` @@ -152,6 +154,10 @@ type Group struct { AllowedEmailDomainsList string `json:"allowed_email_domains_list"` WikiAccessLevel AccessControlValue `json:"wiki_access_level"` + OnlyAllowMergeIfPipelineSucceeds bool `json:"only_allow_merge_if_pipeline_succeeds"` + AllowMergeOnSkippedPipeline bool `json:"allow_merge_on_skipped_pipeline"` + OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"` + // Deprecated: will be removed in v5 of the API, use ListGroupProjects instead Projects []*Project `json:"projects"` @@ -340,6 +346,7 @@ func (s *GroupsService) ListDescendantGroups(gid any, opt *ListDescendantGroupsO // https://docs.gitlab.com/api/groups/#list-projects type ListGroupProjectsOptions struct { ListOptions + Active *bool `url:"active,omitempty" json:"active,omitempty"` Archived *bool `url:"archived,omitempty" json:"archived,omitempty"` IncludeSubGroups *bool `url:"include_subgroups,omitempty" json:"include_subgroups,omitempty"` MinAccessLevel *AccessLevelValue `url:"min_access_level,omitempty" json:"min_access_level,omitempty"` @@ -540,7 +547,7 @@ func (s *GroupsService) CreateGroup(opt *CreateGroupOptions, options ...RequestO // since the Avatar is provided, check allowed_to_push and // allowed_to_merge access levels and error if multiples are provided if opt.DefaultBranchProtectionDefaults != nil && (len(*opt.DefaultBranchProtectionDefaults.AllowedToMerge) > 1 || len(*opt.DefaultBranchProtectionDefaults.AllowedToPush) > 1) { - return nil, nil, fmt.Errorf("multiple access levels for allowed_to_merge or allowed_to_push are not permitted when an Avatar is also specified as it will result in unexpected behavior") + return nil, nil, errors.New("multiple access levels for allowed_to_merge or allowed_to_push are not permitted when an Avatar is also specified as it will result in unexpected behavior") } req, err = s.client.UploadRequest( http.MethodPost, @@ -649,6 +656,7 @@ type UpdateGroupOptions struct { EmailsEnabled *bool `url:"emails_enabled,omitempty" json:"emails_enabled,omitempty"` MentionsDisabled *bool `url:"mentions_disabled,omitempty" json:"mentions_disabled,omitempty"` LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"` + MaxArtifactsSize *int64 `url:"max_artifacts_size,omitempty" json:"max_artifacts_size,omitempty"` RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"` DefaultBranchProtectionDefaults *DefaultBranchProtectionDefaultsOptions `url:"default_branch_protection_defaults,omitempty" json:"default_branch_protection_defaults,omitempty"` FileTemplateProjectID *int64 `url:"file_template_project_id,omitempty" json:"file_template_project_id,omitempty"` @@ -661,6 +669,10 @@ type UpdateGroupOptions struct { AllowedEmailDomainsList *string `url:"allowed_email_domains_list,omitempty" json:"allowed_email_domains_list,omitempty"` WikiAccessLevel *AccessControlValue `url:"wiki_access_level,omitempty" json:"wiki_access_level,omitempty"` + OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"` + AllowMergeOnSkippedPipeline *bool `url:"allow_merge_on_skipped_pipeline,omitempty" json:"allow_merge_on_skipped_pipeline,omitempty"` + OnlyAllowMergeIfAllDiscussionsAreResolved *bool `url:"only_allow_merge_if_all_discussions_are_resolved,omitempty" json:"only_allow_merge_if_all_discussions_are_resolved,omitempty"` + // Deprecated: Use EmailsEnabled instead EmailsDisabled *bool `url:"emails_disabled,omitempty" json:"emails_disabled,omitempty"` @@ -693,7 +705,7 @@ func (s *GroupsService) UpdateGroup(gid any, opt *UpdateGroupOptions, options .. // since the Avatar is provided, check allowed_to_push and // allowed_to_merge access levels and error if multiples are provided if opt.DefaultBranchProtectionDefaults != nil && (len(*opt.DefaultBranchProtectionDefaults.AllowedToMerge) > 1 || len(*opt.DefaultBranchProtectionDefaults.AllowedToPush) > 1) { - return nil, nil, fmt.Errorf("multiple access levels for allowed_to_merge or allowed_to_push are not permitted when an Avatar is also specified as it will result in unexpected behavior") + return nil, nil, errors.New("multiple access levels for allowed_to_merge or allowed_to_push are not permitted when an Avatar is also specified as it will result in unexpected behavior") } req, err = s.client.UploadRequest( http.MethodPut, diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/integrations.go b/vendor/gitlab.com/gitlab-org/api/client-go/integrations.go index 9eeb390..0450aad 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/integrations.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/integrations.go @@ -83,6 +83,72 @@ type ( // GitLab API docs: // https://docs.gitlab.com/api/group_integrations/#get-jira-settings GetGroupJiraSettings(gid any, options ...RequestOptionFunc) (*Integration, *Response, error) + + // GetGroupDiscordSettings gets the Discord integration settings for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#discord + GetGroupDiscordSettings(gid any, options ...RequestOptionFunc) (*DiscordIntegration, *Response, error) + + // GetGroupTelegramSettings gets the Telegram integration settings for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#telegram + GetGroupTelegramSettings(gid any, options ...RequestOptionFunc) (*TelegramIntegration, *Response, error) + + // GetGroupMattermostSettings gets the Mattermost integration settings for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#mattermost-notifications + GetGroupMattermostSettings(gid any, options ...RequestOptionFunc) (*MattermostIntegration, *Response, error) + + // GetGroupMatrixSettings gets the Matrix integration settings for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#matrix-notifications + GetGroupMatrixSettings(gid any, options ...RequestOptionFunc) (*MatrixIntegration, *Response, error) + + // GetGroupGoogleChatSettings gets the Google Chat integration settings for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#google-chat + GetGroupGoogleChatSettings(gid any, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) + + // GetGroupMattermostIntegration retrieves the Mattermost integration for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#mattermost-notifications + GetGroupMattermostIntegration(gid any, options ...RequestOptionFunc) (*GroupMattermostIntegration, *Response, error) + + // SetGroupMattermostIntegration creates or updates the Mattermost integration for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#mattermost-notifications + SetGroupMattermostIntegration(gid any, opt *GroupMattermostIntegrationOptions, options ...RequestOptionFunc) (*GroupMattermostIntegration, *Response, error) + + // DeleteGroupMattermostIntegration removes the Mattermost integration from a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#mattermost-notifications + DeleteGroupMattermostIntegration(gid any, options ...RequestOptionFunc) (*Response, error) + + // GetGroupMattermostSlashCommandsIntegration retrieves the Mattermost slash commands integration for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#mattermost-slash-commands + GetGroupMattermostSlashCommandsIntegration(gid any, options ...RequestOptionFunc) (*GroupMattermostSlashCommandsIntegration, *Response, error) + + // SetGroupMattermostSlashCommandsIntegration creates or updates the Mattermost slash commands integration for a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#mattermost-slash-commands + SetGroupMattermostSlashCommandsIntegration(gid any, opt *GroupMattermostSlashCommandsIntegrationOptions, options ...RequestOptionFunc) (*GroupMattermostSlashCommandsIntegration, *Response, error) + + // DeleteGroupMattermostSlashCommandsIntegration removes the Mattermost slash commands integration from a group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_integrations/#mattermost-slash-commands + DeleteGroupMattermostSlashCommandsIntegration(gid any, options ...RequestOptionFunc) (*Response, error) } // IntegrationsService handles communication with the group @@ -129,6 +195,101 @@ type Integration struct { Inherited bool `json:"inherited"` } +// DiscordIntegration represents the Discord integration settings. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#discord +type DiscordIntegration struct { + Integration + Properties DiscordIntegrationProperties `json:"properties"` +} + +// DiscordIntegrationProperties represents Discord specific properties. +type DiscordIntegrationProperties struct { + NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines,omitempty"` + BranchesToBeNotified string `json:"branches_to_be_notified,omitempty"` +} + +// TelegramIntegration represents the Telegram integration settings. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#telegram +type TelegramIntegration struct { + Integration + Properties TelegramIntegrationProperties `json:"properties"` +} + +// TelegramIntegrationProperties represents Telegram specific properties. +type TelegramIntegrationProperties struct { + Hostname string `json:"hostname,omitempty"` + Room string `json:"room,omitempty"` + Thread string `json:"thread,omitempty"` + NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines,omitempty"` + BranchesToBeNotified string `json:"branches_to_be_notified,omitempty"` +} + +// MattermostIntegration represents the Mattermost integration settings. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#mattermost-notifications +type MattermostIntegration struct { + Integration + Properties MattermostIntegrationProperties `json:"properties"` +} + +// MattermostIntegrationProperties represents Mattermost specific properties. +type MattermostIntegrationProperties struct { + Username string `json:"username,omitempty"` + Channel string `json:"channel,omitempty"` + NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines,omitempty"` + BranchesToBeNotified string `json:"branches_to_be_notified,omitempty"` + LabelsToBeNotified string `json:"labels_to_be_notified,omitempty"` + LabelsToBeNotifiedBehavior string `json:"labels_to_be_notified_behavior,omitempty"` + PushChannel string `json:"push_channel,omitempty"` + IssueChannel string `json:"issue_channel,omitempty"` + ConfidentialIssueChannel string `json:"confidential_issue_channel,omitempty"` + MergeRequestChannel string `json:"merge_request_channel,omitempty"` + NoteChannel string `json:"note_channel,omitempty"` + ConfidentialNoteChannel string `json:"confidential_note_channel,omitempty"` + TagPushChannel string `json:"tag_push_channel,omitempty"` + PipelineChannel string `json:"pipeline_channel,omitempty"` + WikiPageChannel string `json:"wiki_page_channel,omitempty"` + DeploymentChannel string `json:"deployment_channel,omitempty"` + IncidentChannel string `json:"incident_channel,omitempty"` +} + +// MatrixIntegration represents the Matrix integration settings. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#matrix-notifications +type MatrixIntegration struct { + Integration + Properties MatrixIntegrationProperties `json:"properties"` +} + +// MatrixIntegrationProperties represents Matrix specific properties. +type MatrixIntegrationProperties struct { + Hostname string `json:"hostname,omitempty"` + Room string `json:"room,omitempty"` + NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines,omitempty"` + BranchesToBeNotified string `json:"branches_to_be_notified,omitempty"` +} + +// GoogleChatIntegration represents the Google Chat integration settings. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_integrations/#google-chat +type GoogleChatIntegration struct { + Integration + Properties GoogleChatIntegrationProperties `json:"properties"` +} + +// GoogleChatIntegrationProperties represents Google Chat specific properties. +type GoogleChatIntegrationProperties struct { + NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines,omitempty"` + BranchesToBeNotified string `json:"branches_to_be_notified,omitempty"` +} + // ListActiveIntegrationsOptions represents the available // ListActiveIntegrations() options. // @@ -216,7 +377,7 @@ type SetMicrosoftTeamsNotificationsOptions struct { func (s *IntegrationsService) SetGroupMicrosoftTeamsNotifications(gid any, opt *SetMicrosoftTeamsNotificationsOptions, options ...RequestOptionFunc) (*Integration, *Response, error) { return do[*Integration]( s.client, - withPath("groups/%s/integrations/microsoft_teams", GroupID{gid}), + withPath("groups/%s/integrations/microsoft-teams", GroupID{gid}), withMethod(http.MethodPut), withAPIOpts(opt), withRequestOpts(options...), @@ -226,7 +387,7 @@ func (s *IntegrationsService) SetGroupMicrosoftTeamsNotifications(gid any, opt * func (s *IntegrationsService) DisableGroupMicrosoftTeamsNotifications(gid any, options ...RequestOptionFunc) (*Response, error) { _, resp, err := do[none]( s.client, - withPath("groups/%s/integrations/microsoft_teams", GroupID{gid}), + withPath("groups/%s/integrations/microsoft-teams", GroupID{gid}), withMethod(http.MethodDelete), withRequestOpts(options...), ) @@ -236,7 +397,7 @@ func (s *IntegrationsService) DisableGroupMicrosoftTeamsNotifications(gid any, o func (s *IntegrationsService) GetGroupMicrosoftTeamsNotifications(gid any, options ...RequestOptionFunc) (*Integration, *Response, error) { return do[*Integration]( s.client, - withPath("groups/%s/integrations/microsoft_teams", GroupID{gid}), + withPath("groups/%s/integrations/microsoft-teams", GroupID{gid}), withMethod(http.MethodGet), withRequestOpts(options...), ) @@ -293,3 +454,48 @@ func (s *IntegrationsService) GetGroupJiraSettings(gid any, options ...RequestOp withRequestOpts(options...), ) } + +func (s *IntegrationsService) GetGroupDiscordSettings(gid any, options ...RequestOptionFunc) (*DiscordIntegration, *Response, error) { + return do[*DiscordIntegration]( + s.client, + withPath("groups/%s/integrations/discord", GroupID{gid}), + withMethod(http.MethodGet), + withRequestOpts(options...), + ) +} + +func (s *IntegrationsService) GetGroupTelegramSettings(gid any, options ...RequestOptionFunc) (*TelegramIntegration, *Response, error) { + return do[*TelegramIntegration]( + s.client, + withPath("groups/%s/integrations/telegram", GroupID{gid}), + withMethod(http.MethodGet), + withRequestOpts(options...), + ) +} + +func (s *IntegrationsService) GetGroupMattermostSettings(gid any, options ...RequestOptionFunc) (*MattermostIntegration, *Response, error) { + return do[*MattermostIntegration]( + s.client, + withPath("groups/%s/integrations/mattermost", GroupID{gid}), + withMethod(http.MethodGet), + withRequestOpts(options...), + ) +} + +func (s *IntegrationsService) GetGroupMatrixSettings(gid any, options ...RequestOptionFunc) (*MatrixIntegration, *Response, error) { + return do[*MatrixIntegration]( + s.client, + withPath("groups/%s/integrations/matrix", GroupID{gid}), + withMethod(http.MethodGet), + withRequestOpts(options...), + ) +} + +func (s *IntegrationsService) GetGroupGoogleChatSettings(gid any, options ...RequestOptionFunc) (*GoogleChatIntegration, *Response, error) { + return do[*GoogleChatIntegration]( + s.client, + withPath("groups/%s/integrations/hangouts-chat", GroupID{gid}), + withMethod(http.MethodGet), + withRequestOpts(options...), + ) +} diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/issue_links.go b/vendor/gitlab.com/gitlab-org/api/client-go/issue_links.go index 1562e7c..2cf4ce4 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/issue_links.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/issue_links.go @@ -44,6 +44,7 @@ var _ IssueLinksServiceInterface = (*IssueLinksService)(nil) // // GitLab API docs: https://docs.gitlab.com/api/issue_links/ type IssueLink struct { + ID int64 `json:"id"` SourceIssue *Issue `json:"source_issue"` TargetIssue *Issue `json:"target_issue"` LinkType string `json:"link_type"` diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/keys.go b/vendor/gitlab.com/gitlab-org/api/client-go/keys.go index 8d76a22..2fde486 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/keys.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/keys.go @@ -16,11 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" - "time" -) +import "time" type ( KeysServiceInterface interface { @@ -58,20 +54,10 @@ type Key struct { // GitLab API docs: // https://docs.gitlab.com/api/keys/#get-ssh-key-with-user-by-id-of-an-ssh-key func (s *KeysService) GetKeyWithUser(key int64, options ...RequestOptionFunc) (*Key, *Response, error) { - u := fmt.Sprintf("keys/%d", key) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - k := new(Key) - resp, err := s.client.Do(req, k) - if err != nil { - return nil, resp, err - } - - return k, resp, nil + return do[*Key](s.client, + withPath("keys/%d", key), + withRequestOpts(options...), + ) } // GetKeyByFingerprintOptions represents the available GetKeyByFingerprint() @@ -91,16 +77,9 @@ type GetKeyByFingerprintOptions struct { // https://docs.gitlab.com/api/keys/#get-user-by-fingerprint-of-ssh-key // https://docs.gitlab.com/api/keys/#get-user-by-deploy-key-fingerprint func (s *KeysService) GetKeyByFingerprint(opt *GetKeyByFingerprintOptions, options ...RequestOptionFunc) (*Key, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "keys", opt, options) - if err != nil { - return nil, nil, err - } - - k := new(Key) - resp, err := s.client.Do(req, k) - if err != nil { - return nil, resp, err - } - - return k, resp, nil + return do[*Key](s.client, + withPath("keys"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/labels.go b/vendor/gitlab.com/gitlab-org/api/client-go/labels.go index 3a78a14..43619cc 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/labels.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/labels.go @@ -100,52 +100,21 @@ type ListLabelsOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/labels/#list-labels func (s *LabelsService) ListLabels(pid any, opt *ListLabelsOptions, options ...RequestOptionFunc) ([]*Label, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/labels", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var l []*Label - resp, err := s.client.Do(req, &l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[[]*Label](s.client, + withPath("projects/%s/labels", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetLabel get a single label for a given project. // // GitLab API docs: https://docs.gitlab.com/api/labels/#get-a-single-project-label func (s *LabelsService) GetLabel(pid any, lid any, options ...RequestOptionFunc) (*Label, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - label, err := parseID(lid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/labels/%s", PathEscape(project), PathEscape(label)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var l *Label - resp, err := s.client.Do(req, &l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*Label](s.client, + withPath("projects/%s/labels/%s", ProjectID{pid}, LabelID{lid}), + withRequestOpts(options...), + ) } // CreateLabelOptions represents the available CreateLabel() options. @@ -163,24 +132,12 @@ type CreateLabelOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/labels/#create-a-new-label func (s *LabelsService) CreateLabel(pid any, opt *CreateLabelOptions, options ...RequestOptionFunc) (*Label, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/labels", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - l := new(Label) - resp, err := s.client.Do(req, l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*Label](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/labels", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteLabelOptions represents the available DeleteLabel() options. @@ -267,28 +224,11 @@ func (s *LabelsService) UpdateLabel(pid any, lid any, opt *UpdateLabelOptions, o // GitLab API docs: // https://docs.gitlab.com/api/labels/#subscribe-to-a-label func (s *LabelsService) SubscribeToLabel(pid any, lid any, options ...RequestOptionFunc) (*Label, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - label, err := parseID(lid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/labels/%s/subscribe", PathEscape(project), PathEscape(label)) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, nil, err - } - - l := new(Label) - resp, err := s.client.Do(req, l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*Label](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/labels/%s/subscribe", ProjectID{pid}, LabelID{lid}), + withRequestOpts(options...), + ) } // UnsubscribeFromLabel unsubscribes the authenticated user from a label to not @@ -298,22 +238,12 @@ func (s *LabelsService) SubscribeToLabel(pid any, lid any, options ...RequestOpt // GitLab API docs: // https://docs.gitlab.com/api/labels/#unsubscribe-from-a-label func (s *LabelsService) UnsubscribeFromLabel(pid any, lid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - label, err := parseID(lid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/labels/%s/unsubscribe", PathEscape(project), PathEscape(label)) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/labels/%s/unsubscribe", ProjectID{pid}, LabelID{lid}), + withRequestOpts(options...), + ) + return resp, err } // PromoteLabel Promotes a project label to a group label. @@ -321,20 +251,10 @@ func (s *LabelsService) UnsubscribeFromLabel(pid any, lid any, options ...Reques // GitLab API docs: // https://docs.gitlab.com/api/labels/#promote-a-project-label-to-a-group-label func (s *LabelsService) PromoteLabel(pid any, lid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - label, err := parseID(lid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/labels/%s/promote", PathEscape(project), PathEscape(label)) - - req, err := s.client.NewRequest(http.MethodPut, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/labels/%s/promote", ProjectID{pid}, LabelID{lid}), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/license.go b/vendor/gitlab.com/gitlab-org/api/client-go/license.go index 89418fb..762454a 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/license.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/license.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -102,18 +101,10 @@ func (a LicenseAddOns) String() string { // GitLab API docs: // https://docs.gitlab.com/api/license/#retrieve-information-about-the-current-license func (s *LicenseService) GetLicense(options ...RequestOptionFunc) (*License, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "license", nil, options) - if err != nil { - return nil, nil, err - } - - l := new(License) - resp, err := s.client.Do(req, l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*License](s.client, + withPath("license"), + withRequestOpts(options...), + ) } // AddLicenseOptions represents the available AddLicense() options. @@ -128,18 +119,12 @@ type AddLicenseOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/license/#add-a-new-license func (s *LicenseService) AddLicense(opt *AddLicenseOptions, options ...RequestOptionFunc) (*License, *Response, error) { - req, err := s.client.NewRequest(http.MethodPost, "license", opt, options) - if err != nil { - return nil, nil, err - } - - l := new(License) - resp, err := s.client.Do(req, l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*License](s.client, + withMethod(http.MethodPost), + withPath("license"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteLicense deletes an existing license. @@ -147,12 +132,10 @@ func (s *LicenseService) AddLicense(opt *AddLicenseOptions, options ...RequestOp // GitLab API docs: // https://docs.gitlab.com/api/license/#delete-a-license func (s *LicenseService) DeleteLicense(licenseID int64, options ...RequestOptionFunc) (*Response, error) { - u := fmt.Sprintf("license/%d", licenseID) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("license/%d", licenseID), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/license_templates.go b/vendor/gitlab.com/gitlab-org/api/client-go/license_templates.go index 8808f56..bdcb193 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/license_templates.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/license_templates.go @@ -16,11 +16,6 @@ package gitlab -import ( - "fmt" - "net/http" -) - // LicenseTemplate represents a license template. // // GitLab API docs: @@ -71,18 +66,11 @@ type ListLicenseTemplatesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/templates/licenses/#list-license-templates func (s *LicenseTemplatesService) ListLicenseTemplates(opt *ListLicenseTemplatesOptions, options ...RequestOptionFunc) ([]*LicenseTemplate, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "templates/licenses", opt, options) - if err != nil { - return nil, nil, err - } - - var lts []*LicenseTemplate - resp, err := s.client.Do(req, <s) - if err != nil { - return nil, resp, err - } - - return lts, resp, nil + return do[[]*LicenseTemplate](s.client, + withPath("templates/licenses"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetLicenseTemplateOptions represents the available @@ -101,18 +89,9 @@ type GetLicenseTemplateOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/templates/licenses/#single-license-template func (s *LicenseTemplatesService) GetLicenseTemplate(template string, opt *GetLicenseTemplateOptions, options ...RequestOptionFunc) (*LicenseTemplate, *Response, error) { - u := fmt.Sprintf("templates/licenses/%s", template) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - lt := new(LicenseTemplate) - resp, err := s.client.Do(req, lt) - if err != nil { - return nil, resp, err - } - - return lt, resp, nil + return do[*LicenseTemplate](s.client, + withPath("templates/licenses/%s", template), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/markdown.go b/vendor/gitlab.com/gitlab-org/api/client-go/markdown.go index af02391..cf92f1c 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/markdown.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/markdown.go @@ -40,16 +40,10 @@ type RenderOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/markdown/#render-an-arbitrary-markdown-document func (s *MarkdownService) Render(opt *RenderOptions, options ...RequestOptionFunc) (*Markdown, *Response, error) { - req, err := s.client.NewRequest(http.MethodPost, "markdown", opt, options) - if err != nil { - return nil, nil, err - } - - md := new(Markdown) - response, err := s.client.Do(req, md) - if err != nil { - return nil, response, err - } - - return md, response, nil + return do[*Markdown](s.client, + withMethod(http.MethodPost), + withPath("markdown"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/merge_request_approvals.go b/vendor/gitlab.com/gitlab-org/api/client-go/merge_request_approvals.go index 12263ac..2cdc06c 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/merge_request_approvals.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/merge_request_approvals.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -161,24 +160,12 @@ type ApproveMergeRequestOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#approve-merge-request func (s *MergeRequestApprovalsService) ApproveMergeRequest(pid any, mr int64, opt *ApproveMergeRequestOptions, options ...RequestOptionFunc) (*MergeRequestApprovals, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/approve", PathEscape(project), mr) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - m := new(MergeRequestApprovals) - resp, err := s.client.Do(req, m) - if err != nil { - return nil, resp, err - } - - return m, resp, nil + return do[*MergeRequestApprovals](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/approve", ProjectID{pid}, mr), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UnapproveMergeRequest unapproves a previously approved merge request on GitLab. @@ -186,18 +173,12 @@ func (s *MergeRequestApprovalsService) ApproveMergeRequest(pid any, mr int64, op // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#unapprove-merge-request func (s *MergeRequestApprovalsService) UnapproveMergeRequest(pid any, mr int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/unapprove", PathEscape(project), mr) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/unapprove", ProjectID{pid}, mr), + withRequestOpts(options...), + ) + return resp, err } // ResetApprovalsOfMergeRequest clear all approvals of merge request on GitLab. @@ -206,18 +187,12 @@ func (s *MergeRequestApprovalsService) UnapproveMergeRequest(pid any, mr int64, // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#reset-approvals-of-a-merge-request func (s *MergeRequestApprovalsService) ResetApprovalsOfMergeRequest(pid any, mr int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/reset_approvals", PathEscape(project), mr) - - req, err := s.client.NewRequest(http.MethodPut, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/merge_requests/%d/reset_approvals", ProjectID{pid}, mr), + withRequestOpts(options...), + ) + return resp, err } // GetConfiguration shows information about single merge request approvals @@ -225,24 +200,10 @@ func (s *MergeRequestApprovalsService) ResetApprovalsOfMergeRequest(pid any, mr // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#single-merge-request-approval func (s *MergeRequestApprovalsService) GetConfiguration(pid any, mr int64, options ...RequestOptionFunc) (*MergeRequestApprovals, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/approvals", PathEscape(project), mr) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - m := new(MergeRequestApprovals) - resp, err := s.client.Do(req, m) - if err != nil { - return nil, resp, err - } - - return m, resp, nil + return do[*MergeRequestApprovals](s.client, + withPath("projects/%s/merge_requests/%d/approvals", ProjectID{pid}, mr), + withRequestOpts(options...), + ) } // ChangeMergeRequestApprovalConfigurationOptions represents the available @@ -257,74 +218,34 @@ type ChangeMergeRequestApprovalConfigurationOptions struct { // // Deprecated: in GitLab 16.0 func (s *MergeRequestApprovalsService) ChangeApprovalConfiguration(pid any, mergeRequest int64, opt *ChangeMergeRequestApprovalConfigurationOptions, options ...RequestOptionFunc) (*MergeRequest, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/approvals", PathEscape(project), mergeRequest) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - m := new(MergeRequest) - resp, err := s.client.Do(req, m) - if err != nil { - return nil, resp, err - } - - return m, resp, nil + return do[*MergeRequest](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/approvals", ProjectID{pid}, mergeRequest), + withAPIOpts(opt), + withRequestOpts(options...), + ) } -// GetApprovalRules requests information about a merge request’s approval rules +// GetApprovalRules requests information about a merge request's approval rules // // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#get-merge-request-approval-rules func (s *MergeRequestApprovalsService) GetApprovalRules(pid any, mergeRequest int64, options ...RequestOptionFunc) ([]*MergeRequestApprovalRule, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules", PathEscape(project), mergeRequest) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var par []*MergeRequestApprovalRule - resp, err := s.client.Do(req, &par) - if err != nil { - return nil, resp, err - } - - return par, resp, nil + return do[[]*MergeRequestApprovalRule](s.client, + withPath("projects/%s/merge_requests/%d/approval_rules", ProjectID{pid}, mergeRequest), + withRequestOpts(options...), + ) } -// GetApprovalState requests information about a merge request’s approval state +// GetApprovalState requests information about a merge request's approval state // // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#get-the-approval-state-of-merge-requests func (s *MergeRequestApprovalsService) GetApprovalState(pid any, mergeRequest int64, options ...RequestOptionFunc) (*MergeRequestApprovalState, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_state", PathEscape(project), mergeRequest) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var pas *MergeRequestApprovalState - resp, err := s.client.Do(req, &pas) - if err != nil { - return nil, resp, err - } - - return pas, resp, nil + return do[*MergeRequestApprovalState](s.client, + withPath("projects/%s/merge_requests/%d/approval_state", ProjectID{pid}, mergeRequest), + withRequestOpts(options...), + ) } // CreateMergeRequestApprovalRuleOptions represents the available CreateApprovalRule() @@ -345,24 +266,12 @@ type CreateMergeRequestApprovalRuleOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#create-merge-request-rule func (s *MergeRequestApprovalsService) CreateApprovalRule(pid any, mergeRequest int64, opt *CreateMergeRequestApprovalRuleOptions, options ...RequestOptionFunc) (*MergeRequestApprovalRule, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules", PathEscape(project), mergeRequest) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - par := new(MergeRequestApprovalRule) - resp, err := s.client.Do(req, &par) - if err != nil { - return nil, resp, err - } - - return par, resp, nil + return do[*MergeRequestApprovalRule](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/approval_rules", ProjectID{pid}, mergeRequest), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateMergeRequestApprovalRuleOptions represents the available UpdateApprovalRule() @@ -382,24 +291,12 @@ type UpdateMergeRequestApprovalRuleOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#update-merge-request-rule func (s *MergeRequestApprovalsService) UpdateApprovalRule(pid any, mergeRequest int64, approvalRule int64, opt *UpdateMergeRequestApprovalRuleOptions, options ...RequestOptionFunc) (*MergeRequestApprovalRule, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules/%d", PathEscape(project), mergeRequest, approvalRule) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - par := new(MergeRequestApprovalRule) - resp, err := s.client.Do(req, &par) - if err != nil { - return nil, resp, err - } - - return par, resp, nil + return do[*MergeRequestApprovalRule](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/merge_requests/%d/approval_rules/%d", ProjectID{pid}, mergeRequest, approvalRule), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteApprovalRule deletes a mr level approval rule. @@ -407,16 +304,10 @@ func (s *MergeRequestApprovalsService) UpdateApprovalRule(pid any, mergeRequest // GitLab API docs: // https://docs.gitlab.com/api/merge_request_approvals/#delete-merge-request-rule func (s *MergeRequestApprovalsService) DeleteApprovalRule(pid any, mergeRequest int64, approvalRule int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/approval_rules/%d", PathEscape(project), mergeRequest, approvalRule) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/merge_requests/%d/approval_rules/%d", ProjectID{pid}, mergeRequest, approvalRule), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/merge_requests.go b/vendor/gitlab.com/gitlab-org/api/client-go/merge_requests.go index 220d4da..1b498fe 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/merge_requests.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/merge_requests.go @@ -340,6 +340,7 @@ type ListProjectMergeRequestsOptions struct { Sort *string `url:"sort,omitempty" json:"sort,omitempty"` Milestone *string `url:"milestone,omitempty" json:"milestone,omitempty"` View *string `url:"view,omitempty" json:"view,omitempty"` + Environment *string `url:"environment,omitempty" json:"environment,omitempty"` Labels *LabelOptions `url:"labels,comma,omitempty" json:"labels,omitempty"` NotLabels *LabelOptions `url:"not[labels],comma,omitempty" json:"not[labels],omitempty"` WithLabelsDetails *bool `url:"with_labels_details,omitempty" json:"with_labels_details,omitempty"` @@ -348,6 +349,8 @@ type ListProjectMergeRequestsOptions struct { CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"` UpdatedAfter *time.Time `url:"updated_after,omitempty" json:"updated_after,omitempty"` UpdatedBefore *time.Time `url:"updated_before,omitempty" json:"updated_before,omitempty"` + DeployedBefore *time.Time `url:"deployed_before,omitempty" json:"deployed_before,omitempty"` + DeployedAfter *time.Time `url:"deployed_after,omitempty" json:"deployed_after,omitempty"` Scope *string `url:"scope,omitempty" json:"scope,omitempty"` AuthorID *int64 `url:"author_id,omitempty" json:"author_id,omitempty"` AuthorUsername *string `url:"author_username,omitempty" json:"author_username,omitempty"` diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/metadata.go b/vendor/gitlab.com/gitlab-org/api/client-go/metadata.go index 5c9f717..8a79cd3 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/metadata.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/metadata.go @@ -16,8 +16,6 @@ package gitlab -import "net/http" - type ( MetadataServiceInterface interface { GetMetadata(options ...RequestOptionFunc) (*Metadata, *Response, error) @@ -66,16 +64,8 @@ func (k MetadataKAS) String() string { // // GitLab API docs: https://docs.gitlab.com/api/metadata/ func (s *MetadataService) GetMetadata(options ...RequestOptionFunc) (*Metadata, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "metadata", nil, options) - if err != nil { - return nil, nil, err - } - - v := new(Metadata) - resp, err := s.client.Do(req, v) - if err != nil { - return nil, resp, err - } - - return v, resp, nil + return do[*Metadata](s.client, + withPath("metadata"), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/notes.go b/vendor/gitlab.com/gitlab-org/api/client-go/notes.go index 1dc0849..e4dc2f0 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/notes.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/notes.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -161,24 +160,11 @@ type ListIssueNotesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#list-project-issue-notes func (s *NotesService) ListIssueNotes(pid any, issue int64, opt *ListIssueNotesOptions, options ...RequestOptionFunc) ([]*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/notes", PathEscape(project), issue) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var n []*Note - resp, err := s.client.Do(req, &n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[[]*Note](s.client, + withPath("projects/%s/issues/%d/notes", ProjectID{pid}, issue), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetIssueNote returns a single note for a specific project issue. @@ -186,24 +172,10 @@ func (s *NotesService) ListIssueNotes(pid any, issue int64, opt *ListIssueNotesO // GitLab API docs: // https://docs.gitlab.com/api/notes/#get-single-issue-note func (s *NotesService) GetIssueNote(pid any, issue, note int64, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", PathEscape(project), issue, note) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withPath("projects/%s/issues/%d/notes/%d", ProjectID{pid}, issue, note), + withRequestOpts(options...), + ) } // CreateIssueNoteOptions represents the available CreateIssueNote() @@ -222,24 +194,12 @@ type CreateIssueNoteOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#create-new-issue-note func (s *NotesService) CreateIssueNote(pid any, issue int64, opt *CreateIssueNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/notes", PathEscape(project), issue) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/issues/%d/notes", ProjectID{pid}, issue), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateIssueNoteOptions represents the available UpdateIssueNote() @@ -256,24 +216,12 @@ type UpdateIssueNoteOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#modify-existing-issue-note func (s *NotesService) UpdateIssueNote(pid any, issue, note int64, opt *UpdateIssueNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", PathEscape(project), issue, note) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/issues/%d/notes/%d", ProjectID{pid}, issue, note), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteIssueNote deletes an existing note of an issue. @@ -281,18 +229,12 @@ func (s *NotesService) UpdateIssueNote(pid any, issue, note int64, opt *UpdateIs // GitLab API docs: // https://docs.gitlab.com/api/notes/#delete-an-issue-note func (s *NotesService) DeleteIssueNote(pid any, issue, note int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/issues/%d/notes/%d", PathEscape(project), issue, note) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/issues/%d/notes/%d", ProjectID{pid}, issue, note), + withRequestOpts(options...), + ) + return resp, err } // ListSnippetNotesOptions represents the available ListSnippetNotes() options. @@ -311,24 +253,11 @@ type ListSnippetNotesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#list-all-snippet-notes func (s *NotesService) ListSnippetNotes(pid any, snippet int64, opt *ListSnippetNotesOptions, options ...RequestOptionFunc) ([]*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/notes", PathEscape(project), snippet) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var n []*Note - resp, err := s.client.Do(req, &n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[[]*Note](s.client, + withPath("projects/%s/snippets/%d/notes", ProjectID{pid}, snippet), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetSnippetNote returns a single note for a given snippet. @@ -336,24 +265,10 @@ func (s *NotesService) ListSnippetNotes(pid any, snippet int64, opt *ListSnippet // GitLab API docs: // https://docs.gitlab.com/api/notes/#get-single-snippet-note func (s *NotesService) GetSnippetNote(pid any, snippet, note int64, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", PathEscape(project), snippet, note) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withPath("projects/%s/snippets/%d/notes/%d", ProjectID{pid}, snippet, note), + withRequestOpts(options...), + ) } // CreateSnippetNoteOptions represents the available CreateSnippetNote() @@ -372,24 +287,12 @@ type CreateSnippetNoteOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#create-new-snippet-note func (s *NotesService) CreateSnippetNote(pid any, snippet int64, opt *CreateSnippetNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/notes", PathEscape(project), snippet) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/snippets/%d/notes", ProjectID{pid}, snippet), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateSnippetNoteOptions represents the available UpdateSnippetNote() @@ -406,24 +309,12 @@ type UpdateSnippetNoteOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#modify-existing-snippet-note func (s *NotesService) UpdateSnippetNote(pid any, snippet, note int64, opt *UpdateSnippetNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", PathEscape(project), snippet, note) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/snippets/%d/notes/%d", ProjectID{pid}, snippet, note), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteSnippetNote deletes an existing note of a snippet. @@ -431,18 +322,12 @@ func (s *NotesService) UpdateSnippetNote(pid any, snippet, note int64, opt *Upda // GitLab API docs: // https://docs.gitlab.com/api/notes/#delete-a-snippet-note func (s *NotesService) DeleteSnippetNote(pid any, snippet, note int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/snippets/%d/notes/%d", PathEscape(project), snippet, note) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/snippets/%d/notes/%d", ProjectID{pid}, snippet, note), + withRequestOpts(options...), + ) + return resp, err } // ListMergeRequestNotesOptions represents the available ListMergeRequestNotes() @@ -461,24 +346,11 @@ type ListMergeRequestNotesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#list-all-merge-request-notes func (s *NotesService) ListMergeRequestNotes(pid any, mergeRequest int64, opt *ListMergeRequestNotesOptions, options ...RequestOptionFunc) ([]*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/notes", PathEscape(project), mergeRequest) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var n []*Note - resp, err := s.client.Do(req, &n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[[]*Note](s.client, + withPath("projects/%s/merge_requests/%d/notes", ProjectID{pid}, mergeRequest), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetMergeRequestNote returns a single note for a given merge request. @@ -486,24 +358,10 @@ func (s *NotesService) ListMergeRequestNotes(pid any, mergeRequest int64, opt *L // GitLab API docs: // https://docs.gitlab.com/api/notes/#get-single-merge-request-note func (s *NotesService) GetMergeRequestNote(pid any, mergeRequest, note int64, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/notes/%d", PathEscape(project), mergeRequest, note) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withPath("projects/%s/merge_requests/%d/notes/%d", ProjectID{pid}, mergeRequest, note), + withRequestOpts(options...), + ) } // CreateMergeRequestNoteOptions represents the available @@ -523,24 +381,12 @@ type CreateMergeRequestNoteOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#create-new-merge-request-note func (s *NotesService) CreateMergeRequestNote(pid any, mergeRequest int64, opt *CreateMergeRequestNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/merge_requests/%d/notes", PathEscape(project), mergeRequest) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/merge_requests/%d/notes", ProjectID{pid}, mergeRequest), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateMergeRequestNoteOptions represents the available @@ -557,24 +403,12 @@ type UpdateMergeRequestNoteOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#modify-existing-merge-request-note func (s *NotesService) UpdateMergeRequestNote(pid any, mergeRequest, note int64, opt *UpdateMergeRequestNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf( - "projects/%s/merge_requests/%d/notes/%d", PathEscape(project), mergeRequest, note) - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/merge_requests/%d/notes/%d", ProjectID{pid}, mergeRequest, note), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteMergeRequestNote deletes an existing note of a merge request. @@ -582,19 +416,12 @@ func (s *NotesService) UpdateMergeRequestNote(pid any, mergeRequest, note int64, // GitLab API docs: // https://docs.gitlab.com/api/notes/#delete-a-merge-request-note func (s *NotesService) DeleteMergeRequestNote(pid any, mergeRequest, note int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf( - "projects/%s/merge_requests/%d/notes/%d", PathEscape(project), mergeRequest, note) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/merge_requests/%d/notes/%d", ProjectID{pid}, mergeRequest, note), + withRequestOpts(options...), + ) + return resp, err } // ListEpicNotesOptions represents the available ListEpicNotes() options. @@ -614,24 +441,11 @@ type ListEpicNotesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#list-all-epic-notes func (s *NotesService) ListEpicNotes(gid any, epic int64, opt *ListEpicNotesOptions, options ...RequestOptionFunc) ([]*Note, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/notes", PathEscape(group), epic) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var n []*Note - resp, err := s.client.Do(req, &n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[[]*Note](s.client, + withPath("groups/%s/epics/%d/notes", GroupID{gid}, epic), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetEpicNote returns a single note for an epic. @@ -640,24 +454,10 @@ func (s *NotesService) ListEpicNotes(gid any, epic int64, opt *ListEpicNotesOpti // GitLab API docs: // https://docs.gitlab.com/api/notes/#get-single-epic-note func (s *NotesService) GetEpicNote(gid any, epic, note int64, options ...RequestOptionFunc) (*Note, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", PathEscape(group), epic, note) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withPath("groups/%s/epics/%d/notes/%d", GroupID{gid}, epic, note), + withRequestOpts(options...), + ) } // CreateEpicNoteOptions represents the available CreateEpicNote() options. @@ -675,24 +475,12 @@ type CreateEpicNoteOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/notes/#create-new-epic-note func (s *NotesService) CreateEpicNote(gid any, epic int64, opt *CreateEpicNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/notes", PathEscape(group), epic) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withMethod(http.MethodPost), + withPath("groups/%s/epics/%d/notes", GroupID{gid}, epic), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateEpicNoteOptions represents the available UpdateEpicNote() options. @@ -709,24 +497,12 @@ type UpdateEpicNoteOptions struct { // // https://docs.gitlab.com/api/notes/#modify-existing-epic-note func (s *NotesService) UpdateEpicNote(gid any, epic, note int64, opt *UpdateEpicNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", PathEscape(group), epic, note) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - n := new(Note) - resp, err := s.client.Do(req, n) - if err != nil { - return nil, resp, err - } - - return n, resp, nil + return do[*Note](s.client, + withMethod(http.MethodPut), + withPath("groups/%s/epics/%d/notes/%d", GroupID{gid}, epic, note), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteEpicNote deletes an existing note of a merge request. @@ -734,16 +510,10 @@ func (s *NotesService) UpdateEpicNote(gid any, epic, note int64, opt *UpdateEpic // // https://docs.gitlab.com/api/notes/#delete-an-epic-note func (s *NotesService) DeleteEpicNote(gid any, epic, note int64, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("groups/%s/epics/%d/notes/%d", PathEscape(group), epic, note) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("groups/%s/epics/%d/notes/%d", GroupID{gid}, epic, note), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/notifications.go b/vendor/gitlab.com/gitlab-org/api/client-go/notifications.go index fab7089..3a89d3a 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/notifications.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/notifications.go @@ -18,7 +18,6 @@ package gitlab import ( "errors" - "fmt" "net/http" ) @@ -87,20 +86,10 @@ func (ns NotificationSettings) String() string { // GitLab API docs: // https://docs.gitlab.com/api/notification_settings/#global-notification-settings func (s *NotificationSettingsService) GetGlobalSettings(options ...RequestOptionFunc) (*NotificationSettings, *Response, error) { - u := "notification_settings" - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - ns := new(NotificationSettings) - resp, err := s.client.Do(req, ns) - if err != nil { - return nil, resp, err - } - - return ns, resp, nil + return do[*NotificationSettings](s.client, + withPath("notification_settings"), + withRequestOpts(options...), + ) } // NotificationSettingsOptions represents the available options that can be passed @@ -138,20 +127,12 @@ func (s *NotificationSettingsService) UpdateGlobalSettings(opt *NotificationSett "notification level 'global' is not valid for global notification settings") } - u := "notification_settings" - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - ns := new(NotificationSettings) - resp, err := s.client.Do(req, ns) - if err != nil { - return nil, resp, err - } - - return ns, resp, nil + return do[*NotificationSettings](s.client, + withMethod(http.MethodPut), + withPath("notification_settings"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetSettingsForGroup returns current group notification settings. @@ -159,24 +140,10 @@ func (s *NotificationSettingsService) UpdateGlobalSettings(opt *NotificationSett // GitLab API docs: // https://docs.gitlab.com/api/notification_settings/#group--project-level-notification-settings func (s *NotificationSettingsService) GetSettingsForGroup(gid any, options ...RequestOptionFunc) (*NotificationSettings, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/notification_settings", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - ns := new(NotificationSettings) - resp, err := s.client.Do(req, ns) - if err != nil { - return nil, resp, err - } - - return ns, resp, nil + return do[*NotificationSettings](s.client, + withPath("groups/%s/notification_settings", GroupID{gid}), + withRequestOpts(options...), + ) } // GetSettingsForProject returns current project notification settings. @@ -184,24 +151,10 @@ func (s *NotificationSettingsService) GetSettingsForGroup(gid any, options ...Re // GitLab API docs: // https://docs.gitlab.com/api/notification_settings/#group--project-level-notification-settings func (s *NotificationSettingsService) GetSettingsForProject(pid any, options ...RequestOptionFunc) (*NotificationSettings, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/notification_settings", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - ns := new(NotificationSettings) - resp, err := s.client.Do(req, ns) - if err != nil { - return nil, resp, err - } - - return ns, resp, nil + return do[*NotificationSettings](s.client, + withPath("projects/%s/notification_settings", ProjectID{pid}), + withRequestOpts(options...), + ) } // UpdateSettingsForGroup updates current group notification settings. @@ -209,24 +162,12 @@ func (s *NotificationSettingsService) GetSettingsForProject(pid any, options ... // GitLab API docs: // https://docs.gitlab.com/api/notification_settings/#update-groupproject-level-notification-settings func (s *NotificationSettingsService) UpdateSettingsForGroup(gid any, opt *NotificationSettingsOptions, options ...RequestOptionFunc) (*NotificationSettings, *Response, error) { - group, err := parseID(gid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("groups/%s/notification_settings", PathEscape(group)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - ns := new(NotificationSettings) - resp, err := s.client.Do(req, ns) - if err != nil { - return nil, resp, err - } - - return ns, resp, nil + return do[*NotificationSettings](s.client, + withMethod(http.MethodPut), + withPath("groups/%s/notification_settings", GroupID{gid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateSettingsForProject updates current project notification settings. @@ -234,22 +175,10 @@ func (s *NotificationSettingsService) UpdateSettingsForGroup(gid any, opt *Notif // GitLab API docs: // https://docs.gitlab.com/api/notification_settings/#update-groupproject-level-notification-settings func (s *NotificationSettingsService) UpdateSettingsForProject(pid any, opt *NotificationSettingsOptions, options ...RequestOptionFunc) (*NotificationSettings, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/notification_settings", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - ns := new(NotificationSettings) - resp, err := s.client.Do(req, ns) - if err != nil { - return nil, resp, err - } - - return ns, resp, nil + return do[*NotificationSettings](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/notification_settings", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/pagination.go b/vendor/gitlab.com/gitlab-org/api/client-go/pagination.go index 1549f15..51c9393 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/pagination.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/pagination.go @@ -1,5 +1,3 @@ -//go:build go1.23 - package gitlab import ( diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/pipeline_schedules.go b/vendor/gitlab.com/gitlab-org/api/client-go/pipeline_schedules.go index a6541d4..6b100e2 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/pipeline_schedules.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/pipeline_schedules.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -92,24 +91,11 @@ type ListPipelineSchedulesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#get-all-pipeline-schedules func (s *PipelineSchedulesService) ListPipelineSchedules(pid any, opt *ListPipelineSchedulesOptions, options ...RequestOptionFunc) ([]*PipelineSchedule, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var ps []*PipelineSchedule - resp, err := s.client.Do(req, &ps) - if err != nil { - return nil, resp, err - } - - return ps, resp, nil + return do[[]*PipelineSchedule](s.client, + withPath("projects/%s/pipeline_schedules", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetPipelineSchedule gets a pipeline schedule. @@ -117,24 +103,10 @@ func (s *PipelineSchedulesService) ListPipelineSchedules(pid any, opt *ListPipel // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#get-a-single-pipeline-schedule func (s *PipelineSchedulesService) GetPipelineSchedule(pid any, schedule int64, options ...RequestOptionFunc) (*PipelineSchedule, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", PathEscape(project), schedule) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineSchedule) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineSchedule](s.client, + withPath("projects/%s/pipeline_schedules/%d", ProjectID{pid}, schedule), + withRequestOpts(options...), + ) } // ListPipelinesTriggeredByScheduleOptions represents the available @@ -152,24 +124,11 @@ type ListPipelinesTriggeredByScheduleOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#get-all-pipelines-triggered-by-a-pipeline-schedule func (s *PipelineSchedulesService) ListPipelinesTriggeredBySchedule(pid any, schedule int64, opt *ListPipelinesTriggeredByScheduleOptions, options ...RequestOptionFunc) ([]*Pipeline, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/pipelines", PathEscape(project), schedule) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var p []*Pipeline - resp, err := s.client.Do(req, &p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[[]*Pipeline](s.client, + withPath("projects/%s/pipeline_schedules/%d/pipelines", ProjectID{pid}, schedule), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // CreatePipelineScheduleOptions represents the available @@ -191,24 +150,12 @@ type CreatePipelineScheduleOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#create-a-new-pipeline-schedule func (s *PipelineSchedulesService) CreatePipelineSchedule(pid any, opt *CreatePipelineScheduleOptions, options ...RequestOptionFunc) (*PipelineSchedule, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineSchedule) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineSchedule](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/pipeline_schedules", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // EditPipelineScheduleOptions represents the available @@ -230,24 +177,12 @@ type EditPipelineScheduleOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#edit-a-pipeline-schedule func (s *PipelineSchedulesService) EditPipelineSchedule(pid any, schedule int64, opt *EditPipelineScheduleOptions, options ...RequestOptionFunc) (*PipelineSchedule, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", PathEscape(project), schedule) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineSchedule) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineSchedule](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/pipeline_schedules/%d", ProjectID{pid}, schedule), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // TakeOwnershipOfPipelineSchedule sets the owner of the specified @@ -256,24 +191,11 @@ func (s *PipelineSchedulesService) EditPipelineSchedule(pid any, schedule int64, // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#take-ownership-of-a-pipeline-schedule func (s *PipelineSchedulesService) TakeOwnershipOfPipelineSchedule(pid any, schedule int64, options ...RequestOptionFunc) (*PipelineSchedule, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/take_ownership", PathEscape(project), schedule) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineSchedule) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineSchedule](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/pipeline_schedules/%d/take_ownership", ProjectID{pid}, schedule), + withRequestOpts(options...), + ) } // DeletePipelineSchedule deletes a pipeline schedule. @@ -281,18 +203,12 @@ func (s *PipelineSchedulesService) TakeOwnershipOfPipelineSchedule(pid any, sche // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#delete-a-pipeline-schedule func (s *PipelineSchedulesService) DeletePipelineSchedule(pid any, schedule int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d", PathEscape(project), schedule) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/pipeline_schedules/%d", ProjectID{pid}, schedule), + withRequestOpts(options...), + ) + return resp, err } // RunPipelineSchedule triggers a new scheduled pipeline to run immediately. @@ -300,18 +216,12 @@ func (s *PipelineSchedulesService) DeletePipelineSchedule(pid any, schedule int6 // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#run-a-scheduled-pipeline-immediately func (s *PipelineSchedulesService) RunPipelineSchedule(pid any, schedule int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/play", PathEscape(project), schedule) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/pipeline_schedules/%d/play", ProjectID{pid}, schedule), + withRequestOpts(options...), + ) + return resp, err } // CreatePipelineScheduleVariableOptions represents the available @@ -330,24 +240,12 @@ type CreatePipelineScheduleVariableOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#create-a-new-pipeline-schedule func (s *PipelineSchedulesService) CreatePipelineScheduleVariable(pid any, schedule int64, opt *CreatePipelineScheduleVariableOptions, options ...RequestOptionFunc) (*PipelineVariable, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables", PathEscape(project), schedule) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineVariable) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineVariable](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/pipeline_schedules/%d/variables", ProjectID{pid}, schedule), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // EditPipelineScheduleVariableOptions represents the available @@ -365,24 +263,12 @@ type EditPipelineScheduleVariableOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#edit-a-pipeline-schedule-variable func (s *PipelineSchedulesService) EditPipelineScheduleVariable(pid any, schedule int64, key string, opt *EditPipelineScheduleVariableOptions, options ...RequestOptionFunc) (*PipelineVariable, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables/%s", PathEscape(project), schedule, key) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineVariable) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineVariable](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/pipeline_schedules/%d/variables/%s", ProjectID{pid}, schedule, key), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeletePipelineScheduleVariable creates a pipeline schedule variable. @@ -390,22 +276,9 @@ func (s *PipelineSchedulesService) EditPipelineScheduleVariable(pid any, schedul // GitLab API docs: // https://docs.gitlab.com/api/pipeline_schedules/#delete-a-pipeline-schedule-variable func (s *PipelineSchedulesService) DeletePipelineScheduleVariable(pid any, schedule int64, key string, options ...RequestOptionFunc) (*PipelineVariable, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline_schedules/%d/variables/%s", PathEscape(project), schedule, key) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineVariable) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineVariable](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/pipeline_schedules/%d/variables/%s", ProjectID{pid}, schedule, key), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/pipelines.go b/vendor/gitlab.com/gitlab-org/api/client-go/pipelines.go index 6d076e4..83850f8 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/pipelines.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/pipelines.go @@ -18,7 +18,6 @@ package gitlab import ( "encoding/json" - "fmt" "net/http" "time" ) @@ -271,24 +270,11 @@ type ListProjectPipelinesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#list-project-pipelines func (s *PipelinesService) ListProjectPipelines(pid any, opt *ListProjectPipelinesOptions, options ...RequestOptionFunc) ([]*PipelineInfo, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var p []*PipelineInfo - resp, err := s.client.Do(req, &p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[[]*PipelineInfo](s.client, + withPath("projects/%s/pipelines", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetPipeline gets a single project pipeline. @@ -296,24 +282,10 @@ func (s *PipelinesService) ListProjectPipelines(pid any, opt *ListProjectPipelin // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#get-a-single-pipeline func (s *PipelinesService) GetPipeline(pid any, pipeline int64, options ...RequestOptionFunc) (*Pipeline, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/%d", PathEscape(project), pipeline) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(Pipeline) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*Pipeline](s.client, + withPath("projects/%s/pipelines/%d", ProjectID{pid}, pipeline), + withRequestOpts(options...), + ) } // GetPipelineVariables gets the variables of a single project pipeline. @@ -321,24 +293,10 @@ func (s *PipelinesService) GetPipeline(pid any, pipeline int64, options ...Reque // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#get-variables-of-a-pipeline func (s *PipelinesService) GetPipelineVariables(pid any, pipeline int64, options ...RequestOptionFunc) ([]*PipelineVariable, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/%d/variables", PathEscape(project), pipeline) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var p []*PipelineVariable - resp, err := s.client.Do(req, &p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[[]*PipelineVariable](s.client, + withPath("projects/%s/pipelines/%d/variables", ProjectID{pid}, pipeline), + withRequestOpts(options...), + ) } // GetPipelineTestReport gets the test report of a single project pipeline. @@ -346,24 +304,10 @@ func (s *PipelinesService) GetPipelineVariables(pid any, pipeline int64, options // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#get-a-pipelines-test-report func (s *PipelinesService) GetPipelineTestReport(pid any, pipeline int64, options ...RequestOptionFunc) (*PipelineTestReport, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/%d/test_report", PathEscape(project), pipeline) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineTestReport) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineTestReport](s.client, + withPath("projects/%s/pipelines/%d/test_report", ProjectID{pid}, pipeline), + withRequestOpts(options...), + ) } // GetPipelineTestReportSummary gets the test report summary of a single project pipeline. @@ -371,24 +315,10 @@ func (s *PipelinesService) GetPipelineTestReport(pid any, pipeline int64, option // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#get-a-test-report-summary-for-a-pipeline func (s *PipelinesService) GetPipelineTestReportSummary(pid any, pipeline int64, options ...RequestOptionFunc) (*PipelineTestReportSummary, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/%d/test_report_summary", PathEscape(project), pipeline) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(PipelineTestReportSummary) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*PipelineTestReportSummary](s.client, + withPath("projects/%s/pipelines/%d/test_report_summary", ProjectID{pid}, pipeline), + withRequestOpts(options...), + ) } // GetLatestPipelineOptions represents the available GetLatestPipeline() options. @@ -404,24 +334,11 @@ type GetLatestPipelineOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#get-the-latest-pipeline func (s *PipelinesService) GetLatestPipeline(pid any, opt *GetLatestPipelineOptions, options ...RequestOptionFunc) (*Pipeline, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/latest", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(Pipeline) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*Pipeline](s.client, + withPath("projects/%s/pipelines/latest", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // CreatePipelineOptions represents the available CreatePipeline() options. @@ -528,24 +445,12 @@ func NewPipelineInputValue[T PipelineInputValueType](value T) PipelineInputValue // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#create-a-new-pipeline func (s *PipelinesService) CreatePipeline(pid any, opt *CreatePipelineOptions, options ...RequestOptionFunc) (*Pipeline, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipeline", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(Pipeline) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*Pipeline](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/pipeline", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // RetryPipelineBuild retries failed builds in a pipeline. @@ -553,24 +458,11 @@ func (s *PipelinesService) CreatePipeline(pid any, opt *CreatePipelineOptions, o // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#retry-jobs-in-a-pipeline func (s *PipelinesService) RetryPipelineBuild(pid any, pipeline int64, options ...RequestOptionFunc) (*Pipeline, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/%d/retry", PathEscape(project), pipeline) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(Pipeline) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*Pipeline](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/pipelines/%d/retry", ProjectID{pid}, pipeline), + withRequestOpts(options...), + ) } // CancelPipelineBuild cancels a pipeline builds. @@ -578,24 +470,11 @@ func (s *PipelinesService) RetryPipelineBuild(pid any, pipeline int64, options . // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#cancel-a-pipelines-jobs func (s *PipelinesService) CancelPipelineBuild(pid any, pipeline int64, options ...RequestOptionFunc) (*Pipeline, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/%d/cancel", PathEscape(project), pipeline) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(Pipeline) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*Pipeline](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/pipelines/%d/cancel", ProjectID{pid}, pipeline), + withRequestOpts(options...), + ) } // DeletePipeline deletes an existing pipeline. @@ -603,18 +482,12 @@ func (s *PipelinesService) CancelPipelineBuild(pid any, pipeline int64, options // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#delete-a-pipeline func (s *PipelinesService) DeletePipeline(pid any, pipeline int64, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/%d", PathEscape(project), pipeline) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/pipelines/%d", ProjectID{pid}, pipeline), + withRequestOpts(options...), + ) + return resp, err } // UpdatePipelineMetadataOptions represents the available UpdatePipelineMetadata() @@ -632,22 +505,10 @@ type UpdatePipelineMetadataOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/pipelines/#update-pipeline-metadata func (s *PipelinesService) UpdatePipelineMetadata(pid any, pipeline int64, opt *UpdatePipelineMetadataOptions, options ...RequestOptionFunc) (*Pipeline, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/pipelines/%d/metadata", PathEscape(project), pipeline) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(Pipeline) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*Pipeline](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/pipelines/%d/metadata", ProjectID{pid}, pipeline), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/plan_limits.go b/vendor/gitlab.com/gitlab-org/api/client-go/plan_limits.go index 018eff5..d7247fa 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/plan_limits.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/plan_limits.go @@ -63,18 +63,11 @@ type GetCurrentPlanLimitsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/plan_limits/#get-current-plan-limits func (s *PlanLimitsService) GetCurrentPlanLimits(opt *GetCurrentPlanLimitsOptions, options ...RequestOptionFunc) (*PlanLimit, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "application/plan_limits", opt, options) - if err != nil { - return nil, nil, err - } - - pl := new(PlanLimit) - resp, err := s.client.Do(req, pl) - if err != nil { - return nil, resp, err - } - - return pl, resp, nil + return do[*PlanLimit](s.client, + withPath("application/plan_limits"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // ChangePlanLimitOptions represents the available ChangePlanLimits() options. @@ -98,16 +91,10 @@ type ChangePlanLimitOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/plan_limits/#change-plan-limits func (s *PlanLimitsService) ChangePlanLimits(opt *ChangePlanLimitOptions, options ...RequestOptionFunc) (*PlanLimit, *Response, error) { - req, err := s.client.NewRequest(http.MethodPut, "application/plan_limits", opt, options) - if err != nil { - return nil, nil, err - } - - pl := new(PlanLimit) - resp, err := s.client.Do(req, pl) - if err != nil { - return nil, resp, err - } - - return pl, resp, nil + return do[*PlanLimit](s.client, + withMethod(http.MethodPut), + withPath("application/plan_limits"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/project_templates.go b/vendor/gitlab.com/gitlab-org/api/client-go/project_templates.go index ffafb25..2da051d 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/project_templates.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/project_templates.go @@ -16,11 +16,6 @@ package gitlab -import ( - "fmt" - "net/http" -) - type ( ProjectTemplatesServiceInterface interface { ListTemplates(pid any, templateType string, opt *ListProjectTemplatesOptions, options ...RequestOptionFunc) ([]*ProjectTemplate, *Response, error) @@ -73,24 +68,11 @@ type ListProjectTemplatesOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/project_templates/#get-all-templates-of-a-particular-type func (s *ProjectTemplatesService) ListTemplates(pid any, templateType string, opt *ListProjectTemplatesOptions, options ...RequestOptionFunc) ([]*ProjectTemplate, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/templates/%s", PathEscape(project), templateType) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var pt []*ProjectTemplate - resp, err := s.client.Do(req, &pt) - if err != nil { - return nil, resp, err - } - - return pt, resp, nil + return do[[]*ProjectTemplate](s.client, + withPath("projects/%s/templates/%s", ProjectID{pid}, templateType), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetProjectTemplate gets a single project template. @@ -98,22 +80,8 @@ func (s *ProjectTemplatesService) ListTemplates(pid any, templateType string, op // GitLab API docs: // https://docs.gitlab.com/api/project_templates/#get-one-template-of-a-particular-type func (s *ProjectTemplatesService) GetProjectTemplate(pid any, templateType string, templateName string, options ...RequestOptionFunc) (*ProjectTemplate, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/templates/%s/%s", PathEscape(project), templateType, templateName) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - ptd := new(ProjectTemplate) - resp, err := s.client.Do(req, ptd) - if err != nil { - return nil, resp, err - } - - return ptd, resp, nil + return do[*ProjectTemplate](s.client, + withPath("projects/%s/templates/%s/%s", ProjectID{pid}, templateType, templateName), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/projects.go b/vendor/gitlab.com/gitlab-org/api/client-go/projects.go index 2dfbfbe..d414a91 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/projects.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/projects.go @@ -150,6 +150,7 @@ type Project struct { PreventMergeWithoutJiraIssue bool `json:"prevent_merge_without_jira_issue"` PrintingMergeRequestLinkEnabled bool `json:"printing_merge_request_link_enabled"` LFSEnabled bool `json:"lfs_enabled"` + MaxArtifactsSize int64 `json:"max_artifacts_size"` RepositoryStorage string `json:"repository_storage"` RequestAccessEnabled bool `json:"request_access_enabled"` MergeMethod MergeMethodValue `json:"merge_method"` @@ -262,10 +263,11 @@ type Project struct { // // GitLab API docs: https://docs.gitlab.com/api/projects/ type ProjectSharedWithGroup struct { - GroupID int64 `json:"group_id"` - GroupName string `json:"group_name"` - GroupFullPath string `json:"group_full_path"` - GroupAccessLevel int64 `json:"group_access_level"` + GroupID int64 `json:"group_id"` + GroupName string `json:"group_name"` + GroupFullPath string `json:"group_full_path"` + GroupAccessLevel int64 `json:"group_access_level"` + ExpiresAt *ISOTime `json:"expires_at"` } // BasicProject included in other service responses (such as todos). @@ -971,6 +973,7 @@ type EditProjectOptions struct { IssuesTemplate *string `url:"issues_template,omitempty" json:"issues_template,omitempty"` KeepLatestArtifact *bool `url:"keep_latest_artifact,omitempty" json:"keep_latest_artifact,omitempty"` LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"` + MaxArtifactsSize *int64 `url:"max_artifacts_size,omitempty" json:"max_artifacts_size,omitempty"` MergeCommitTemplate *string `url:"merge_commit_template,omitempty" json:"merge_commit_template,omitempty"` MergeRequestDefaultTargetSelf *bool `url:"mr_default_target_self,omitempty" json:"mr_default_target_self,omitempty"` MergeMethod *MergeMethodValue `url:"merge_method,omitempty" json:"merge_method,omitempty"` @@ -1414,6 +1417,7 @@ type ProjectHook struct { ReleasesEvents bool `json:"releases_events"` MilestoneEvents bool `json:"milestone_events"` FeatureFlagEvents bool `json:"feature_flag_events"` + EmojiEvents bool `json:"emoji_events"` EnableSSLVerification bool `json:"enable_ssl_verification"` RepositoryUpdateEvents bool `json:"repository_update_events"` AlertStatus string `json:"alert_status"` @@ -1423,6 +1427,8 @@ type ProjectHook struct { ResourceAccessTokenEvents bool `json:"resource_access_token_events"` CustomWebhookTemplate string `json:"custom_webhook_template"` CustomHeaders []*HookCustomHeader `json:"custom_headers"` + VulnerabilityEvents bool `json:"vulnerability_events"` + BranchFilterStrategy string `json:"branch_filter_strategy"` } // ListProjectHooksOptions represents the available ListProjectHooks() options. @@ -1502,6 +1508,7 @@ type AddProjectHookOptions struct { PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` PushEventsBranchFilter *string `url:"push_events_branch_filter,omitempty" json:"push_events_branch_filter,omitempty"` ReleasesEvents *bool `url:"releases_events,omitempty" json:"releases_events,omitempty"` + EmojiEvents *bool `url:"emoji_events,omitempty" json:"emoji_events,omitempty"` TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` Token *string `url:"token,omitempty" json:"token,omitempty"` URL *string `url:"url,omitempty" json:"url,omitempty"` @@ -1509,6 +1516,8 @@ type AddProjectHookOptions struct { ResourceAccessTokenEvents *bool `url:"resource_access_token_events,omitempty" json:"resource_access_token_events,omitempty"` CustomWebhookTemplate *string `url:"custom_webhook_template,omitempty" json:"custom_webhook_template,omitempty"` CustomHeaders *[]*HookCustomHeader `url:"custom_headers,omitempty" json:"custom_headers,omitempty"` + VulnerabilityEvents *bool `url:"vulnerability_events,omitempty" json:"vulnerability_events,omitempty"` + BranchFilterStrategy *string `url:"branch_filter_strategy,omitempty" json:"branch_filter_strategy,omitempty"` } // AddProjectHook adds a hook to a specified project. @@ -1555,6 +1564,7 @@ type EditProjectHookOptions struct { PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` PushEventsBranchFilter *string `url:"push_events_branch_filter,omitempty" json:"push_events_branch_filter,omitempty"` ReleasesEvents *bool `url:"releases_events,omitempty" json:"releases_events,omitempty"` + EmojiEvents *bool `url:"emoji_events,omitempty" json:"emoji_events,omitempty"` TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` Token *string `url:"token,omitempty" json:"token,omitempty"` URL *string `url:"url,omitempty" json:"url,omitempty"` @@ -1562,6 +1572,8 @@ type EditProjectHookOptions struct { ResourceAccessTokenEvents *bool `url:"resource_access_token_events,omitempty" json:"resource_access_token_events,omitempty"` CustomWebhookTemplate *string `url:"custom_webhook_template,omitempty" json:"custom_webhook_template,omitempty"` CustomHeaders *[]*HookCustomHeader `url:"custom_headers,omitempty" json:"custom_headers,omitempty"` + VulnerabilityEvents *bool `url:"vulnerability_events,omitempty" json:"vulnerability_events,omitempty"` + BranchFilterStrategy *string `url:"branch_filter_strategy,omitempty" json:"branch_filter_strategy,omitempty"` } // EditProjectHook edits a hook for a specified project. diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/protected_branches.go b/vendor/gitlab.com/gitlab-org/api/client-go/protected_branches.go index bae532c..0fd162f 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/protected_branches.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/protected_branches.go @@ -16,11 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" - "net/url" -) +import "net/http" type ( ProtectedBranchesServiceInterface interface { @@ -86,24 +82,11 @@ type ListProtectedBranchesOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/protected_branches/#list-protected-branches func (s *ProtectedBranchesService) ListProtectedBranches(pid any, opt *ListProtectedBranchesOptions, options ...RequestOptionFunc) ([]*ProtectedBranch, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/protected_branches", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var p []*ProtectedBranch - resp, err := s.client.Do(req, &p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[[]*ProtectedBranch](s.client, + withPath("projects/%s/protected_branches", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetProtectedBranch gets a single protected branch or wildcard protected branch. @@ -111,24 +94,10 @@ func (s *ProtectedBranchesService) ListProtectedBranches(pid any, opt *ListProte // GitLab API docs: // https://docs.gitlab.com/api/protected_branches/#get-a-single-protected-branch-or-wildcard-protected-branch func (s *ProtectedBranchesService) GetProtectedBranch(pid any, branch string, options ...RequestOptionFunc) (*ProtectedBranch, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/protected_branches/%s", PathEscape(project), url.PathEscape(branch)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - p := new(ProtectedBranch) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*ProtectedBranch](s.client, + withPath("projects/%s/protected_branches/%s", ProjectID{pid}, branch), + withRequestOpts(options...), + ) } // ProtectRepositoryBranchesOptions represents the available @@ -167,24 +136,12 @@ type BranchPermissionOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/protected_branches/#protect-repository-branches func (s *ProtectedBranchesService) ProtectRepositoryBranches(pid any, opt *ProtectRepositoryBranchesOptions, options ...RequestOptionFunc) (*ProtectedBranch, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/protected_branches", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(ProtectedBranch) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*ProtectedBranch](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/protected_branches", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UnprotectRepositoryBranches unprotects the given protected branch or wildcard @@ -193,18 +150,12 @@ func (s *ProtectedBranchesService) ProtectRepositoryBranches(pid any, opt *Prote // GitLab API docs: // https://docs.gitlab.com/api/protected_branches/#unprotect-repository-branches func (s *ProtectedBranchesService) UnprotectRepositoryBranches(pid any, branch string, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/protected_branches/%s", PathEscape(project), url.PathEscape(branch)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/protected_branches/%s", ProjectID{pid}, branch), + withRequestOpts(options...), + ) + return resp, err } // UpdateProtectedBranchOptions represents the available @@ -226,22 +177,10 @@ type UpdateProtectedBranchOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/protected_branches/#update-a-protected-branch func (s *ProtectedBranchesService) UpdateProtectedBranch(pid any, branch string, opt *UpdateProtectedBranchOptions, options ...RequestOptionFunc) (*ProtectedBranch, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/protected_branches/%s", PathEscape(project), url.PathEscape(branch)) - - req, err := s.client.NewRequest(http.MethodPatch, u, opt, options) - if err != nil { - return nil, nil, err - } - - p := new(ProtectedBranch) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*ProtectedBranch](s.client, + withMethod(http.MethodPatch), + withPath("projects/%s/protected_branches/%s", ProjectID{pid}, branch), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/releaselinks.go b/vendor/gitlab.com/gitlab-org/api/client-go/releaselinks.go index 00fb33d..dce9cd3 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/releaselinks.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/releaselinks.go @@ -16,10 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" -) +import "net/http" type ( ReleaseLinksServiceInterface interface { @@ -64,51 +61,21 @@ type ListReleaseLinksOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/releases/links/#list-links-of-a-release func (s *ReleaseLinksService) ListReleaseLinks(pid any, tagName string, opt *ListReleaseLinksOptions, options ...RequestOptionFunc) ([]*ReleaseLink, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/releases/%s/assets/links", PathEscape(project), PathEscape(tagName)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var rls []*ReleaseLink - resp, err := s.client.Do(req, &rls) - if err != nil { - return nil, resp, err - } - - return rls, resp, nil + return do[[]*ReleaseLink](s.client, + withPath("projects/%s/releases/%s/assets/links", ProjectID{pid}, tagName), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetReleaseLink returns a link from release assets. // // GitLab API docs: https://docs.gitlab.com/api/releases/links/#get-a-release-link func (s *ReleaseLinksService) GetReleaseLink(pid any, tagName string, link int64, options ...RequestOptionFunc) (*ReleaseLink, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/releases/%s/assets/links/%d", - PathEscape(project), - PathEscape(tagName), - link) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - rl := new(ReleaseLink) - resp, err := s.client.Do(req, rl) - if err != nil { - return nil, resp, err - } - - return rl, resp, nil + return do[*ReleaseLink](s.client, + withPath("projects/%s/releases/%s/assets/links/%d", ProjectID{pid}, tagName, link), + withRequestOpts(options...), + ) } // CreateReleaseLinkOptions represents CreateReleaseLink() options. @@ -126,24 +93,12 @@ type CreateReleaseLinkOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/releases/links/#create-a-release-link func (s *ReleaseLinksService) CreateReleaseLink(pid any, tagName string, opt *CreateReleaseLinkOptions, options ...RequestOptionFunc) (*ReleaseLink, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/releases/%s/assets/links", PathEscape(project), PathEscape(tagName)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - rl := new(ReleaseLink) - resp, err := s.client.Do(req, rl) - if err != nil { - return nil, resp, err - } - - return rl, resp, nil + return do[*ReleaseLink](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/releases/%s/assets/links", ProjectID{pid}, tagName), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // UpdateReleaseLinkOptions represents UpdateReleaseLink() options. @@ -163,53 +118,21 @@ type UpdateReleaseLinkOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/releases/links/#update-a-release-link func (s *ReleaseLinksService) UpdateReleaseLink(pid any, tagName string, link int64, opt *UpdateReleaseLinkOptions, options ...RequestOptionFunc) (*ReleaseLink, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/releases/%s/assets/links/%d", - PathEscape(project), - PathEscape(tagName), - link) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - rl := new(ReleaseLink) - resp, err := s.client.Do(req, rl) - if err != nil { - return nil, resp, err - } - - return rl, resp, nil + return do[*ReleaseLink](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/releases/%s/assets/links/%d", ProjectID{pid}, tagName, link), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteReleaseLink deletes a link from release. // // GitLab API docs: https://docs.gitlab.com/api/releases/links/#delete-a-release-link func (s *ReleaseLinksService) DeleteReleaseLink(pid any, tagName string, link int64, options ...RequestOptionFunc) (*ReleaseLink, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/releases/%s/assets/links/%d", - PathEscape(project), - PathEscape(tagName), - link, + return do[*ReleaseLink](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/releases/%s/assets/links/%d", ProjectID{pid}, tagName, link), + withRequestOpts(options...), ) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, nil, err - } - - rl := new(ReleaseLink) - resp, err := s.client.Do(req, rl) - if err != nil { - return nil, resp, err - } - - return rl, resp, nil } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/repositories.go b/vendor/gitlab.com/gitlab-org/api/client-go/repositories.go index 5d21e57..1a4762f 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/repositories.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/repositories.go @@ -80,24 +80,11 @@ type ListTreeOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/repositories/#list-repository-tree func (s *RepositoriesService) ListTree(pid any, opt *ListTreeOptions, options ...RequestOptionFunc) ([]*TreeNode, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/tree", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var t []*TreeNode - resp, err := s.client.Do(req, &t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[[]*TreeNode](s.client, + withPath("projects/%s/repository/tree", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // Blob gets information about blob in repository like size and content. Note @@ -249,24 +236,11 @@ type CompareOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/repositories/#compare-branches-tags-or-commits func (s *RepositoriesService) Compare(pid any, opt *CompareOptions, options ...RequestOptionFunc) (*Compare, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/compare", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - c := new(Compare) - resp, err := s.client.Do(req, c) - if err != nil { - return nil, resp, err - } - - return c, resp, nil + return do[*Compare](s.client, + withPath("projects/%s/repository/compare", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // Contributor represents a GitLab contributor. @@ -297,24 +271,11 @@ type ListContributorsOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/repositories/#contributors func (s *RepositoriesService) Contributors(pid any, opt *ListContributorsOptions, options ...RequestOptionFunc) ([]*Contributor, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/contributors", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var c []*Contributor - resp, err := s.client.Do(req, &c) - if err != nil { - return nil, resp, err - } - - return c, resp, nil + return do[[]*Contributor](s.client, + withPath("projects/%s/repository/contributors", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // MergeBaseOptions represents the available MergeBase() options. @@ -331,24 +292,11 @@ type MergeBaseOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/repositories/#merge-base func (s *RepositoriesService) MergeBase(pid any, opt *MergeBaseOptions, options ...RequestOptionFunc) (*Commit, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/merge_base", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - c := new(Commit) - resp, err := s.client.Do(req, c) - if err != nil { - return nil, resp, err - } - - return c, resp, nil + return do[*Commit](s.client, + withPath("projects/%s/repository/merge_base", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // AddChangelogOptions represents the available AddChangelog() options. @@ -372,18 +320,13 @@ type AddChangelogOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/repositories/#add-changelog-data-to-a-changelog-file func (s *RepositoriesService) AddChangelog(pid any, opt *AddChangelogOptions, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/repository/changelog", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/repository/changelog", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) + return resp, err } // ChangelogData represents the generated changelog data. @@ -418,22 +361,9 @@ type GenerateChangelogDataOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/repositories/#generate-changelog-data func (s *RepositoriesService) GenerateChangelogData(pid any, opt GenerateChangelogDataOptions, options ...RequestOptionFunc) (*ChangelogData, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/changelog", project) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - cd := new(ChangelogData) - resp, err := s.client.Do(req, cd) - if err != nil { - return nil, resp, err - } - - return cd, resp, nil + return do[*ChangelogData](s.client, + withPath("projects/%s/repository/changelog", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/request_handler.go b/vendor/gitlab.com/gitlab-org/api/client-go/request_handler.go index 0982735..422cb0a 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/request_handler.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/request_handler.go @@ -62,6 +62,19 @@ func (i UserID) forPath() (string, error) { return PathEscape(id), nil } +type LabelID struct { + Value any +} + +func (i LabelID) forPath() (string, error) { + id, err := parseID(i.Value) + if err != nil { + return "", err + } + + return PathEscape(id), nil +} + type NoEscape struct { Value string } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/runner_controller_tokens.go b/vendor/gitlab.com/gitlab-org/api/client-go/runner_controller_tokens.go new file mode 100644 index 0000000..0f9bc2f --- /dev/null +++ b/vendor/gitlab.com/gitlab-org/api/client-go/runner_controller_tokens.go @@ -0,0 +1,113 @@ +package gitlab + +import ( + "net/http" + "time" +) + +type ( + // RunnerControllerTokensServiceInterface handles communication with the runner + // controller token related methods of the GitLab API. This is an admin-only + // endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + RunnerControllerTokensServiceInterface interface { + // ListRunnerControllerTokens gets a list of runner controller tokens. This is + // an admin-only endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + ListRunnerControllerTokens(rid int64, opt *ListRunnerControllerTokensOptions, options ...RequestOptionFunc) ([]*RunnerControllerToken, *Response, error) + // GetRunnerControllerToken gets a single runner controller token. This is an + // admin-only endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + GetRunnerControllerToken(rid int64, tokenID int64, options ...RequestOptionFunc) (*RunnerControllerToken, *Response, error) + // CreateRunnerControllerToken creates a new runner controller token. This is + // an admin-only endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + CreateRunnerControllerToken(rid int64, opt *CreateRunnerControllerTokenOptions, options ...RequestOptionFunc) (*RunnerControllerToken, *Response, error) + // RevokeRunnerControllerToken revokes a runner controller token. This is an + // admin-only endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + RevokeRunnerControllerToken(rid int64, tokenID int64, options ...RequestOptionFunc) (*Response, error) + } + + // RunnerControllerTokensService handles communication with the runner + // controller token related methods of the GitLab API. This is an admin-only + // endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + RunnerControllerTokensService struct { + client *Client + } +) + +var _ RunnerControllerTokensServiceInterface = (*RunnerControllerTokensService)(nil) + +// RunnerControllerToken represents a GitLab runner controller token. +type RunnerControllerToken struct { + ID int64 `json:"id"` + Description string `json:"description"` + Token string `json:"token,omitempty"` + CreatedAt *time.Time `json:"created_at"` + UpdatedAt *time.Time `json:"updated_at"` +} + +// ListRunnerControllerTokensOptions represents the available +// ListRunnerControllerTokens() options. +// +// GitLab API docs: Documentation not yet available, see +// https://gitlab.com/gitlab-org/gitlab/-/issues/581275 +type ListRunnerControllerTokensOptions struct { + ListOptions +} + +func (s *RunnerControllerTokensService) ListRunnerControllerTokens(rid int64, opt *ListRunnerControllerTokensOptions, options ...RequestOptionFunc) ([]*RunnerControllerToken, *Response, error) { + return do[[]*RunnerControllerToken](s.client, + withPath("runner_controllers/%d/tokens", rid), + withAPIOpts(opt), + withRequestOpts(options...), + ) +} + +func (s *RunnerControllerTokensService) GetRunnerControllerToken(rid int64, tokenID int64, options ...RequestOptionFunc) (*RunnerControllerToken, *Response, error) { + return do[*RunnerControllerToken](s.client, + withPath("runner_controllers/%d/tokens/%d", rid, tokenID), + withRequestOpts(options...), + ) +} + +// CreateRunnerControllerTokenOptions represents the available +// CreateRunnerControllerToken() options. +// +// GitLab API docs: Documentation not yet available, see +// https://gitlab.com/gitlab-org/gitlab/-/issues/581275 +type CreateRunnerControllerTokenOptions struct { + Description *string `url:"description,omitempty" json:"description,omitempty"` +} + +func (s *RunnerControllerTokensService) CreateRunnerControllerToken(rid int64, opt *CreateRunnerControllerTokenOptions, options ...RequestOptionFunc) (*RunnerControllerToken, *Response, error) { + return do[*RunnerControllerToken](s.client, + withMethod(http.MethodPost), + withPath("runner_controllers/%d/tokens", rid), + withAPIOpts(opt), + withRequestOpts(options...), + ) +} + +func (s *RunnerControllerTokensService) RevokeRunnerControllerToken(rid int64, tokenID int64, options ...RequestOptionFunc) (*Response, error) { + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("runner_controllers/%d/tokens/%d", rid, tokenID), + withRequestOpts(options...), + ) + return resp, err +} diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/runner_controllers.go b/vendor/gitlab.com/gitlab-org/api/client-go/runner_controllers.go new file mode 100644 index 0000000..7431026 --- /dev/null +++ b/vendor/gitlab.com/gitlab-org/api/client-go/runner_controllers.go @@ -0,0 +1,137 @@ +package gitlab + +import ( + "net/http" + "time" +) + +type ( + // RunnerControllersServiceInterface handles communication with the runner + // controller related methods of the GitLab API. This is an admin-only endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + RunnerControllersServiceInterface interface { + // ListRunnerControllers gets a list of runner controllers. This is an + // admin-only endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + ListRunnerControllers(opt *ListRunnerControllersOptions, options ...RequestOptionFunc) ([]*RunnerController, *Response, error) + // GetRunnerController gets a single runner controller. This is an admin-only + // endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + GetRunnerController(rid int64, options ...RequestOptionFunc) (*RunnerController, *Response, error) + // CreateRunnerController creates a new runner controller. This is an + // admin-only endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + CreateRunnerController(opt *CreateRunnerControllerOptions, options ...RequestOptionFunc) (*RunnerController, *Response, error) + // UpdateRunnerController updates a runner controller. This is an admin-only + // endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + UpdateRunnerController(rid int64, opt *UpdateRunnerControllerOptions, options ...RequestOptionFunc) (*RunnerController, *Response, error) + // DeleteRunnerController deletes a runner controller. This is an admin-only + // endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + DeleteRunnerController(rid int64, options ...RequestOptionFunc) (*Response, error) + } + + // RunnerControllersService handles communication with the runner controller + // related methods of the GitLab API. This is an admin-only endpoint. + // + // GitLab API docs: Documentation not yet available, see + // https://gitlab.com/gitlab-org/gitlab/-/issues/581275 + RunnerControllersService struct { + client *Client + } +) + +var _ RunnerControllersServiceInterface = (*RunnerControllersService)(nil) + +// RunnerController represents a GitLab runner controller. +type RunnerController struct { + ID int64 `json:"id"` + Description string `json:"description"` + Enabled bool `json:"enabled"` + CreatedAt *time.Time `json:"created_at"` + UpdatedAt *time.Time `json:"updated_at"` +} + +// ListRunnerControllersOptions represents the available +// ListRunnerControllers() options. +// +// GitLab API docs: Documentation not yet available, see +// https://gitlab.com/gitlab-org/gitlab/-/issues/581275 +type ListRunnerControllersOptions struct { + ListOptions +} + +func (s *RunnerControllersService) ListRunnerControllers(opt *ListRunnerControllersOptions, options ...RequestOptionFunc) ([]*RunnerController, *Response, error) { + return do[[]*RunnerController](s.client, + withPath("runner_controllers"), + withAPIOpts(opt), + withRequestOpts(options...), + ) +} + +func (s *RunnerControllersService) GetRunnerController(rid int64, options ...RequestOptionFunc) (*RunnerController, *Response, error) { + return do[*RunnerController](s.client, + withPath("runner_controllers/%d", rid), + withRequestOpts(options...), + ) +} + +// CreateRunnerControllerOptions represents the available +// CreateRunnerController() options. +// +// GitLab API docs: Documentation not yet available, see +// https://gitlab.com/gitlab-org/gitlab/-/issues/581275 +type CreateRunnerControllerOptions struct { + Description *string `url:"description,omitempty" json:"description,omitempty"` + Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"` +} + +func (s *RunnerControllersService) CreateRunnerController(opt *CreateRunnerControllerOptions, options ...RequestOptionFunc) (*RunnerController, *Response, error) { + return do[*RunnerController](s.client, + withMethod(http.MethodPost), + withPath("runner_controllers"), + withAPIOpts(opt), + withRequestOpts(options...), + ) +} + +// UpdateRunnerControllerOptions represents the available +// UpdateRunnerController() options. +// +// GitLab API docs: Documentation not yet available, see +// https://gitlab.com/gitlab-org/gitlab/-/issues/581275 +type UpdateRunnerControllerOptions struct { + Description *string `url:"description,omitempty" json:"description,omitempty"` + Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"` +} + +func (s *RunnerControllersService) UpdateRunnerController(rid int64, opt *UpdateRunnerControllerOptions, options ...RequestOptionFunc) (*RunnerController, *Response, error) { + return do[*RunnerController](s.client, + withMethod(http.MethodPut), + withPath("runner_controllers/%d", rid), + withAPIOpts(opt), + withRequestOpts(options...), + ) +} + +func (s *RunnerControllersService) DeleteRunnerController(rid int64, options ...RequestOptionFunc) (*Response, error) { + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("runner_controllers/%d", rid), + withRequestOpts(options...), + ) + return resp, err +} diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/search.go b/vendor/gitlab.com/gitlab-org/api/client-go/search.go index 33276d5..32e2191 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/search.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/search.go @@ -16,10 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" -) +import "net/http" type ( SearchServiceInterface interface { @@ -350,15 +347,14 @@ func (s *SearchService) search(scope, query string, result any, opt *SearchOptio } func (s *SearchService) searchByGroup(gid any, scope, query string, result any, opt *SearchOptions, options ...RequestOptionFunc) (*Response, error) { - group, err := parseID(gid) + path, err := GroupID{gid}.forPath() if err != nil { return nil, err } - u := fmt.Sprintf("groups/%s/-/search", PathEscape(group)) opts := &searchOptions{SearchOptions: *opt, Scope: scope, Search: query} - req, err := s.client.NewRequest(http.MethodGet, u, opts, options) + req, err := s.client.NewRequest(http.MethodGet, "groups/"+path+"/-/search", opts, options) if err != nil { return nil, err } @@ -367,15 +363,14 @@ func (s *SearchService) searchByGroup(gid any, scope, query string, result any, } func (s *SearchService) searchByProject(pid any, scope, query string, result any, opt *SearchOptions, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) + path, err := ProjectID{pid}.forPath() if err != nil { return nil, err } - u := fmt.Sprintf("projects/%s/-/search", PathEscape(project)) opts := &searchOptions{SearchOptions: *opt, Scope: scope, Search: query} - req, err := s.client.NewRequest(http.MethodGet, u, opts, options) + req, err := s.client.NewRequest(http.MethodGet, "projects/"+path+"/-/search", opts, options) if err != nil { return nil, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/secure_files.go b/vendor/gitlab.com/gitlab-org/api/client-go/secure_files.go index a0f96d1..bfb82a2 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/secure_files.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/secure_files.go @@ -14,7 +14,6 @@ package gitlab import ( - "bytes" "fmt" "io" "net/http" @@ -206,13 +205,13 @@ func (s SecureFilesService) DownloadSecureFile(pid any, id int64, options ...Req return nil, nil, err } - var file bytes.Buffer - resp, err := s.client.Do(req, &file) + preserver := &bodyPreserver{} + resp, err := s.client.Do(req, preserver) if err != nil { return nil, resp, err } - return &file, resp, err + return preserver.body, resp, err } // RemoveSecureFile removes a project's secure file. diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/services.go b/vendor/gitlab.com/gitlab-org/api/client-go/services.go index 53a34ad..c8eeb0d 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/services.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/services.go @@ -111,24 +111,10 @@ type Service = Integration // // GitLab API docs: https://docs.gitlab.com/api/project_integrations/#list-all-active-integrations func (s *ServicesService) ListServices(pid any, options ...RequestOptionFunc) ([]*Service, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var svcs []*Service - resp, err := s.client.Do(req, &svcs) - if err != nil { - return nil, resp, err - } - - return svcs, resp, nil + return do[[]*Service](s.client, + withPath("projects/%s/services", ProjectID{pid}), + withRequestOpts(options...), + ) } // CustomIssueTrackerService represents Custom Issue Tracker service settings. @@ -155,24 +141,10 @@ type CustomIssueTrackerServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-custom-issue-tracker-settings func (s *ServicesService) GetCustomIssueTrackerService(pid any, options ...RequestOptionFunc) (*CustomIssueTrackerService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(CustomIssueTrackerService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*CustomIssueTrackerService](s.client, + withPath("projects/%s/services/custom-issue-tracker", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetCustomIssueTrackerServiceOptions represents the available SetCustomIssueTrackerService() @@ -191,24 +163,12 @@ type SetCustomIssueTrackerServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-a-custom-issue-tracker func (s *ServicesService) SetCustomIssueTrackerService(pid any, opt *SetCustomIssueTrackerServiceOptions, options ...RequestOptionFunc) (*CustomIssueTrackerService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(CustomIssueTrackerService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*CustomIssueTrackerService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/custom-issue-tracker", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteCustomIssueTrackerService deletes Custom Issue Tracker service settings for a project. @@ -216,18 +176,12 @@ func (s *ServicesService) SetCustomIssueTrackerService(pid any, opt *SetCustomIs // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-a-custom-issue-tracker func (s *ServicesService) DeleteCustomIssueTrackerService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/custom-issue-tracker", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/custom-issue-tracker", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // DataDogService represents DataDog service settings. @@ -259,24 +213,10 @@ type DataDogServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-datadog-settings func (s *ServicesService) GetDataDogService(pid any, options ...RequestOptionFunc) (*DataDogService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/datadog", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(DataDogService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*DataDogService](s.client, + withPath("projects/%s/integrations/datadog", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetDataDogServiceOptions represents the available SetDataDogService() @@ -301,24 +241,12 @@ type SetDataDogServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-datadog func (s *ServicesService) SetDataDogService(pid any, opt *SetDataDogServiceOptions, options ...RequestOptionFunc) (*DataDogService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/datadog", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(DataDogService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*DataDogService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/integrations/datadog", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteDataDogService deletes the DataDog service settings for a project. @@ -326,18 +254,12 @@ func (s *ServicesService) SetDataDogService(pid any, opt *SetDataDogServiceOptio // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-datadog func (s *ServicesService) DeleteDataDogService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/integrations/datadog", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/integrations/datadog", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // DiscordService represents Discord service settings. @@ -363,24 +285,10 @@ type DiscordServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-discord-notifications-settings func (s *ServicesService) GetDiscordService(pid any, options ...RequestOptionFunc) (*DiscordService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/discord", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(DiscordService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*DiscordService](s.client, + withPath("projects/%s/services/discord", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetDiscordServiceOptions represents the available SetDiscordService() @@ -423,24 +331,12 @@ type SetDiscordServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-discord-notifications func (s *ServicesService) SetDiscordService(pid any, opt *SetDiscordServiceOptions, options ...RequestOptionFunc) (*DiscordService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/discord", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(DiscordService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*DiscordService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/discord", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteDiscordService deletes Discord service settings for a project. @@ -448,18 +344,12 @@ func (s *ServicesService) SetDiscordService(pid any, opt *SetDiscordServiceOptio // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-discord-notifications func (s *ServicesService) DeleteDiscordService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/discord", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/discord", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // DroneCIService represents Drone CI service settings. @@ -485,24 +375,10 @@ type DroneCIServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-drone-settings func (s *ServicesService) GetDroneCIService(pid any, options ...RequestOptionFunc) (*DroneCIService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/drone-ci", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(DroneCIService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*DroneCIService](s.client, + withPath("projects/%s/services/drone-ci", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetDroneCIServiceOptions represents the available SetDroneCIService() @@ -524,24 +400,12 @@ type SetDroneCIServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-drone func (s *ServicesService) SetDroneCIService(pid any, opt *SetDroneCIServiceOptions, options ...RequestOptionFunc) (*DroneCIService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/drone-ci", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(DroneCIService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*DroneCIService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/drone-ci", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteDroneCIService deletes Drone CI service settings for a project. @@ -549,18 +413,12 @@ func (s *ServicesService) SetDroneCIService(pid any, opt *SetDroneCIServiceOptio // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-drone func (s *ServicesService) DeleteDroneCIService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/drone-ci", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/drone-ci", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // EmailsOnPushService represents Emails on Push service settings. @@ -580,9 +438,12 @@ type EmailsOnPushServiceProperties struct { Recipients string `json:"recipients"` DisableDiffs bool `json:"disable_diffs"` SendFromCommitterEmail bool `json:"send_from_committer_email"` - PushEvents bool `json:"push_events"` - TagPushEvents bool `json:"tag_push_events"` BranchesToBeNotified string `json:"branches_to_be_notified"` + + // Deprecated: to be removed in 2.0 - use EmailsOnPushService.PushEvents instead. + PushEvents bool `json:"push_events"` + // Deprecated: to be removed in 2.0 - use EmailsOnPushService.TagPushEvents instead. + TagPushEvents bool `json:"tag_push_events"` } // GetEmailsOnPushService gets Emails on Push service settings for a project. @@ -590,24 +451,10 @@ type EmailsOnPushServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-emails-on-push-settings func (s *ServicesService) GetEmailsOnPushService(pid any, options ...RequestOptionFunc) (*EmailsOnPushService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/emails-on-push", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(EmailsOnPushService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*EmailsOnPushService](s.client, + withPath("projects/%s/integrations/emails-on-push", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetEmailsOnPushServiceOptions represents the available SetEmailsOnPushService() @@ -629,24 +476,12 @@ type SetEmailsOnPushServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-emails-on-push func (s *ServicesService) SetEmailsOnPushService(pid any, opt *SetEmailsOnPushServiceOptions, options ...RequestOptionFunc) (*EmailsOnPushService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/emails-on-push", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(EmailsOnPushService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*EmailsOnPushService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/integrations/emails-on-push", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteEmailsOnPushService deletes Emails on Push service settings for a project. @@ -654,18 +489,12 @@ func (s *ServicesService) SetEmailsOnPushService(pid any, opt *SetEmailsOnPushSe // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-emails-on-push func (s *ServicesService) DeleteEmailsOnPushService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/integrations/emails-on-push", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/integrations/emails-on-push", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // ExternalWikiService represents External Wiki service settings. @@ -690,24 +519,10 @@ type ExternalWikiServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-external-wiki-settings func (s *ServicesService) GetExternalWikiService(pid any, options ...RequestOptionFunc) (*ExternalWikiService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/external-wiki", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(ExternalWikiService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*ExternalWikiService](s.client, + withPath("projects/%s/services/external-wiki", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetExternalWikiServiceOptions represents the available SetExternalWikiService() @@ -724,24 +539,12 @@ type SetExternalWikiServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-an-external-wiki func (s *ServicesService) SetExternalWikiService(pid any, opt *SetExternalWikiServiceOptions, options ...RequestOptionFunc) (*ExternalWikiService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/external-wiki", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(ExternalWikiService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*ExternalWikiService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/external-wiki", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteExternalWikiService deletes External Wiki service for project. @@ -749,18 +552,12 @@ func (s *ServicesService) SetExternalWikiService(pid any, opt *SetExternalWikiSe // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-an-external-wiki func (s *ServicesService) DeleteExternalWikiService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/external-wiki", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/external-wiki", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // GithubService represents Github service settings. @@ -786,24 +583,10 @@ type GithubServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-github-settings func (s *ServicesService) GetGithubService(pid any, options ...RequestOptionFunc) (*GithubService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/github", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(GithubService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*GithubService](s.client, + withPath("projects/%s/services/github", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetGithubServiceOptions represents the available SetGithubService() @@ -822,24 +605,12 @@ type SetGithubServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-github func (s *ServicesService) SetGithubService(pid any, opt *SetGithubServiceOptions, options ...RequestOptionFunc) (*GithubService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/github", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(GithubService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*GithubService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/github", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteGithubService deletes Github service for a project @@ -847,18 +618,12 @@ func (s *ServicesService) SetGithubService(pid any, opt *SetGithubServiceOptions // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-github func (s *ServicesService) DeleteGithubService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/github", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/github", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // HarborService represents the Harbor service settings. @@ -887,24 +652,10 @@ type HarborServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-harbor-settings func (s *ServicesService) GetHarborService(pid any, options ...RequestOptionFunc) (*HarborService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/harbor", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(HarborService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*HarborService](s.client, + withPath("projects/%s/integrations/harbor", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetHarborServiceOptions represents the available SetHarborService() @@ -919,24 +670,12 @@ type SetHarborServiceOptions = SetUpHarborOptions // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-harbor func (s *ServicesService) SetHarborService(pid any, opt *SetHarborServiceOptions, options ...RequestOptionFunc) (*HarborService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/harbor", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(HarborService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*HarborService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/integrations/harbor", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteHarborService deletes Harbor service for a project. @@ -944,18 +683,12 @@ func (s *ServicesService) SetHarborService(pid any, opt *SetHarborServiceOptions // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-harbor func (s *ServicesService) DeleteHarborService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/integrations/harbor", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/integrations/harbor", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // SlackApplication represents GitLab for slack application settings. @@ -1001,24 +734,10 @@ type SlackApplicationProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-gitlab-for-slack-app-settings func (s *ServicesService) GetSlackApplication(pid any, options ...RequestOptionFunc) (*SlackApplication, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/gitlab-slack-application", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(SlackApplication) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*SlackApplication](s.client, + withPath("projects/%s/integrations/gitlab-slack-application", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetSlackApplicationOptions represents the available SetSlackApplication() @@ -1069,24 +788,12 @@ type SetSlackApplicationOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-gitlab-for-slack-app func (s *ServicesService) SetSlackApplication(pid any, opt *SetSlackApplicationOptions, options ...RequestOptionFunc) (*SlackApplication, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/gitlab-slack-application", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(SlackApplication) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*SlackApplication](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/integrations/gitlab-slack-application", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DisableSlackApplication disable the GitLab for Slack app integration for a project. @@ -1094,18 +801,12 @@ func (s *ServicesService) SetSlackApplication(pid any, opt *SetSlackApplicationO // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-gitlab-for-slack-app func (s *ServicesService) DisableSlackApplication(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/integrations/gitlab-slack-application", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/integrations/gitlab-slack-application", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // JenkinsCIService represents Jenkins CI service settings. @@ -1133,24 +834,10 @@ type JenkinsCIServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-jenkins-settings func (s *ServicesService) GetJenkinsCIService(pid any, options ...RequestOptionFunc) (*JenkinsCIService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/jenkins", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(JenkinsCIService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*JenkinsCIService](s.client, + withPath("projects/%s/services/jenkins", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetJenkinsCIServiceOptions represents the available SetJenkinsCIService() @@ -1174,24 +861,12 @@ type SetJenkinsCIServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-jenkins func (s *ServicesService) SetJenkinsCIService(pid any, opt *SetJenkinsCIServiceOptions, options ...RequestOptionFunc) (*JenkinsCIService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/jenkins", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(JenkinsCIService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*JenkinsCIService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/jenkins", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteJenkinsCIService deletes Jenkins CI service for project. @@ -1199,18 +874,12 @@ func (s *ServicesService) SetJenkinsCIService(pid any, opt *SetJenkinsCIServiceO // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-jenkins func (s *ServicesService) DeleteJenkinsCIService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/jenkins", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/jenkins", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // JiraService represents Jira service settings. @@ -1280,24 +949,10 @@ func (p *JiraServiceProperties) UnmarshalJSON(b []byte) error { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-jira-settings func (s *ServicesService) GetJiraService(pid any, options ...RequestOptionFunc) (*JiraService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/jira", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(JiraService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*JiraService](s.client, + withPath("projects/%s/integrations/jira", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetJiraServiceOptions represents the available SetJiraService() @@ -1329,24 +984,12 @@ type SetJiraServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-jira-issues func (s *ServicesService) SetJiraService(pid any, opt *SetJiraServiceOptions, options ...RequestOptionFunc) (*JiraService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/jira", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(JiraService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*JiraService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/integrations/jira", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteJiraService deletes Jira service for project. @@ -1354,18 +997,12 @@ func (s *ServicesService) SetJiraService(pid any, opt *SetJiraServiceOptions, op // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-jira func (s *ServicesService) DeleteJiraService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/integrations/jira", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/integrations/jira", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // MatrixService represents Matrix service settings. @@ -1487,24 +1124,10 @@ type MattermostServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-mattermost-notifications-settings func (s *ServicesService) GetMattermostService(pid any, options ...RequestOptionFunc) (*MattermostService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/mattermost", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(MattermostService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*MattermostService](s.client, + withPath("projects/%s/services/mattermost", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetMattermostServiceOptions represents the available SetMattermostService() @@ -1543,24 +1166,12 @@ type SetMattermostServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-mattermost-notifications func (s *ServicesService) SetMattermostService(pid any, opt *SetMattermostServiceOptions, options ...RequestOptionFunc) (*MattermostService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/mattermost", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(MattermostService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*MattermostService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/mattermost", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteMattermostService deletes Mattermost service for project. @@ -1568,18 +1179,12 @@ func (s *ServicesService) SetMattermostService(pid any, opt *SetMattermostServic // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-mattermost-notifications func (s *ServicesService) DeleteMattermostService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/mattermost", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/mattermost", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // MattermostSlashCommandsService represents Mattermost slash commands settings. @@ -1605,24 +1210,10 @@ type MattermostSlashCommandsProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-mattermost-slash-commands-settings func (s *ServicesService) GetMattermostSlashCommandsService(pid any, options ...RequestOptionFunc) (*MattermostSlashCommandsService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(MattermostSlashCommandsService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*MattermostSlashCommandsService](s.client, + withPath("projects/%s/services/mattermost-slash-commands", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetMattermostSlashCommandsServiceOptions represents the available SetSlackSlashCommandsService() @@ -1640,24 +1231,12 @@ type SetMattermostSlashCommandsServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-mattermost-slash-commands func (s *ServicesService) SetMattermostSlashCommandsService(pid any, opt *SetMattermostSlashCommandsServiceOptions, options ...RequestOptionFunc) (*MattermostSlashCommandsService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(MattermostSlashCommandsService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*MattermostSlashCommandsService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/mattermost-slash-commands", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteMattermostSlashCommandsService deletes Mattermost slash commands service for project. @@ -1665,18 +1244,12 @@ func (s *ServicesService) SetMattermostSlashCommandsService(pid any, opt *SetMat // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-mattermost-slash-commands func (s *ServicesService) DeleteMattermostSlashCommandsService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/mattermost-slash-commands", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // MicrosoftTeamsService represents Microsoft Teams service settings. @@ -1711,24 +1284,10 @@ type MicrosoftTeamsServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-microsoft-teams-notifications-settings func (s *ServicesService) GetMicrosoftTeamsService(pid any, options ...RequestOptionFunc) (*MicrosoftTeamsService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/microsoft-teams", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(MicrosoftTeamsService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*MicrosoftTeamsService](s.client, + withPath("projects/%s/services/microsoft-teams", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetMicrosoftTeamsServiceOptions represents the available SetMicrosoftTeamsService() @@ -1756,24 +1315,12 @@ type SetMicrosoftTeamsServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-microsoft-teams-notifications func (s *ServicesService) SetMicrosoftTeamsService(pid any, opt *SetMicrosoftTeamsServiceOptions, options ...RequestOptionFunc) (*MicrosoftTeamsService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/microsoft-teams", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(MicrosoftTeamsService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*MicrosoftTeamsService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/microsoft-teams", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteMicrosoftTeamsService deletes Microsoft Teams service for project. @@ -1781,18 +1328,12 @@ func (s *ServicesService) SetMicrosoftTeamsService(pid any, opt *SetMicrosoftTea // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-microsoft-teams-notifications func (s *ServicesService) DeleteMicrosoftTeamsService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/microsoft-teams", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/microsoft-teams", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // PipelinesEmailService represents Pipelines Email service settings. @@ -1820,24 +1361,10 @@ type PipelinesEmailProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-pipeline-status-emails-settings func (s *ServicesService) GetPipelinesEmailService(pid any, options ...RequestOptionFunc) (*PipelinesEmailService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/pipelines-email", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(PipelinesEmailService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*PipelinesEmailService](s.client, + withPath("projects/%s/services/pipelines-email", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetPipelinesEmailServiceOptions represents the available @@ -1859,24 +1386,12 @@ type SetPipelinesEmailServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-pipeline-status-emails func (s *ServicesService) SetPipelinesEmailService(pid any, opt *SetPipelinesEmailServiceOptions, options ...RequestOptionFunc) (*PipelinesEmailService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/pipelines-email", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(PipelinesEmailService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*PipelinesEmailService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/pipelines-email", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeletePipelinesEmailService deletes Pipelines Email service settings for a project. @@ -1884,18 +1399,12 @@ func (s *ServicesService) SetPipelinesEmailService(pid any, opt *SetPipelinesEma // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-pipeline-status-emails func (s *ServicesService) DeletePipelinesEmailService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/pipelines-email", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/pipelines-email", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // RedmineService represents the Redmine service settings. @@ -1923,24 +1432,10 @@ type RedmineServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-redmine-settings func (s *ServicesService) GetRedmineService(pid any, options ...RequestOptionFunc) (*RedmineService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/redmine", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(RedmineService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*RedmineService](s.client, + withPath("projects/%s/integrations/redmine", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetRedmineServiceOptions represents the available SetRedmineService(). @@ -1960,24 +1455,12 @@ type SetRedmineServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-redmine func (s *ServicesService) SetRedmineService(pid any, opt *SetRedmineServiceOptions, options ...RequestOptionFunc) (*RedmineService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/integrations/redmine", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(RedmineService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*RedmineService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/integrations/redmine", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteRedmineService deletes Redmine service for project. @@ -1985,18 +1468,12 @@ func (s *ServicesService) SetRedmineService(pid any, opt *SetRedmineServiceOptio // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-redmine func (s *ServicesService) DeleteRedmineService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/integrations/redmine", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/integrations/redmine", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // SlackService represents Slack service settings. @@ -2038,24 +1515,10 @@ type SlackServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-slack-notifications-settings func (s *ServicesService) GetSlackService(pid any, options ...RequestOptionFunc) (*SlackService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/slack", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(SlackService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*SlackService](s.client, + withPath("projects/%s/services/slack", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetSlackServiceOptions represents the available SetSlackService() @@ -2099,24 +1562,12 @@ type SetSlackServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-slack-notifications func (s *ServicesService) SetSlackService(pid any, opt *SetSlackServiceOptions, options ...RequestOptionFunc) (*SlackService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/slack", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(SlackService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*SlackService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/slack", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteSlackService deletes Slack service for project. @@ -2124,18 +1575,12 @@ func (s *ServicesService) SetSlackService(pid any, opt *SetSlackServiceOptions, // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-slack-notifications func (s *ServicesService) DeleteSlackService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/slack", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/slack", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // SlackSlashCommandsService represents Slack slash commands settings. @@ -2160,24 +1605,10 @@ type SlackSlashCommandsProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-slack-slash-commands-settings func (s *ServicesService) GetSlackSlashCommandsService(pid any, options ...RequestOptionFunc) (*SlackSlashCommandsService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/slack-slash-commands", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(SlackSlashCommandsService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*SlackSlashCommandsService](s.client, + withPath("projects/%s/services/slack-slash-commands", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetSlackSlashCommandsServiceOptions represents the available SetSlackSlashCommandsService() @@ -2194,24 +1625,12 @@ type SetSlackSlashCommandsServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-slack-slash-commands func (s *ServicesService) SetSlackSlashCommandsService(pid any, opt *SetSlackSlashCommandsServiceOptions, options ...RequestOptionFunc) (*SlackSlashCommandsService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/slack-slash-commands", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(SlackSlashCommandsService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*SlackSlashCommandsService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/slack-slash-commands", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteSlackSlashCommandsService deletes Slack slash commands service for project. @@ -2219,18 +1638,12 @@ func (s *ServicesService) SetSlackSlashCommandsService(pid any, opt *SetSlackSla // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-slack-slash-commands func (s *ServicesService) DeleteSlackSlashCommandsService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/slack-slash-commands", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/slack-slash-commands", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // TelegramService represents Telegram service settings. @@ -2257,24 +1670,10 @@ type TelegramServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-telegram-settings func (s *ServicesService) GetTelegramService(pid any, options ...RequestOptionFunc) (*TelegramService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(TelegramService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*TelegramService](s.client, + withPath("projects/%s/services/telegram", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetTelegramServiceOptions represents the available SetTelegramService() @@ -2303,24 +1702,12 @@ type SetTelegramServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-telegram func (s *ServicesService) SetTelegramService(pid any, opt *SetTelegramServiceOptions, options ...RequestOptionFunc) (*TelegramService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - svc := new(TelegramService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*TelegramService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/telegram", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteTelegramService deletes Telegram service for project. @@ -2328,18 +1715,12 @@ func (s *ServicesService) SetTelegramService(pid any, opt *SetTelegramServiceOpt // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-telegram func (s *ServicesService) DeleteTelegramService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/telegram", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } // YouTrackService represents YouTrack service settings. @@ -2367,24 +1748,10 @@ type YouTrackServiceProperties struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#get-youtrack-settings func (s *ServicesService) GetYouTrackService(pid any, options ...RequestOptionFunc) (*YouTrackService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/youtrack", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - svc := new(YouTrackService) - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, resp, err - } - - return svc, resp, nil + return do[*YouTrackService](s.client, + withPath("projects/%s/services/youtrack", ProjectID{pid}), + withRequestOpts(options...), + ) } // SetYouTrackServiceOptions represents the available SetYouTrackService() @@ -2404,24 +1771,12 @@ type SetYouTrackServiceOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#set-up-youtrack func (s *ServicesService) SetYouTrackService(pid any, opt *SetYouTrackServiceOptions, options ...RequestOptionFunc) (*YouTrackService, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/services/youtrack", PathEscape(project)) - - svc := new(YouTrackService) - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) - if err != nil { - return nil, nil, err - } - - resp, err := s.client.Do(req, svc) - if err != nil { - return nil, nil, err - } - - return svc, resp, nil + return do[*YouTrackService](s.client, + withMethod(http.MethodPut), + withPath("projects/%s/services/youtrack", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteYouTrackService deletes YouTrack service settings for a project. @@ -2429,16 +1784,10 @@ func (s *ServicesService) SetYouTrackService(pid any, opt *SetYouTrackServiceOpt // GitLab API docs: // https://docs.gitlab.com/api/project_integrations/#disable-youtrack func (s *ServicesService) DeleteYouTrackService(pid any, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/services/youtrack", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/services/youtrack", ProjectID{pid}), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/settings.go b/vendor/gitlab.com/gitlab-org/api/client-go/settings.go index ef3d769..b41a605 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/settings.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/settings.go @@ -243,6 +243,7 @@ type Settings struct { InactiveProjectsDeleteAfterMonths int64 `json:"inactive_projects_delete_after_months"` InactiveProjectsMinSizeMB int64 `json:"inactive_projects_min_size_mb"` InactiveProjectsSendWarningEmailAfterMonths int64 `json:"inactive_projects_send_warning_email_after_months"` + InactiveResourceAccessTokensDeleteAfterDays int64 `json:"inactive_resource_access_tokens_delete_after_days"` IncludeOptionalMetricsInServicePing bool `json:"include_optional_metrics_in_service_ping"` InProductMarketingEmailsEnabled bool `json:"in_product_marketing_emails_enabled"` InvisibleCaptchaEnabled bool `json:"invisible_captcha_enabled"` @@ -521,18 +522,10 @@ func (s Settings) String() string { // GitLab API docs: // https://docs.gitlab.com/api/settings/#get-details-on-current-application-settings func (s *SettingsService) GetSettings(options ...RequestOptionFunc) (*Settings, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "application/settings", nil, options) - if err != nil { - return nil, nil, err - } - - as := new(Settings) - resp, err := s.client.Do(req, as) - if err != nil { - return nil, resp, err - } - - return as, resp, nil + return do[*Settings](s.client, + withPath("application/settings"), + withRequestOpts(options...), + ) } // UpdateSettingsOptions represents the available UpdateSettings() options. @@ -730,6 +723,7 @@ type UpdateSettingsOptions struct { InactiveProjectsDeleteAfterMonths *int64 `url:"inactive_projects_delete_after_months,omitempty" json:"inactive_projects_delete_after_months,omitempty"` InactiveProjectsMinSizeMB *int64 `url:"inactive_projects_min_size_mb,omitempty" json:"inactive_projects_min_size_mb,omitempty"` InactiveProjectsSendWarningEmailAfterMonths *int64 `url:"inactive_projects_send_warning_email_after_months,omitempty" json:"inactive_projects_send_warning_email_after_months,omitempty"` + InactiveResourceAccessTokensDeleteAfterDays *int64 `url:"inactive_resource_access_tokens_delete_after_days,omitempty" json:"inactive_resource_access_tokens_delete_after_days,omitempty"` IncludeOptionalMetricsInServicePing *bool `url:"include_optional_metrics_in_service_ping,omitempty" json:"include_optional_metrics_in_service_ping,omitempty"` InProductMarketingEmailsEnabled *bool `url:"in_product_marketing_emails_enabled,omitempty" json:"in_product_marketing_emails_enabled,omitempty"` InvisibleCaptchaEnabled *bool `url:"invisible_captcha_enabled,omitempty" json:"invisible_captcha_enabled,omitempty"` @@ -987,16 +981,10 @@ type BranchProtectionDefaultsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/settings/#update-application-settings func (s *SettingsService) UpdateSettings(opt *UpdateSettingsOptions, options ...RequestOptionFunc) (*Settings, *Response, error) { - req, err := s.client.NewRequest(http.MethodPut, "application/settings", opt, options) - if err != nil { - return nil, nil, err - } - - as := new(Settings) - resp, err := s.client.Do(req, as) - if err != nil { - return nil, resp, err - } - - return as, resp, nil + return do[*Settings](s.client, + withMethod(http.MethodPut), + withPath("application/settings"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/sidekiq_metrics.go b/vendor/gitlab.com/gitlab-org/api/client-go/sidekiq_metrics.go index cc7296f..0eb6a29 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/sidekiq_metrics.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/sidekiq_metrics.go @@ -17,7 +17,6 @@ package gitlab import ( - "net/http" "time" ) @@ -62,18 +61,10 @@ type QueueMetricsQueue struct { // GitLab API docs: // https://docs.gitlab.com/api/sidekiq_metrics/#get-the-current-queue-metrics func (s *SidekiqService) GetQueueMetrics(options ...RequestOptionFunc) (*QueueMetrics, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/queue_metrics", nil, options) - if err != nil { - return nil, nil, err - } - - q := new(QueueMetrics) - resp, err := s.client.Do(req, q) - if err != nil { - return nil, resp, err - } - - return q, resp, nil + return do[*QueueMetrics](s.client, + withPath("/sidekiq/queue_metrics"), + withRequestOpts(options...), + ) } // ProcessMetrics represents the GitLab sidekiq process metrics. @@ -105,18 +96,10 @@ type ProcessMetricsProcess struct { // GitLab API docs: // https://docs.gitlab.com/api/sidekiq_metrics/#get-the-current-process-metrics func (s *SidekiqService) GetProcessMetrics(options ...RequestOptionFunc) (*ProcessMetrics, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/process_metrics", nil, options) - if err != nil { - return nil, nil, err - } - - p := new(ProcessMetrics) - resp, err := s.client.Do(req, p) - if err != nil { - return nil, resp, err - } - - return p, resp, nil + return do[*ProcessMetrics](s.client, + withPath("/sidekiq/process_metrics"), + withRequestOpts(options...), + ) } // JobStats represents the GitLab sidekiq job stats. @@ -142,18 +125,10 @@ type JobStatsJobs struct { // GitLab API docs: // https://docs.gitlab.com/api/sidekiq_metrics/#get-the-current-job-statistics func (s *SidekiqService) GetJobStats(options ...RequestOptionFunc) (*JobStats, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/job_stats", nil, options) - if err != nil { - return nil, nil, err - } - - j := new(JobStats) - resp, err := s.client.Do(req, j) - if err != nil { - return nil, resp, err - } - - return j, resp, nil + return do[*JobStats](s.client, + withPath("/sidekiq/job_stats"), + withRequestOpts(options...), + ) } // CompoundMetrics represents the GitLab sidekiq compounded stats. @@ -172,16 +147,8 @@ type CompoundMetrics struct { // GitLab API docs: // https://docs.gitlab.com/api/sidekiq_metrics/#get-a-compound-response-of-all-the-previously-mentioned-metrics func (s *SidekiqService) GetCompoundMetrics(options ...RequestOptionFunc) (*CompoundMetrics, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "/sidekiq/compound_metrics", nil, options) - if err != nil { - return nil, nil, err - } - - c := new(CompoundMetrics) - resp, err := s.client.Do(req, c) - if err != nil { - return nil, resp, err - } - - return c, resp, nil + return do[*CompoundMetrics](s.client, + withPath("/sidekiq/compound_metrics"), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/system_hooks.go b/vendor/gitlab.com/gitlab-org/api/client-go/system_hooks.go index a74914f..f8bcffc 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/system_hooks.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/system_hooks.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -65,18 +64,10 @@ func (h Hook) String() string { // GitLab API docs: // https://docs.gitlab.com/api/system_hooks/#list-system-hooks func (s *SystemHooksService) ListHooks(options ...RequestOptionFunc) ([]*Hook, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "hooks", nil, options) - if err != nil { - return nil, nil, err - } - - var h []*Hook - resp, err := s.client.Do(req, &h) - if err != nil { - return nil, resp, err - } - - return h, resp, nil + return do[[]*Hook](s.client, + withPath("hooks"), + withRequestOpts(options...), + ) } // GetHook get a single system hook. @@ -84,20 +75,10 @@ func (s *SystemHooksService) ListHooks(options ...RequestOptionFunc) ([]*Hook, * // GitLab API docs: // https://docs.gitlab.com/api/system_hooks/#get-system-hook func (s *SystemHooksService) GetHook(hook int64, options ...RequestOptionFunc) (*Hook, *Response, error) { - u := fmt.Sprintf("hooks/%d", hook) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var h *Hook - resp, err := s.client.Do(req, &h) - if err != nil { - return nil, resp, err - } - - return h, resp, nil + return do[*Hook](s.client, + withPath("hooks/%d", hook), + withRequestOpts(options...), + ) } // AddHookOptions represents the available AddHook() options. @@ -119,18 +100,12 @@ type AddHookOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/system_hooks/#add-new-system-hook func (s *SystemHooksService) AddHook(opt *AddHookOptions, options ...RequestOptionFunc) (*Hook, *Response, error) { - req, err := s.client.NewRequest(http.MethodPost, "hooks", opt, options) - if err != nil { - return nil, nil, err - } - - h := new(Hook) - resp, err := s.client.Do(req, h) - if err != nil { - return nil, resp, err - } - - return h, resp, nil + return do[*Hook](s.client, + withMethod(http.MethodPost), + withPath("hooks"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // HookEvent represents an event trigger by a GitLab system hook. @@ -154,20 +129,10 @@ func (h HookEvent) String() string { // GitLab API docs: // https://docs.gitlab.com/api/system_hooks/#test-system-hook func (s *SystemHooksService) TestHook(hook int64, options ...RequestOptionFunc) (*HookEvent, *Response, error) { - u := fmt.Sprintf("hooks/%d", hook) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - h := new(HookEvent) - resp, err := s.client.Do(req, h) - if err != nil { - return nil, resp, err - } - - return h, resp, nil + return do[*HookEvent](s.client, + withPath("hooks/%d", hook), + withRequestOpts(options...), + ) } // DeleteHook deletes a system hook. This is an idempotent API function and @@ -177,12 +142,10 @@ func (s *SystemHooksService) TestHook(hook int64, options ...RequestOptionFunc) // GitLab API docs: // https://docs.gitlab.com/api/system_hooks/#delete-system-hook func (s *SystemHooksService) DeleteHook(hook int64, options ...RequestOptionFunc) (*Response, error) { - u := fmt.Sprintf("hooks/%d", hook) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("hooks/%d", hook), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/tags.go b/vendor/gitlab.com/gitlab-org/api/client-go/tags.go index 5df51a3..28da18a 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/tags.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/tags.go @@ -17,10 +17,8 @@ package gitlab import ( - "fmt" "math/big" "net/http" - "net/url" "time" ) @@ -112,24 +110,11 @@ type ListTagsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/tags/#list-project-repository-tags func (s *TagsService) ListTags(pid any, opt *ListTagsOptions, options ...RequestOptionFunc) ([]*Tag, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/tags", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, opt, options) - if err != nil { - return nil, nil, err - } - - var t []*Tag - resp, err := s.client.Do(req, &t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[[]*Tag](s.client, + withPath("projects/%s/repository/tags", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // GetTag a specific repository tag determined by its name. It returns 200 together @@ -138,24 +123,10 @@ func (s *TagsService) ListTags(pid any, opt *ListTagsOptions, options ...Request // GitLab API docs: // https://docs.gitlab.com/api/tags/#get-a-single-repository-tag func (s *TagsService) GetTag(pid any, tag string, options ...RequestOptionFunc) (*Tag, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/tags/%s", PathEscape(project), url.PathEscape(tag)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var t *Tag - resp, err := s.client.Do(req, &t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[*Tag](s.client, + withPath("projects/%s/repository/tags/%s", ProjectID{pid}, tag), + withRequestOpts(options...), + ) } // GetTagSignature a specific repository tag determined by its name. It returns 200 together @@ -164,24 +135,10 @@ func (s *TagsService) GetTag(pid any, tag string, options ...RequestOptionFunc) // GitLab API docs: // https://docs.gitlab.com/api/tags/#get-x509-signature-of-a-tag func (s *TagsService) GetTagSignature(pid any, tag string, options ...RequestOptionFunc) (*X509Signature, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/tags/%s/signature", PathEscape(project), url.PathEscape(tag)) - - req, err := s.client.NewRequest(http.MethodGet, u, nil, options) - if err != nil { - return nil, nil, err - } - - var sig *X509Signature - resp, err := s.client.Do(req, &sig) - if err != nil { - return nil, resp, err - } - - return sig, resp, nil + return do[*X509Signature](s.client, + withPath("projects/%s/repository/tags/%s/signature", ProjectID{pid}, tag), + withRequestOpts(options...), + ) } // CreateTagOptions represents the available CreateTag() options. @@ -199,24 +156,12 @@ type CreateTagOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/tags/#create-a-new-tag func (s *TagsService) CreateTag(pid any, opt *CreateTagOptions, options ...RequestOptionFunc) (*Tag, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/repository/tags", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, opt, options) - if err != nil { - return nil, nil, err - } - - t := new(Tag) - resp, err := s.client.Do(req, t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[*Tag](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/repository/tags", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // DeleteTag deletes a tag of a repository with given name. @@ -224,16 +169,10 @@ func (s *TagsService) CreateTag(pid any, opt *CreateTagOptions, options ...Reque // GitLab API docs: // https://docs.gitlab.com/api/tags/#delete-a-tag func (s *TagsService) DeleteTag(pid any, tag string, options ...RequestOptionFunc) (*Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, err - } - u := fmt.Sprintf("projects/%s/repository/tags/%s", PathEscape(project), url.PathEscape(tag)) - - req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodDelete), + withPath("projects/%s/repository/tags/%s", ProjectID{pid}, tag), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/terraform_states.go b/vendor/gitlab.com/gitlab-org/api/client-go/terraform_states.go index 6ca64d2..e2696bd 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/terraform_states.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/terraform_states.go @@ -1,7 +1,6 @@ package gitlab import ( - "bytes" "fmt" "io" "net/http" @@ -152,13 +151,13 @@ func (s *TerraformStatesService) DownloadLatest(pid any, name string, options .. return nil, nil, err } - var b bytes.Buffer - resp, err := s.client.Do(req, &b) + preserver := &bodyPreserver{} + resp, err := s.client.Do(req, preserver) if err != nil { return nil, resp, err } - return &b, resp, nil + return preserver.body, resp, nil } func (s *TerraformStatesService) Download(pid any, name string, serial uint64, options ...RequestOptionFunc) (io.Reader, *Response, error) { @@ -173,13 +172,13 @@ func (s *TerraformStatesService) Download(pid any, name string, serial uint64, o return nil, nil, err } - var b bytes.Buffer - resp, err := s.client.Do(req, &b) + preserver := &bodyPreserver{} + resp, err := s.client.Do(req, preserver) if err != nil { return nil, resp, err } - return &b, resp, nil + return preserver.body, resp, nil } // Delete deletes a single Terraform state diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/todos.go b/vendor/gitlab.com/gitlab-org/api/client-go/todos.go index e0949e6..ab47c78 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/todos.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/todos.go @@ -17,7 +17,6 @@ package gitlab import ( - "fmt" "net/http" "time" ) @@ -139,36 +138,27 @@ type ListTodosOptions struct { } func (s *TodosService) ListTodos(opt *ListTodosOptions, options ...RequestOptionFunc) ([]*Todo, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "todos", opt, options) - if err != nil { - return nil, nil, err - } - - var t []*Todo - resp, err := s.client.Do(req, &t) - if err != nil { - return nil, resp, err - } - - return t, resp, nil + return do[[]*Todo](s.client, + withPath("todos"), + withAPIOpts(opt), + withRequestOpts(options...), + ) } func (s *TodosService) MarkTodoAsDone(id int64, options ...RequestOptionFunc) (*Response, error) { - u := fmt.Sprintf("todos/%d/mark_as_done", id) - - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("todos/%d/mark_as_done", id), + withRequestOpts(options...), + ) + return resp, err } func (s *TodosService) MarkAllTodosAsDone(options ...RequestOptionFunc) (*Response, error) { - req, err := s.client.NewRequest(http.MethodPost, "todos/mark_as_done", nil, options) - if err != nil { - return nil, err - } - - return s.client.Do(req, nil) + _, resp, err := do[none](s.client, + withMethod(http.MethodPost), + withPath("todos/mark_as_done"), + withRequestOpts(options...), + ) + return resp, err } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/validate.go b/vendor/gitlab.com/gitlab-org/api/client-go/validate.go index ee1906b..0aa6e58 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/validate.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/validate.go @@ -16,10 +16,7 @@ package gitlab -import ( - "fmt" - "net/http" -) +import "net/http" type ( ValidateServiceInterface interface { @@ -95,24 +92,12 @@ type ProjectNamespaceLintOptions struct { } func (s *ValidateService) ProjectNamespaceLint(pid any, opt *ProjectNamespaceLintOptions, options ...RequestOptionFunc) (*ProjectLintResult, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/ci/lint", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodPost, u, &opt, options) - if err != nil { - return nil, nil, err - } - - l := new(ProjectLintResult) - resp, err := s.client.Do(req, l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*ProjectLintResult](s.client, + withMethod(http.MethodPost), + withPath("projects/%s/ci/lint", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } // ProjectLintOptions represents the available ProjectLint() options. @@ -128,22 +113,9 @@ type ProjectLintOptions struct { } func (s *ValidateService) ProjectLint(pid any, opt *ProjectLintOptions, options ...RequestOptionFunc) (*ProjectLintResult, *Response, error) { - project, err := parseID(pid) - if err != nil { - return nil, nil, err - } - u := fmt.Sprintf("projects/%s/ci/lint", PathEscape(project)) - - req, err := s.client.NewRequest(http.MethodGet, u, &opt, options) - if err != nil { - return nil, nil, err - } - - l := new(ProjectLintResult) - resp, err := s.client.Do(req, l) - if err != nil { - return nil, resp, err - } - - return l, resp, nil + return do[*ProjectLintResult](s.client, + withPath("projects/%s/ci/lint", ProjectID{pid}), + withAPIOpts(opt), + withRequestOpts(options...), + ) } diff --git a/vendor/gitlab.com/gitlab-org/api/client-go/version.go b/vendor/gitlab.com/gitlab-org/api/client-go/version.go index 90bd255..c548f1c 100644 --- a/vendor/gitlab.com/gitlab-org/api/client-go/version.go +++ b/vendor/gitlab.com/gitlab-org/api/client-go/version.go @@ -16,8 +16,6 @@ package gitlab -import "net/http" - type ( VersionServiceInterface interface { GetVersion(options ...RequestOptionFunc) (*Version, *Response, error) @@ -51,16 +49,8 @@ func (s Version) String() string { // // GitLab API docs: https://docs.gitlab.com/api/version/ func (s *VersionService) GetVersion(options ...RequestOptionFunc) (*Version, *Response, error) { - req, err := s.client.NewRequest(http.MethodGet, "version", nil, options) - if err != nil { - return nil, nil, err - } - - v := new(Version) - resp, err := s.client.Do(req, v) - if err != nil { - return nil, resp, err - } - - return v, resp, nil + return do[*Version](s.client, + withPath("version"), + withRequestOpts(options...), + ) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 4fdc56f..9e47fb0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -12,8 +12,8 @@ github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value -# github.com/google/go-querystring v1.1.0 -## explicit; go 1.10 +# github.com/google/go-querystring v1.2.0 +## explicit; go 1.13 github.com/google/go-querystring/query # github.com/hashicorp/go-cleanhttp v0.5.2 ## explicit; go 1.13 @@ -67,7 +67,7 @@ github.com/onsi/gomega/matchers/support/goraph/edge github.com/onsi/gomega/matchers/support/goraph/node github.com/onsi/gomega/matchers/support/goraph/util github.com/onsi/gomega/types -# gitlab.com/gitlab-org/api/client-go v1.9.1 +# gitlab.com/gitlab-org/api/client-go v1.19.0 ## explicit; go 1.24.0 gitlab.com/gitlab-org/api/client-go # go.yaml.in/yaml/v3 v3.0.4