Loading bulk_imports.go +6 −12 Original line number Diff line number Diff line Loading @@ -62,16 +62,10 @@ type BulkImportStartMigrationResponse struct { } func (b *BulkImportsService) StartMigration(startMigrationOptions *BulkImportStartMigrationOptions, options ...RequestOptionFunc) (*BulkImportStartMigrationResponse, *Response, error) { request, err := b.client.NewRequest(http.MethodPost, "bulk_imports", startMigrationOptions, options) if err != nil { return nil, nil, err } startMigrationResponse := new(BulkImportStartMigrationResponse) response, err := b.client.Do(request, startMigrationResponse) if err != nil { return nil, response, err } return startMigrationResponse, response, nil return do[*BulkImportStartMigrationResponse](b.client, withMethod(http.MethodPost), withPath("bulk_imports"), withAPIOpts(startMigrationOptions), withRequestOpts(options...), ) } group_labels.go +22 −42 Original line number Diff line number Diff line Loading @@ -16,10 +16,7 @@ package gitlab import ( "fmt" "net/http" ) import "net/http" type ( GroupLabelsServiceInterface interface { Loading Loading @@ -125,26 +122,21 @@ type DeleteGroupLabelOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#delete-a-group-label func (s *GroupLabelsService) DeleteGroupLabel(gid any, lid any, opt *DeleteGroupLabelOptions, options ...RequestOptionFunc) (*Response, error) { group, err := parseID(gid) if err != nil { return nil, err } u := fmt.Sprintf("groups/%s/labels", PathEscape(group)) reqOpts := make([]doOption, 0, 4) reqOpts = append(reqOpts, withMethod(http.MethodDelete), withAPIOpts(opt), withRequestOpts(options...), ) if lid != nil { label, err := parseID(lid) if err != nil { return nil, err } u = fmt.Sprintf("groups/%s/labels/%s", PathEscape(group), PathEscape(label)) } req, err := s.client.NewRequest(http.MethodDelete, u, opt, options) if err != nil { return nil, err reqOpts = append(reqOpts, withPath("groups/%s/labels/%s", GroupID{gid}, LabelID{lid})) } else { reqOpts = append(reqOpts, withPath("groups/%s/labels", GroupID{gid})) } return s.client.Do(req, nil) _, resp, err := do[none](s.client, reqOpts...) return resp, err } // UpdateGroupLabelOptions represents the available UpdateGroupLabel() options. Loading @@ -165,32 +157,20 @@ type UpdateGroupLabelOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#update-a-group-label func (s *GroupLabelsService) UpdateGroupLabel(gid any, lid any, opt *UpdateGroupLabelOptions, options ...RequestOptionFunc) (*GroupLabel, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/labels", PathEscape(group)) reqOpts := make([]doOption, 0, 4) reqOpts = append(reqOpts, withMethod(http.MethodPut), withAPIOpts(opt), withRequestOpts(options...), ) if lid != nil { 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.MethodPut, 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 reqOpts = append(reqOpts, withPath("groups/%s/labels/%s", GroupID{gid}, LabelID{lid})) } else { reqOpts = append(reqOpts, withPath("groups/%s/labels", GroupID{gid})) } return l, resp, nil return do[*GroupLabel](s.client, reqOpts...) } // SubscribeToGroupLabel subscribes the authenticated user to a label to receive Loading job_token_scope.go +46 −130 Original line number Diff line number Diff line Loading @@ -14,10 +14,7 @@ package gitlab import ( "fmt" "net/http" ) import "net/http" type ( JobTokenScopeServiceInterface interface { Loading Loading @@ -54,24 +51,10 @@ type JobTokenAccessSettings struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#get-a-projects-cicd-job-token-access-settings func (j *JobTokenScopeService) GetProjectJobTokenAccessSettings(pid any, options ...RequestOptionFunc) (*JobTokenAccessSettings, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodGet, u, nil, options) if err != nil { return nil, nil, err } jt := new(JobTokenAccessSettings) resp, err := j.client.Do(req, jt) if err != nil { return nil, resp, err } return jt, resp, err return do[*JobTokenAccessSettings](j.client, withPath("projects/%s/job_token_scope", ProjectID{pid}), withRequestOpts(options...), ) } // PatchProjectJobTokenAccessSettingsOptions represents the available Loading @@ -88,18 +71,13 @@ type PatchProjectJobTokenAccessSettingsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#patch-a-projects-cicd-job-token-access-settings func (j *JobTokenScopeService) PatchProjectJobTokenAccessSettings(pid any, opt *PatchProjectJobTokenAccessSettingsOptions, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodPatch, u, opt, options) if err != nil { return nil, err } return j.client.Do(req, nil) _, resp, err := do[none](j.client, withMethod(http.MethodPatch), withPath("projects/%s/job_token_scope", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) return resp, err } // JobTokenInboundAllowItem represents a single job token inbound allowlist item. Loading @@ -125,24 +103,11 @@ type GetJobTokenInboundAllowListOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#get-a-projects-cicd-job-token-inbound-allowlist func (j *JobTokenScopeService) GetProjectJobTokenInboundAllowList(pid any, opt *GetJobTokenInboundAllowListOptions, options ...RequestOptionFunc) ([]*Project, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/allowlist`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } var ps []*Project resp, err := j.client.Do(req, &ps) if err != nil { return nil, resp, err } return ps, resp, nil return do[[]*Project](j.client, withPath("projects/%s/job_token_scope/allowlist", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } // JobTokenInboundAllowOptions represents the available Loading @@ -160,24 +125,12 @@ type JobTokenInboundAllowOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#add-a-project-to-a-cicd-job-token-inbound-allowlist func (j *JobTokenScopeService) AddProjectToJobScopeAllowList(pid any, opt *JobTokenInboundAllowOptions, options ...RequestOptionFunc) (*JobTokenInboundAllowItem, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/allowlist`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodPost, u, opt, options) if err != nil { return nil, nil, err } jt := new(JobTokenInboundAllowItem) resp, err := j.client.Do(req, jt) if err != nil { return nil, resp, err } return jt, resp, nil return do[*JobTokenInboundAllowItem](j.client, withMethod(http.MethodPost), withPath("projects/%s/job_token_scope/allowlist", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } // RemoveProjectFromJobScopeAllowList removes a project from a project's job Loading @@ -186,18 +139,12 @@ func (j *JobTokenScopeService) AddProjectToJobScopeAllowList(pid any, opt *JobTo // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#remove-a-project-from-a-cicd-job-token-inbound-allowlist func (j *JobTokenScopeService) RemoveProjectFromJobScopeAllowList(pid any, targetProject int64, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/allowlist/%d`, PathEscape(project), targetProject) req, err := j.client.NewRequest(http.MethodDelete, u, nil, options) if err != nil { return nil, err } return j.client.Do(req, nil) _, resp, err := do[none](j.client, withMethod(http.MethodDelete), withPath("projects/%s/job_token_scope/allowlist/%d", ProjectID{pid}, targetProject), withRequestOpts(options...), ) return resp, err } // JobTokenAllowlistItem represents a single job token allowlist item. Loading @@ -223,24 +170,11 @@ type GetJobTokenAllowlistGroupsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#get-a-projects-cicd-job-token-allowlist-of-groups func (j *JobTokenScopeService) GetJobTokenAllowlistGroups(pid any, opt *GetJobTokenAllowlistGroupsOptions, options ...RequestOptionFunc) ([]*Group, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/groups_allowlist`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } var ps []*Group resp, err := j.client.Do(req, &ps) if err != nil { return nil, resp, err } return ps, resp, nil return do[[]*Group](j.client, withPath("projects/%s/job_token_scope/groups_allowlist", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } // AddGroupToJobTokenAllowlistOptions represents the available Loading @@ -258,24 +192,12 @@ type AddGroupToJobTokenAllowlistOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#add-a-group-to-a-cicd-job-token-allowlist func (j *JobTokenScopeService) AddGroupToJobTokenAllowlist(pid any, opt *AddGroupToJobTokenAllowlistOptions, options ...RequestOptionFunc) (*JobTokenAllowlistItem, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/groups_allowlist`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodPost, u, opt, options) if err != nil { return nil, nil, err } jt := new(JobTokenAllowlistItem) resp, err := j.client.Do(req, jt) if err != nil { return nil, resp, err } return jt, resp, nil return do[*JobTokenAllowlistItem](j.client, withMethod(http.MethodPost), withPath("projects/%s/job_token_scope/groups_allowlist", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } // RemoveGroupFromJobTokenAllowlist removes a group from a project's job Loading @@ -284,16 +206,10 @@ func (j *JobTokenScopeService) AddGroupToJobTokenAllowlist(pid any, opt *AddGrou // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#remove-a-group-from-a-cicd-job-token-allowlist func (j *JobTokenScopeService) RemoveGroupFromJobTokenAllowlist(pid any, targetGroup int64, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/groups_allowlist/%d`, PathEscape(project), targetGroup) req, err := j.client.NewRequest(http.MethodDelete, u, nil, options) if err != nil { return nil, err } return j.client.Do(req, nil) _, resp, err := do[none](j.client, withMethod(http.MethodDelete), withPath("projects/%s/job_token_scope/groups_allowlist/%d", ProjectID{pid}, targetGroup), withRequestOpts(options...), ) return resp, err } labels.go +21 −39 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package gitlab import ( "encoding/json" "fmt" "net/http" ) Loading Loading @@ -151,26 +150,21 @@ type DeleteLabelOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/labels/#delete-a-label func (s *LabelsService) DeleteLabel(pid any, lid any, opt *DeleteLabelOptions, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/labels", PathEscape(project)) reqOpts := make([]doOption, 0, 4) reqOpts = append(reqOpts, withMethod(http.MethodDelete), withAPIOpts(opt), withRequestOpts(options...), ) if lid != nil { label, err := parseID(lid) if err != nil { return nil, err } u = fmt.Sprintf("projects/%s/labels/%s", PathEscape(project), PathEscape(label)) reqOpts = append(reqOpts, withPath("projects/%s/labels/%s", ProjectID{pid}, LabelID{lid})) } else { reqOpts = append(reqOpts, withPath("projects/%s/labels", ProjectID{pid})) } 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, reqOpts...) return resp, err } // UpdateLabelOptions represents the available UpdateLabel() options. Loading @@ -189,32 +183,20 @@ type UpdateLabelOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/labels/#edit-an-existing-label func (s *LabelsService) UpdateLabel(pid any, lid any, opt *UpdateLabelOptions, options ...RequestOptionFunc) (*Label, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/labels", PathEscape(project)) reqOpts := make([]doOption, 0, 4) reqOpts = append(reqOpts, withMethod(http.MethodPut), withAPIOpts(opt), withRequestOpts(options...), ) if lid != nil { 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.MethodPut, 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 reqOpts = append(reqOpts, withPath("projects/%s/labels/%s", ProjectID{pid}, LabelID{lid})) } else { reqOpts = append(reqOpts, withPath("projects/%s/labels", ProjectID{pid})) } return l, resp, nil return do[*Label](s.client, reqOpts...) } // SubscribeToLabel subscribes the authenticated user to a label to receive Loading project_iterations.go +6 −23 Original line number Diff line number Diff line Loading @@ -16,11 +16,7 @@ package gitlab import ( "fmt" "net/http" "time" ) import "time" type ( ProjectIterationsServiceInterface interface { Loading Loading @@ -77,22 +73,9 @@ type ListProjectIterationsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/iterations/#list-project-iterations func (i *ProjectIterationsService) ListProjectIterations(pid any, opt *ListProjectIterationsOptions, options ...RequestOptionFunc) ([]*ProjectIteration, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/iterations", PathEscape(project)) req, err := i.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } var pis []*ProjectIteration resp, err := i.client.Do(req, &pis) if err != nil { return nil, resp, err } return pis, resp, nil return do[[]*ProjectIteration](i.client, withPath("projects/%s/iterations", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } Loading
bulk_imports.go +6 −12 Original line number Diff line number Diff line Loading @@ -62,16 +62,10 @@ type BulkImportStartMigrationResponse struct { } func (b *BulkImportsService) StartMigration(startMigrationOptions *BulkImportStartMigrationOptions, options ...RequestOptionFunc) (*BulkImportStartMigrationResponse, *Response, error) { request, err := b.client.NewRequest(http.MethodPost, "bulk_imports", startMigrationOptions, options) if err != nil { return nil, nil, err } startMigrationResponse := new(BulkImportStartMigrationResponse) response, err := b.client.Do(request, startMigrationResponse) if err != nil { return nil, response, err } return startMigrationResponse, response, nil return do[*BulkImportStartMigrationResponse](b.client, withMethod(http.MethodPost), withPath("bulk_imports"), withAPIOpts(startMigrationOptions), withRequestOpts(options...), ) }
group_labels.go +22 −42 Original line number Diff line number Diff line Loading @@ -16,10 +16,7 @@ package gitlab import ( "fmt" "net/http" ) import "net/http" type ( GroupLabelsServiceInterface interface { Loading Loading @@ -125,26 +122,21 @@ type DeleteGroupLabelOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#delete-a-group-label func (s *GroupLabelsService) DeleteGroupLabel(gid any, lid any, opt *DeleteGroupLabelOptions, options ...RequestOptionFunc) (*Response, error) { group, err := parseID(gid) if err != nil { return nil, err } u := fmt.Sprintf("groups/%s/labels", PathEscape(group)) reqOpts := make([]doOption, 0, 4) reqOpts = append(reqOpts, withMethod(http.MethodDelete), withAPIOpts(opt), withRequestOpts(options...), ) if lid != nil { label, err := parseID(lid) if err != nil { return nil, err } u = fmt.Sprintf("groups/%s/labels/%s", PathEscape(group), PathEscape(label)) } req, err := s.client.NewRequest(http.MethodDelete, u, opt, options) if err != nil { return nil, err reqOpts = append(reqOpts, withPath("groups/%s/labels/%s", GroupID{gid}, LabelID{lid})) } else { reqOpts = append(reqOpts, withPath("groups/%s/labels", GroupID{gid})) } return s.client.Do(req, nil) _, resp, err := do[none](s.client, reqOpts...) return resp, err } // UpdateGroupLabelOptions represents the available UpdateGroupLabel() options. Loading @@ -165,32 +157,20 @@ type UpdateGroupLabelOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/group_labels/#update-a-group-label func (s *GroupLabelsService) UpdateGroupLabel(gid any, lid any, opt *UpdateGroupLabelOptions, options ...RequestOptionFunc) (*GroupLabel, *Response, error) { group, err := parseID(gid) if err != nil { return nil, nil, err } u := fmt.Sprintf("groups/%s/labels", PathEscape(group)) reqOpts := make([]doOption, 0, 4) reqOpts = append(reqOpts, withMethod(http.MethodPut), withAPIOpts(opt), withRequestOpts(options...), ) if lid != nil { 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.MethodPut, 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 reqOpts = append(reqOpts, withPath("groups/%s/labels/%s", GroupID{gid}, LabelID{lid})) } else { reqOpts = append(reqOpts, withPath("groups/%s/labels", GroupID{gid})) } return l, resp, nil return do[*GroupLabel](s.client, reqOpts...) } // SubscribeToGroupLabel subscribes the authenticated user to a label to receive Loading
job_token_scope.go +46 −130 Original line number Diff line number Diff line Loading @@ -14,10 +14,7 @@ package gitlab import ( "fmt" "net/http" ) import "net/http" type ( JobTokenScopeServiceInterface interface { Loading Loading @@ -54,24 +51,10 @@ type JobTokenAccessSettings struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#get-a-projects-cicd-job-token-access-settings func (j *JobTokenScopeService) GetProjectJobTokenAccessSettings(pid any, options ...RequestOptionFunc) (*JobTokenAccessSettings, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodGet, u, nil, options) if err != nil { return nil, nil, err } jt := new(JobTokenAccessSettings) resp, err := j.client.Do(req, jt) if err != nil { return nil, resp, err } return jt, resp, err return do[*JobTokenAccessSettings](j.client, withPath("projects/%s/job_token_scope", ProjectID{pid}), withRequestOpts(options...), ) } // PatchProjectJobTokenAccessSettingsOptions represents the available Loading @@ -88,18 +71,13 @@ type PatchProjectJobTokenAccessSettingsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#patch-a-projects-cicd-job-token-access-settings func (j *JobTokenScopeService) PatchProjectJobTokenAccessSettings(pid any, opt *PatchProjectJobTokenAccessSettingsOptions, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodPatch, u, opt, options) if err != nil { return nil, err } return j.client.Do(req, nil) _, resp, err := do[none](j.client, withMethod(http.MethodPatch), withPath("projects/%s/job_token_scope", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) return resp, err } // JobTokenInboundAllowItem represents a single job token inbound allowlist item. Loading @@ -125,24 +103,11 @@ type GetJobTokenInboundAllowListOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#get-a-projects-cicd-job-token-inbound-allowlist func (j *JobTokenScopeService) GetProjectJobTokenInboundAllowList(pid any, opt *GetJobTokenInboundAllowListOptions, options ...RequestOptionFunc) ([]*Project, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/allowlist`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } var ps []*Project resp, err := j.client.Do(req, &ps) if err != nil { return nil, resp, err } return ps, resp, nil return do[[]*Project](j.client, withPath("projects/%s/job_token_scope/allowlist", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } // JobTokenInboundAllowOptions represents the available Loading @@ -160,24 +125,12 @@ type JobTokenInboundAllowOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#add-a-project-to-a-cicd-job-token-inbound-allowlist func (j *JobTokenScopeService) AddProjectToJobScopeAllowList(pid any, opt *JobTokenInboundAllowOptions, options ...RequestOptionFunc) (*JobTokenInboundAllowItem, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/allowlist`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodPost, u, opt, options) if err != nil { return nil, nil, err } jt := new(JobTokenInboundAllowItem) resp, err := j.client.Do(req, jt) if err != nil { return nil, resp, err } return jt, resp, nil return do[*JobTokenInboundAllowItem](j.client, withMethod(http.MethodPost), withPath("projects/%s/job_token_scope/allowlist", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } // RemoveProjectFromJobScopeAllowList removes a project from a project's job Loading @@ -186,18 +139,12 @@ func (j *JobTokenScopeService) AddProjectToJobScopeAllowList(pid any, opt *JobTo // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#remove-a-project-from-a-cicd-job-token-inbound-allowlist func (j *JobTokenScopeService) RemoveProjectFromJobScopeAllowList(pid any, targetProject int64, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/allowlist/%d`, PathEscape(project), targetProject) req, err := j.client.NewRequest(http.MethodDelete, u, nil, options) if err != nil { return nil, err } return j.client.Do(req, nil) _, resp, err := do[none](j.client, withMethod(http.MethodDelete), withPath("projects/%s/job_token_scope/allowlist/%d", ProjectID{pid}, targetProject), withRequestOpts(options...), ) return resp, err } // JobTokenAllowlistItem represents a single job token allowlist item. Loading @@ -223,24 +170,11 @@ type GetJobTokenAllowlistGroupsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#get-a-projects-cicd-job-token-allowlist-of-groups func (j *JobTokenScopeService) GetJobTokenAllowlistGroups(pid any, opt *GetJobTokenAllowlistGroupsOptions, options ...RequestOptionFunc) ([]*Group, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/groups_allowlist`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } var ps []*Group resp, err := j.client.Do(req, &ps) if err != nil { return nil, resp, err } return ps, resp, nil return do[[]*Group](j.client, withPath("projects/%s/job_token_scope/groups_allowlist", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } // AddGroupToJobTokenAllowlistOptions represents the available Loading @@ -258,24 +192,12 @@ type AddGroupToJobTokenAllowlistOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#add-a-group-to-a-cicd-job-token-allowlist func (j *JobTokenScopeService) AddGroupToJobTokenAllowlist(pid any, opt *AddGroupToJobTokenAllowlistOptions, options ...RequestOptionFunc) (*JobTokenAllowlistItem, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/groups_allowlist`, PathEscape(project)) req, err := j.client.NewRequest(http.MethodPost, u, opt, options) if err != nil { return nil, nil, err } jt := new(JobTokenAllowlistItem) resp, err := j.client.Do(req, jt) if err != nil { return nil, resp, err } return jt, resp, nil return do[*JobTokenAllowlistItem](j.client, withMethod(http.MethodPost), withPath("projects/%s/job_token_scope/groups_allowlist", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) } // RemoveGroupFromJobTokenAllowlist removes a group from a project's job Loading @@ -284,16 +206,10 @@ func (j *JobTokenScopeService) AddGroupToJobTokenAllowlist(pid any, opt *AddGrou // GitLab API docs: // https://docs.gitlab.com/api/project_job_token_scopes/#remove-a-group-from-a-cicd-job-token-allowlist func (j *JobTokenScopeService) RemoveGroupFromJobTokenAllowlist(pid any, targetGroup int64, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf(`projects/%s/job_token_scope/groups_allowlist/%d`, PathEscape(project), targetGroup) req, err := j.client.NewRequest(http.MethodDelete, u, nil, options) if err != nil { return nil, err } return j.client.Do(req, nil) _, resp, err := do[none](j.client, withMethod(http.MethodDelete), withPath("projects/%s/job_token_scope/groups_allowlist/%d", ProjectID{pid}, targetGroup), withRequestOpts(options...), ) return resp, err }
labels.go +21 −39 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package gitlab import ( "encoding/json" "fmt" "net/http" ) Loading Loading @@ -151,26 +150,21 @@ type DeleteLabelOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/labels/#delete-a-label func (s *LabelsService) DeleteLabel(pid any, lid any, opt *DeleteLabelOptions, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { return nil, err } u := fmt.Sprintf("projects/%s/labels", PathEscape(project)) reqOpts := make([]doOption, 0, 4) reqOpts = append(reqOpts, withMethod(http.MethodDelete), withAPIOpts(opt), withRequestOpts(options...), ) if lid != nil { label, err := parseID(lid) if err != nil { return nil, err } u = fmt.Sprintf("projects/%s/labels/%s", PathEscape(project), PathEscape(label)) reqOpts = append(reqOpts, withPath("projects/%s/labels/%s", ProjectID{pid}, LabelID{lid})) } else { reqOpts = append(reqOpts, withPath("projects/%s/labels", ProjectID{pid})) } 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, reqOpts...) return resp, err } // UpdateLabelOptions represents the available UpdateLabel() options. Loading @@ -189,32 +183,20 @@ type UpdateLabelOptions struct { // // GitLab API docs: https://docs.gitlab.com/api/labels/#edit-an-existing-label func (s *LabelsService) UpdateLabel(pid any, lid any, opt *UpdateLabelOptions, options ...RequestOptionFunc) (*Label, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/labels", PathEscape(project)) reqOpts := make([]doOption, 0, 4) reqOpts = append(reqOpts, withMethod(http.MethodPut), withAPIOpts(opt), withRequestOpts(options...), ) if lid != nil { 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.MethodPut, 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 reqOpts = append(reqOpts, withPath("projects/%s/labels/%s", ProjectID{pid}, LabelID{lid})) } else { reqOpts = append(reqOpts, withPath("projects/%s/labels", ProjectID{pid})) } return l, resp, nil return do[*Label](s.client, reqOpts...) } // SubscribeToLabel subscribes the authenticated user to a label to receive Loading
project_iterations.go +6 −23 Original line number Diff line number Diff line Loading @@ -16,11 +16,7 @@ package gitlab import ( "fmt" "net/http" "time" ) import "time" type ( ProjectIterationsServiceInterface interface { Loading Loading @@ -77,22 +73,9 @@ type ListProjectIterationsOptions struct { // GitLab API docs: // https://docs.gitlab.com/api/iterations/#list-project-iterations func (i *ProjectIterationsService) ListProjectIterations(pid any, opt *ListProjectIterationsOptions, options ...RequestOptionFunc) ([]*ProjectIteration, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/iterations", PathEscape(project)) req, err := i.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } var pis []*ProjectIteration resp, err := i.client.Do(req, &pis) if err != nil { return nil, resp, err } return pis, resp, nil return do[[]*ProjectIteration](i.client, withPath("projects/%s/iterations", ProjectID{pid}), withAPIOpts(opt), withRequestOpts(options...), ) }