Commit 23e0590c authored by Florian Forster's avatar Florian Forster
Browse files

Merge branch 'refac7' into 'main'

refactor: moved comments to interface 7

Closes #2210

See merge request !2715
parents ccb04ce7 a93cc86c
Loading
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -18,8 +18,21 @@ import "net/http"

type (
	GroupActivityAnalyticsServiceInterface interface {
		// GetRecentlyCreatedIssuesCount gets the count of recently created issues for a group.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/group_activity_analytics/#get-count-of-recently-created-issues-for-group
		GetRecentlyCreatedIssuesCount(opt *GetRecentlyCreatedIssuesCountOptions, options ...RequestOptionFunc) (*IssuesCount, *Response, error)
		// GetRecentlyCreatedMergeRequestsCount gets the count of recently created merge
		// requests for a group.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/group_activity_analytics/#get-count-of-recently-created-merge-requests-for-group
		GetRecentlyCreatedMergeRequestsCount(opt *GetRecentlyCreatedMergeRequestsCountOptions, options ...RequestOptionFunc) (*MergeRequestsCount, *Response, error)
		// GetRecentlyAddedMembersCount gets the count of recently added members to a group.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/group_activity_analytics/#get-count-of-members-recently-added-to-group
		GetRecentlyAddedMembersCount(opt *GetRecentlyAddedMembersCountOptions, options ...RequestOptionFunc) (*NewMembersCount, *Response, error)
	}

@@ -51,10 +64,6 @@ type GetRecentlyCreatedIssuesCountOptions struct {
	GroupPath string `url:"group_path" json:"group_path"`
}

// GetRecentlyCreatedIssuesCount gets the count of recently created issues for a group.
//
// GitLab API docs:
// https://docs.gitlab.com/api/group_activity_analytics/#get-count-of-recently-created-issues-for-group
func (s *GroupActivityAnalyticsService) GetRecentlyCreatedIssuesCount(opt *GetRecentlyCreatedIssuesCountOptions, options ...RequestOptionFunc) (*IssuesCount, *Response, error) {
	return do[*IssuesCount](s.client,
		withMethod(http.MethodGet),
@@ -82,11 +91,6 @@ type GetRecentlyCreatedMergeRequestsCountOptions struct {
	GroupPath string `url:"group_path" json:"group_path"`
}

// GetRecentlyCreatedMergeRequestsCount gets the count of recently created merge
// requests for a group.
//
// GitLab API docs:
// https://docs.gitlab.com/api/group_activity_analytics/#get-count-of-recently-created-merge-requests-for-group
func (s *GroupActivityAnalyticsService) GetRecentlyCreatedMergeRequestsCount(opt *GetRecentlyCreatedMergeRequestsCountOptions, options ...RequestOptionFunc) (*MergeRequestsCount, *Response, error) {
	return do[*MergeRequestsCount](s.client,
		withMethod(http.MethodGet),
@@ -113,10 +117,6 @@ type GetRecentlyAddedMembersCountOptions struct {
	GroupPath string `url:"group_path" json:"group_path"`
}

// GetRecentlyAddedMembersCount gets the count of recently added members to a group.
//
// GitLab API docs:
// https://docs.gitlab.com/api/group_activity_analytics/#get-count-of-members-recently-added-to-group
func (s *GroupActivityAnalyticsService) GetRecentlyAddedMembersCount(opt *GetRecentlyAddedMembersCountOptions, options ...RequestOptionFunc) (*NewMembersCount, *Response, error) {
	return do[*NewMembersCount](s.client,
		withMethod(http.MethodGet),
+22 −22
Original line number Diff line number Diff line
@@ -22,10 +22,32 @@ import (

type (
	GroupMarkdownUploadsServiceInterface interface {
		// ListGroupMarkdownUploads gets all markdown uploads for a group.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/group_markdown_uploads/#list-uploads
		ListGroupMarkdownUploads(gid any, opt *ListMarkdownUploadsOptions, options ...RequestOptionFunc) ([]*GroupMarkdownUpload, *Response, error)
		// DownloadGroupMarkdownUploadByID downloads a specific upload by ID.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/group_markdown_uploads/#download-an-uploaded-file-by-id
		DownloadGroupMarkdownUploadByID(gid any, uploadID int64, options ...RequestOptionFunc) (io.Reader, *Response, error)
		// DownloadGroupMarkdownUploadBySecretAndFilename downloads a specific upload
		// by secret and filename.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/group_markdown_uploads/#download-an-uploaded-file-by-secret-and-filename
		DownloadGroupMarkdownUploadBySecretAndFilename(gid any, secret string, filename string, options ...RequestOptionFunc) (io.Reader, *Response, error)
		// DeleteGroupMarkdownUploadByID deletes an upload by ID.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/group_markdown_uploads/#delete-an-uploaded-file-by-id
		DeleteGroupMarkdownUploadByID(gid any, uploadID int64, options ...RequestOptionFunc) (*Response, error)
		// DeleteGroupMarkdownUploadBySecretAndFilename deletes an upload
		// by secret and filename.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/group_markdown_uploads/#delete-an-uploaded-file-by-secret-and-filename
		DeleteGroupMarkdownUploadBySecretAndFilename(gid any, secret string, filename string, options ...RequestOptionFunc) (*Response, error)
	}

@@ -46,18 +68,10 @@ type (
	GroupMarkdownUpload = MarkdownUpload
)

// ListGroupMarkdownUploads gets all markdown uploads for a group.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/group_markdown_uploads/#list-uploads
func (s *GroupMarkdownUploadsService) ListGroupMarkdownUploads(gid any, opt *ListMarkdownUploadsOptions, options ...RequestOptionFunc) ([]*GroupMarkdownUpload, *Response, error) {
	return listMarkdownUploads[GroupMarkdownUpload](s.client, GroupResource, GroupID{gid}, opt, options)
}

// DownloadGroupMarkdownUploadByID downloads a specific upload by ID.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/group_markdown_uploads/#download-an-uploaded-file-by-id
func (s *GroupMarkdownUploadsService) DownloadGroupMarkdownUploadByID(gid any, uploadID int64, options ...RequestOptionFunc) (io.Reader, *Response, error) {
	buffer, resp, err := downloadMarkdownUploadByID(s.client, GroupResource, GroupID{gid}, uploadID, options)
	if err != nil {
@@ -66,11 +80,6 @@ func (s *GroupMarkdownUploadsService) DownloadGroupMarkdownUploadByID(gid any, u
	return buffer, resp, nil
}

// DownloadGroupMarkdownUploadBySecretAndFilename downloads a specific upload
// by secret and filename.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/group_markdown_uploads/#download-an-uploaded-file-by-secret-and-filename
func (s *GroupMarkdownUploadsService) DownloadGroupMarkdownUploadBySecretAndFilename(gid any, secret string, filename string, options ...RequestOptionFunc) (io.Reader, *Response, error) {
	buffer, resp, err := downloadMarkdownUploadBySecretAndFilename(s.client, GroupResource, GroupID{gid}, secret, filename, options)
	if err != nil {
@@ -79,19 +88,10 @@ func (s *GroupMarkdownUploadsService) DownloadGroupMarkdownUploadBySecretAndFile
	return buffer, resp, nil
}

// DeleteGroupMarkdownUploadByID deletes an upload by ID.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/group_markdown_uploads/#delete-an-uploaded-file-by-id
func (s *GroupMarkdownUploadsService) DeleteGroupMarkdownUploadByID(gid any, uploadID int64, options ...RequestOptionFunc) (*Response, error) {
	return deleteMarkdownUploadByID(s.client, GroupResource, GroupID{gid}, uploadID, options)
}

// DeleteGroupMarkdownUploadBySecretAndFilename deletes an upload
// by secret and filename.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/group_markdown_uploads/#delete-an-uploaded-file-by-secret-and-filename
func (s *GroupMarkdownUploadsService) DeleteGroupMarkdownUploadBySecretAndFilename(gid any, secret string, filename string, options ...RequestOptionFunc) (*Response, error) {
	return deleteMarkdownUploadBySecretAndFilename(s.client, GroupResource, GroupID{gid}, secret, filename, options)
}
+20 −21
Original line number Diff line number Diff line
@@ -23,10 +23,30 @@ import (

type (
	InstanceVariablesServiceInterface interface {
		// ListVariables gets a list of all variables for an instance.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/instance_level_ci_variables/#list-all-instance-variables
		ListVariables(opt *ListInstanceVariablesOptions, options ...RequestOptionFunc) ([]*InstanceVariable, *Response, error)
		// GetVariable gets a variable.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/instance_level_ci_variables/#show-instance-variable-details
		GetVariable(key string, options ...RequestOptionFunc) (*InstanceVariable, *Response, error)
		// CreateVariable creates a new instance level CI variable.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/instance_level_ci_variables/#create-instance-variable
		CreateVariable(opt *CreateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error)
		// UpdateVariable updates an existing instance level CI variable.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/instance_level_ci_variables/#update-instance-variable
		UpdateVariable(key string, opt *UpdateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error)
		// RemoveVariable removes an instance level CI variable.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/instance_level_ci_variables/#remove-instance-variable
		RemoveVariable(key string, options ...RequestOptionFunc) (*Response, error)
	}

@@ -69,10 +89,6 @@ type ListInstanceVariablesOptions struct {
	ListOptions
}

// ListVariables gets a list of all variables for an instance.
//
// GitLab API docs:
// https://docs.gitlab.com/api/instance_level_ci_variables/#list-all-instance-variables
func (s *InstanceVariablesService) ListVariables(opt *ListInstanceVariablesOptions, options ...RequestOptionFunc) ([]*InstanceVariable, *Response, error) {
	return do[[]*InstanceVariable](s.client,
		withPath("admin/ci/variables"),
@@ -81,10 +97,6 @@ func (s *InstanceVariablesService) ListVariables(opt *ListInstanceVariablesOptio
	)
}

// GetVariable gets a variable.
//
// GitLab API docs:
// https://docs.gitlab.com/api/instance_level_ci_variables/#show-instance-variable-details
func (s *InstanceVariablesService) GetVariable(key string, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
	return do[*InstanceVariable](s.client,
		withPath("admin/ci/variables/%s", url.PathEscape(key)),
@@ -107,10 +119,6 @@ type CreateInstanceVariableOptions struct {
	VariableType *VariableTypeValue `url:"variable_type,omitempty" json:"variable_type,omitempty"`
}

// CreateVariable creates a new instance level CI variable.
//
// GitLab API docs:
// https://docs.gitlab.com/api/instance_level_ci_variables/#create-instance-variable
func (s *InstanceVariablesService) CreateVariable(opt *CreateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
	return do[*InstanceVariable](s.client,
		withMethod(http.MethodPost),
@@ -134,11 +142,6 @@ type UpdateInstanceVariableOptions struct {
	VariableType *VariableTypeValue `url:"variable_type,omitempty" json:"variable_type,omitempty"`
}

// UpdateVariable updates the position of an existing
// instance level CI variable.
//
// GitLab API docs:
// https://docs.gitlab.com/api/instance_level_ci_variables/#update-instance-variable
func (s *InstanceVariablesService) UpdateVariable(key string, opt *UpdateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) {
	return do[*InstanceVariable](s.client,
		withMethod(http.MethodPut),
@@ -148,10 +151,6 @@ func (s *InstanceVariablesService) UpdateVariable(key string, opt *UpdateInstanc
	)
}

// RemoveVariable removes an instance level CI variable.
//
// GitLab API docs:
// https://docs.gitlab.com/api/instance_level_ci_variables/#remove-instance-variable
func (s *InstanceVariablesService) RemoveVariable(key string, options ...RequestOptionFunc) (*Response, error) {
	_, resp, err := do[none](s.client,
		withMethod(http.MethodDelete),
+26 −26
Original line number Diff line number Diff line
@@ -24,11 +24,37 @@ import (

type (
	ProjectMarkdownUploadsServiceInterface interface {
		// UploadProjectMarkdown uploads a markdown file to a project.
		//
		// GitLab API docs:
		// https://docs.gitlab.com/api/project_markdown_uploads/#upload-a-file
		UploadProjectMarkdown(pid any, content io.Reader, filename string, options ...RequestOptionFunc) (*ProjectMarkdownUploadedFile, *Response, error)
		// ListProjectMarkdownUploads gets all markdown uploads for a project.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/project_markdown_uploads/#list-uploads
		ListProjectMarkdownUploads(pid any, options ...RequestOptionFunc) ([]*ProjectMarkdownUpload, *Response, error)
		// DownloadProjectMarkdownUploadByID downloads a specific upload by ID.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/project_markdown_uploads/#download-an-uploaded-file-by-id
		DownloadProjectMarkdownUploadByID(pid any, uploadID int64, options ...RequestOptionFunc) ([]byte, *Response, error)
		// DownloadProjectMarkdownUploadBySecretAndFilename downloads a specific upload
		// by secret and filename.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/project_markdown_uploads/#download-an-uploaded-file-by-secret-and-filename
		DownloadProjectMarkdownUploadBySecretAndFilename(pid any, secret string, filename string, options ...RequestOptionFunc) ([]byte, *Response, error)
		// DeleteProjectMarkdownUploadByID deletes an upload by ID.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/project_markdown_uploads/#delete-an-uploaded-file-by-id
		DeleteProjectMarkdownUploadByID(pid any, uploadID int64, options ...RequestOptionFunc) (*Response, error)
		// DeleteProjectMarkdownUploadBySecretAndFilename deletes an upload
		// by secret and filename.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/project_markdown_uploads/#delete-an-uploaded-file-by-secret-and-filename
		DeleteProjectMarkdownUploadBySecretAndFilename(pid any, secret string, filename string, options ...RequestOptionFunc) (*Response, error)
	}

@@ -50,10 +76,6 @@ type (
	ProjectMarkdownUploadedFile = MarkdownUploadedFile
)

// UploadProjectMarkdown uploads a markdown file to a project.
//
// GitLab docs:
// https://docs.gitlab.com/api/project_markdown_uploads/#upload-a-file
func (s *ProjectMarkdownUploadsService) UploadProjectMarkdown(pid any, content io.Reader, filename string, options ...RequestOptionFunc) (*ProjectMarkdownUploadedFile, *Response, error) {
	project, err := parseID(pid)
	if err != nil {
@@ -83,18 +105,10 @@ func (s *ProjectMarkdownUploadsService) UploadProjectMarkdown(pid any, content i
	return f, resp, nil
}

// ListProjectMarkdownUploads gets all markdown uploads for a project.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/project_markdown_uploads/#list-uploads
func (s *ProjectMarkdownUploadsService) ListProjectMarkdownUploads(pid any, options ...RequestOptionFunc) ([]*ProjectMarkdownUpload, *Response, error) {
	return listMarkdownUploads[ProjectMarkdownUpload](s.client, ProjectResource, ProjectID{pid}, nil, options)
}

// DownloadProjectMarkdownUploadByID downloads a specific upload by ID.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/project_markdown_uploads/#download-an-uploaded-file-by-id
func (s *ProjectMarkdownUploadsService) DownloadProjectMarkdownUploadByID(pid any, uploadID int64, options ...RequestOptionFunc) ([]byte, *Response, error) {
	buffer, resp, err := downloadMarkdownUploadByID(s.client, ProjectResource, ProjectID{pid}, uploadID, options)
	if err != nil {
@@ -103,11 +117,6 @@ func (s *ProjectMarkdownUploadsService) DownloadProjectMarkdownUploadByID(pid an
	return buffer.Bytes(), resp, nil
}

// DownloadProjectMarkdownUploadBySecretAndFilename downloads a specific upload
// by secret and filename.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/project_markdown_uploads/#download-an-uploaded-file-by-secret-and-filename
func (s *ProjectMarkdownUploadsService) DownloadProjectMarkdownUploadBySecretAndFilename(pid any, secret string, filename string, options ...RequestOptionFunc) ([]byte, *Response, error) {
	buffer, resp, err := downloadMarkdownUploadBySecretAndFilename(s.client, ProjectResource, ProjectID{pid}, secret, filename, options)
	if err != nil {
@@ -116,19 +125,10 @@ func (s *ProjectMarkdownUploadsService) DownloadProjectMarkdownUploadBySecretAnd
	return buffer.Bytes(), resp, nil
}

// DeleteProjectMarkdownUploadByID deletes an upload by ID.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/project_markdown_uploads/#delete-an-uploaded-file-by-id
func (s *ProjectMarkdownUploadsService) DeleteProjectMarkdownUploadByID(pid any, uploadID int64, options ...RequestOptionFunc) (*Response, error) {
	return deleteMarkdownUploadByID(s.client, ProjectResource, ProjectID{pid}, uploadID, options)
}

// DeleteProjectMarkdownUploadBySecretAndFilename deletes an upload
// by secret and filename.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/project_markdown_uploads/#delete-an-uploaded-file-by-secret-and-filename
func (s *ProjectMarkdownUploadsService) DeleteProjectMarkdownUploadBySecretAndFilename(pid any, secret string, filename string, options ...RequestOptionFunc) (*Response, error) {
	return deleteMarkdownUploadBySecretAndFilename(s.client, ProjectResource, ProjectID{pid}, secret, filename, options)
}
+9 −9
Original line number Diff line number Diff line
@@ -22,7 +22,16 @@ import (

type (
	ProjectSecuritySettingsServiceInterface interface {
		// ListProjectSecuritySettings lists all of a project's security settings.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/project_security_settings/#list-project-security-settings
		ListProjectSecuritySettings(pid any, options ...RequestOptionFunc) (*ProjectSecuritySettings, *Response, error)
		// UpdateSecretPushProtectionEnabledSetting updates the secret_push_protection_enabled
		// setting for a project to the provided value.
		//
		// GitLab API Docs:
		// https://docs.gitlab.com/api/project_security_settings/#update-secret_push_protection_enabled-setting
		UpdateSecretPushProtectionEnabledSetting(pid any, opt UpdateProjectSecuritySettingsOptions, options ...RequestOptionFunc) (*ProjectSecuritySettings, *Response, error)
	}

@@ -63,10 +72,6 @@ func (s ProjectSecuritySettings) String() string {
	return Stringify(s)
}

// ListProjectSecuritySettings lists all of a project's security settings.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/project_security_settings/#list-project-security-settings
func (s *ProjectSecuritySettingsService) ListProjectSecuritySettings(pid any, options ...RequestOptionFunc) (*ProjectSecuritySettings, *Response, error) {
	return do[*ProjectSecuritySettings](s.client,
		withPath("projects/%s/security_settings", ProjectID{pid}),
@@ -83,11 +88,6 @@ type UpdateProjectSecuritySettingsOptions struct {
	SecretPushProtectionEnabled *bool `url:"secret_push_protection_enabled,omitempty" json:"secret_push_protection_enabled,omitempty"`
}

// UpdateSecretPushProtectionEnabledSetting updates the secret_push_protection_enabled
// setting for the all projects in a project to the provided value.
//
// GitLab API Docs:
// https://docs.gitlab.com/api/project_security_settings/#update-secret_push_protection_enabled-setting
func (s *ProjectSecuritySettingsService) UpdateSecretPushProtectionEnabledSetting(pid any, opt UpdateProjectSecuritySettingsOptions, options ...RequestOptionFunc) (*ProjectSecuritySettings, *Response, error) {
	return do[*ProjectSecuritySettings](s.client,
		withMethod(http.MethodPut),