From c0650b2b633797300f3036df172d0bfbb440915d Mon Sep 17 00:00:00 2001 From: zubeen Date: Tue, 28 Oct 2025 23:20:38 +0530 Subject: [PATCH 1/3] refactor: moved comments to interface --- enterprise_users.go | 37 +++++++++++++++------------- environments.go | 59 ++++++++++++++++++++++++--------------------- epic_issues.go | 41 +++++++++++++++---------------- epics.go | 51 +++++++++++++++++++-------------------- 4 files changed, 97 insertions(+), 91 deletions(-) diff --git a/enterprise_users.go b/enterprise_users.go index cd1886d7..b8c9e99d 100644 --- a/enterprise_users.go +++ b/enterprise_users.go @@ -22,9 +22,29 @@ import ( type ( EnterpriseUsersServiceInterface interface { + // ListEnterpriseUsers lists all enterprise users for a given top-level group. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_enterprise_users/#list-all-enterprise-users ListEnterpriseUsers(gid any, opt *ListEnterpriseUsersOptions, options ...RequestOptionFunc) ([]*User, *Response, error) + + // GetEnterpriseUser gets details on a specified enterprise user. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_enterprise_users/#get-details-on-an-enterprise-user GetEnterpriseUser(gid any, uid int, options ...RequestOptionFunc) (*User, *Response, error) + + // Disable2FAForEnterpriseUser disables two-factor authentication (2FA) for a + // specified enterprise user. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_enterprise_users/#disable-two-factor-authentication-for-an-enterprise-user Disable2FAForEnterpriseUser(gid any, uid int, options ...RequestOptionFunc) (*Response, error) + + // DeleteEnterpriseUserOptions represents the available DeleteEnterpriseUser options. + // + // GitLab API docs: + // https://docs.gitlab.com/api/group_enterprise_users/#delete-an-enterprise-user DeleteEnterpriseUser(gid any, uid int, deleteOptions *DeleteEnterpriseUserOptions, options ...RequestOptionFunc) (*Response, error) } @@ -55,10 +75,6 @@ type ListEnterpriseUsersOptions struct { TwoFactor string `url:"two_factor,omitempty" json:"two_factor,omitempty"` } -// ListEnterpriseUsers lists all enterprise users for a given top-level group. -// -// GitLab API docs: -// https://docs.gitlab.com/api/group_enterprise_users/#list-all-enterprise-users func (s *EnterpriseUsersService) ListEnterpriseUsers(gid any, opt *ListEnterpriseUsersOptions, options ...RequestOptionFunc) ([]*User, *Response, error) { group, err := parseID(gid) if err != nil { @@ -80,10 +96,6 @@ func (s *EnterpriseUsersService) ListEnterpriseUsers(gid any, opt *ListEnterpris return users, resp, nil } -// GetEnterpriseUser gets details on a specified enterprise user. -// -// GitLab API docs: -// https://docs.gitlab.com/api/group_enterprise_users/#get-details-on-an-enterprise-user func (s *EnterpriseUsersService) GetEnterpriseUser(gid any, uid int, options ...RequestOptionFunc) (*User, *Response, error) { group, err := parseID(gid) if err != nil { @@ -105,11 +117,6 @@ func (s *EnterpriseUsersService) GetEnterpriseUser(gid any, uid int, options ... return user, resp, nil } -// Disable2FAForEnterpriseUser disables two-factor authentication (2FA) for a -// specified enterprise user. -// -// GitLab API docs: -// https://docs.gitlab.com/api/group_enterprise_users/#disable-two-factor-authentication-for-an-enterprise-user func (s *EnterpriseUsersService) Disable2FAForEnterpriseUser(gid any, uid int, options ...RequestOptionFunc) (*Response, error) { group, err := parseID(gid) if err != nil { @@ -125,10 +132,6 @@ func (s *EnterpriseUsersService) Disable2FAForEnterpriseUser(gid any, uid int, o return s.client.Do(req, nil) } -// DeleteEnterpriseUserOptions represents the available DeleteEnterpriseUser options. -// -// GitLab API docs: -// https://docs.gitlab.com/api/group_enterprise_users/#delete-an-enterprise-user type DeleteEnterpriseUserOptions struct { HardDelete *bool `url:"hard_delete,omitempty" json:"hard_delete,omitempty"` } diff --git a/environments.go b/environments.go index 9d8f9fed..1dfb79a8 100644 --- a/environments.go +++ b/environments.go @@ -25,11 +25,43 @@ import ( type ( // EnvironmentsServiceInterface defines all the API methods for the EnvironmentsService EnvironmentsServiceInterface interface { + // ListEnvironments gets a list of environments from a project, sorted by name + // alphabetically. + // + // GitLab API docs: + // https://docs.gitlab.com/api/environments/#list-environments ListEnvironments(pid any, opts *ListEnvironmentsOptions, options ...RequestOptionFunc) ([]*Environment, *Response, error) + + // GetEnvironment gets a specific environment from a project. + // + // GitLab API docs: + // https://docs.gitlab.com/api/environments/#get-a-specific-environment GetEnvironment(pid any, environment int, options ...RequestOptionFunc) (*Environment, *Response, error) + + // CreateEnvironment adds an environment to a project. This method is idempotent + // and can be called multiple times with the same parameters. Creating an environment + // that already exists does not affect the existing association. + // + // GitLab API docs: + // https://docs.gitlab.com/api/environments/#create-a-new-environment CreateEnvironment(pid any, opt *CreateEnvironmentOptions, options ...RequestOptionFunc) (*Environment, *Response, error) + + // EditEnvironment updates a project team environment to a specified access level.. + // + // GitLab API docs: + // https://docs.gitlab.com/api/environments/#update-an-existing-environment EditEnvironment(pid any, environment int, opt *EditEnvironmentOptions, options ...RequestOptionFunc) (*Environment, *Response, error) + + // DeleteEnvironment removes an environment from a project team. + // + // GitLab API docs: + // https://docs.gitlab.com/api/environments/#delete-an-environment DeleteEnvironment(pid any, environment int, options ...RequestOptionFunc) (*Response, error) + + // StopEnvironment stops an environment within a specific project. + // + // GitLab API docs: + // https://docs.gitlab.com/api/environments/#stop-an-environment StopEnvironment(pid any, environmentID int, opt *StopEnvironmentOptions, options ...RequestOptionFunc) (*Environment, *Response, error) } @@ -81,11 +113,6 @@ type ListEnvironmentsOptions struct { States *string `url:"states,omitempty" json:"states,omitempty"` } -// ListEnvironments gets a list of environments from a project, sorted by name -// alphabetically. -// -// GitLab API docs: -// https://docs.gitlab.com/api/environments/#list-environments func (s *EnvironmentsService) ListEnvironments(pid any, opts *ListEnvironmentsOptions, options ...RequestOptionFunc) ([]*Environment, *Response, error) { project, err := parseID(pid) if err != nil { @@ -107,10 +134,6 @@ func (s *EnvironmentsService) ListEnvironments(pid any, opts *ListEnvironmentsOp return envs, resp, nil } -// GetEnvironment gets a specific environment from a project. -// -// GitLab API docs: -// https://docs.gitlab.com/api/environments/#get-a-specific-environment func (s *EnvironmentsService) GetEnvironment(pid any, environment int, options ...RequestOptionFunc) (*Environment, *Response, error) { project, err := parseID(pid) if err != nil { @@ -147,12 +170,6 @@ type CreateEnvironmentOptions struct { AutoStopSetting *string `url:"auto_stop_setting,omitempty" json:"auto_stop_setting,omitempty"` } -// CreateEnvironment adds an environment to a project. This method is idempotent -// and can be called multiple times with the same parameters. Creating an environment -// that already exists does not affect the existing association. -// -// GitLab API docs: -// https://docs.gitlab.com/api/environments/#create-a-new-environment func (s *EnvironmentsService) CreateEnvironment(pid any, opt *CreateEnvironmentOptions, options ...RequestOptionFunc) (*Environment, *Response, error) { project, err := parseID(pid) if err != nil { @@ -189,10 +206,6 @@ type EditEnvironmentOptions struct { AutoStopSetting *string `url:"auto_stop_setting,omitempty" json:"auto_stop_setting,omitempty"` } -// EditEnvironment updates a project team environment to a specified access level.. -// -// GitLab API docs: -// https://docs.gitlab.com/api/environments/#update-an-existing-environment func (s *EnvironmentsService) EditEnvironment(pid any, environment int, opt *EditEnvironmentOptions, options ...RequestOptionFunc) (*Environment, *Response, error) { project, err := parseID(pid) if err != nil { @@ -214,10 +227,6 @@ func (s *EnvironmentsService) EditEnvironment(pid any, environment int, opt *Edi return env, resp, nil } -// DeleteEnvironment removes an environment from a project team. -// -// GitLab API docs: -// https://docs.gitlab.com/api/environments/#delete-an-environment func (s *EnvironmentsService) DeleteEnvironment(pid any, environment int, options ...RequestOptionFunc) (*Response, error) { project, err := parseID(pid) if err != nil { @@ -241,10 +250,6 @@ type StopEnvironmentOptions struct { Force *bool `url:"force,omitempty" json:"force,omitempty"` } -// StopEnvironment stops an environment within a specific project. -// -// GitLab API docs: -// https://docs.gitlab.com/api/environments/#stop-an-environment func (s *EnvironmentsService) StopEnvironment(pid any, environmentID int, opt *StopEnvironmentOptions, options ...RequestOptionFunc) (*Environment, *Response, error) { project, err := parseID(pid) if err != nil { diff --git a/epic_issues.go b/epic_issues.go index 625d86c1..cd51bb81 100644 --- a/epic_issues.go +++ b/epic_issues.go @@ -26,12 +26,32 @@ type ( // Will be removed in v5 of the API, use Work Items API instead EpicIssuesServiceInterface interface { // Will be removed in v5 of the API, use Work Items API instead + // ListEpicIssues get a list of epic issues. + // + // Gitlab API docs: + // https://docs.gitlab.com/api/epic_issues/#list-issues-for-an-epic ListEpicIssues(gid any, epic int, opt *ListOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) + + // AssignEpicIssue assigns an existing issue to an epic. // Will be removed in v5 of the API, use Work Items API instead + // + // Gitlab API Docs: + // https://docs.gitlab.com/api/epic_issues/#assign-an-issue-to-the-epic AssignEpicIssue(gid any, epic, issue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) + + // RemoveEpicIssue removes an issue from an epic. // Will be removed in v5 of the API, use Work Items API instead + // + // Gitlab API Docs: + // https://docs.gitlab.com/api/epic_issues/#remove-an-issue-from-the-epic RemoveEpicIssue(gid any, epic, epicIssue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) + + // UpdateEpicIssueAssignmentOptions describes the UpdateEpicIssueAssignment() + // options. // Will be removed in v5 of the API, use Work Items API instead + // + // Gitlab API Docs: + // https://docs.gitlab.com/api/epic_issues/#update-epic---issue-association UpdateEpicIssueAssignment(gid any, epic, epicIssue int, opt *UpdateEpicIssueAssignmentOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) } @@ -59,11 +79,6 @@ type EpicIssueAssignment struct { Issue *Issue `json:"issue"` } -// ListEpicIssues get a list of epic issues. -// Will be removed in v5 of the API, use Work Items API instead -// -// Gitlab API docs: -// https://docs.gitlab.com/api/epic_issues/#list-issues-for-an-epic func (s *EpicIssuesService) ListEpicIssues(gid any, epic int, opt *ListOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) { group, err := parseID(gid) if err != nil { @@ -85,11 +100,6 @@ func (s *EpicIssuesService) ListEpicIssues(gid any, epic int, opt *ListOptions, return is, resp, nil } -// AssignEpicIssue assigns an existing issue to an epic. -// Will be removed in v5 of the API, use Work Items API instead -// -// Gitlab API Docs: -// https://docs.gitlab.com/api/epic_issues/#assign-an-issue-to-the-epic func (s *EpicIssuesService) AssignEpicIssue(gid any, epic, issue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) { group, err := parseID(gid) if err != nil { @@ -111,11 +121,6 @@ func (s *EpicIssuesService) AssignEpicIssue(gid any, epic, issue int, options .. return a, resp, nil } -// RemoveEpicIssue removes an issue from an epic. -// Will be removed in v5 of the API, use Work Items API instead -// -// Gitlab API Docs: -// https://docs.gitlab.com/api/epic_issues/#remove-an-issue-from-the-epic func (s *EpicIssuesService) RemoveEpicIssue(gid any, epic, epicIssue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) { group, err := parseID(gid) if err != nil { @@ -137,12 +142,6 @@ func (s *EpicIssuesService) RemoveEpicIssue(gid any, epic, epicIssue int, option return a, resp, nil } -// UpdateEpicIssueAssignmentOptions describes the UpdateEpicIssueAssignment() -// options. -// Will be removed in v5 of the API, use Work Items API instead -// -// Gitlab API Docs: -// https://docs.gitlab.com/api/epic_issues/#update-epic---issue-association type UpdateEpicIssueAssignmentOptions struct { *ListOptions MoveBeforeID *int `url:"move_before_id,omitempty" json:"move_before_id,omitempty"` diff --git a/epics.go b/epics.go index fa3f6b61..ca194b58 100644 --- a/epics.go +++ b/epics.go @@ -26,17 +26,42 @@ type ( // EpicsServiceInterface defines all the API methods for the EpicsService // Will be removed in v5 of the API, use Work Items API instead EpicsServiceInterface interface { + // ListGroupEpics gets a list of group epics. This function accepts pagination + // parameters page and per_page to return the list of group epics. // Will be removed in v5 of the API, use Work Items API instead + // + // GitLab API docs: https://docs.gitlab.com/api/epics/#list-epics-for-a-group ListGroupEpics(gid any, opt *ListGroupEpicsOptions, options ...RequestOptionFunc) ([]*Epic, *Response, error) + + // GetEpic gets a single group epic. // Will be removed in v5 of the API, use Work Items API instead + // + // GitLab API docs: https://docs.gitlab.com/api/epics/#single-epic GetEpic(gid any, epic int, options ...RequestOptionFunc) (*Epic, *Response, error) + + // GetEpicLinks gets all child epics of an epic. // Will be removed in v5 of the API, use Work Items API instead + // + // GitLab API docs: https://docs.gitlab.com/api/epic_links/ GetEpicLinks(gid any, epic int, options ...RequestOptionFunc) ([]*Epic, *Response, error) + + // CreateEpic creates a new group epic. // Will be removed in v5 of the API, use Work Items API instead + // + // GitLab API docs: https://docs.gitlab.com/api/epics/#new-epic CreateEpic(gid any, opt *CreateEpicOptions, options ...RequestOptionFunc) (*Epic, *Response, error) + + // UpdateEpic updates an existing group epic. This function is also used + // to mark an epic as closed. // Will be removed in v5 of the API, use Work Items API instead + // + // GitLab API docs: https://docs.gitlab.com/api/epics/#update-epic UpdateEpic(gid any, epic int, opt *UpdateEpicOptions, options ...RequestOptionFunc) (*Epic, *Response, error) + + // DeleteEpic deletes a single group epic. // Will be removed in v5 of the API, use Work Items API instead + // + // GitLab API docs: https://docs.gitlab.com/api/epics/#delete-epic DeleteEpic(gid any, epic int, options ...RequestOptionFunc) (*Response, error) } @@ -126,11 +151,6 @@ type ListGroupEpicsOptions struct { MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"` } -// ListGroupEpics gets a list of group epics. This function accepts pagination -// parameters page and per_page to return the list of group epics. -// Will be removed in v5 of the API, use Work Items API instead -// -// GitLab API docs: https://docs.gitlab.com/api/epics/#list-epics-for-a-group func (s *EpicsService) ListGroupEpics(gid any, opt *ListGroupEpicsOptions, options ...RequestOptionFunc) ([]*Epic, *Response, error) { group, err := parseID(gid) if err != nil { @@ -152,10 +172,6 @@ func (s *EpicsService) ListGroupEpics(gid any, opt *ListGroupEpicsOptions, optio return es, resp, nil } -// GetEpic gets a single group epic. -// Will be removed in v5 of the API, use Work Items API instead -// -// GitLab API docs: https://docs.gitlab.com/api/epics/#single-epic func (s *EpicsService) GetEpic(gid any, epic int, options ...RequestOptionFunc) (*Epic, *Response, error) { group, err := parseID(gid) if err != nil { @@ -177,10 +193,6 @@ func (s *EpicsService) GetEpic(gid any, epic int, options ...RequestOptionFunc) return e, resp, nil } -// GetEpicLinks gets all child epics of an epic. -// Will be removed in v5 of the API, use Work Items API instead -// -// GitLab API docs: https://docs.gitlab.com/api/epic_links/ func (s *EpicsService) GetEpicLinks(gid any, epic int, options ...RequestOptionFunc) ([]*Epic, *Response, error) { group, err := parseID(gid) if err != nil { @@ -220,10 +232,6 @@ type CreateEpicOptions struct { ParentID *int `url:"parent_id,omitempty" json:"parent_id,omitempty"` } -// CreateEpic creates a new group epic. -// Will be removed in v5 of the API, use Work Items API instead -// -// GitLab API docs: https://docs.gitlab.com/api/epics/#new-epic func (s *EpicsService) CreateEpic(gid any, opt *CreateEpicOptions, options ...RequestOptionFunc) (*Epic, *Response, error) { group, err := parseID(gid) if err != nil { @@ -266,11 +274,6 @@ type UpdateEpicOptions struct { Color *string `url:"color,omitempty" json:"color,omitempty"` } -// UpdateEpic updates an existing group epic. This function is also used -// to mark an epic as closed. -// Will be removed in v5 of the API, use Work Items API instead -// -// GitLab API docs: https://docs.gitlab.com/api/epics/#update-epic func (s *EpicsService) UpdateEpic(gid any, epic int, opt *UpdateEpicOptions, options ...RequestOptionFunc) (*Epic, *Response, error) { group, err := parseID(gid) if err != nil { @@ -292,10 +295,6 @@ func (s *EpicsService) UpdateEpic(gid any, epic int, opt *UpdateEpicOptions, opt return e, resp, nil } -// DeleteEpic deletes a single group epic. -// Will be removed in v5 of the API, use Work Items API instead -// -// GitLab API docs: https://docs.gitlab.com/api/epics/#delete-epic func (s *EpicsService) DeleteEpic(gid any, epic int, options ...RequestOptionFunc) (*Response, error) { group, err := parseID(gid) if err != nil { -- GitLab From 0e60edba3804a3e5ea6c05a00300ee2abd1b7b2f Mon Sep 17 00:00:00 2001 From: zubeen Date: Tue, 28 Oct 2025 23:44:02 +0530 Subject: [PATCH 2/3] resolve Duo's review comments --- enterprise_users.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/enterprise_users.go b/enterprise_users.go index b8c9e99d..03771bc0 100644 --- a/enterprise_users.go +++ b/enterprise_users.go @@ -41,7 +41,7 @@ type ( // https://docs.gitlab.com/api/group_enterprise_users/#disable-two-factor-authentication-for-an-enterprise-user Disable2FAForEnterpriseUser(gid any, uid int, options ...RequestOptionFunc) (*Response, error) - // DeleteEnterpriseUserOptions represents the available DeleteEnterpriseUser options. + // DeleteEnterpriseUser deletes an specified enterprise user. // // GitLab API docs: // https://docs.gitlab.com/api/group_enterprise_users/#delete-an-enterprise-user @@ -132,14 +132,14 @@ func (s *EnterpriseUsersService) Disable2FAForEnterpriseUser(gid any, uid int, o return s.client.Do(req, nil) } +// DeleteEnterpriseUserOptions represents the available DeleteEnterpriseUser options. +// +// GitLab API docs: +// https://docs.gitlab.com/api/group_enterprise_users/#delete-an-enterprise-user type DeleteEnterpriseUserOptions struct { HardDelete *bool `url:"hard_delete,omitempty" json:"hard_delete,omitempty"` } -// DeleteEnterpriseUser deletes an specified enterprise user. -// -// GitLab API docs: -// https://docs.gitlab.com/api/group_enterprise_users/#delete-an-enterprise-user func (s *EnterpriseUsersService) DeleteEnterpriseUser(gid any, uid int, opt *DeleteEnterpriseUserOptions, options ...RequestOptionFunc) (*Response, error) { group, err := parseID(gid) if err != nil { -- GitLab From e728a019f3fd4f3c26cd6eefa6d66b69384380f2 Mon Sep 17 00:00:00 2001 From: Zubeen Date: Tue, 28 Oct 2025 23:52:05 +0530 Subject: [PATCH 3/3] resolve duo's comments --- environments.go | 2 +- epic_issues.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/environments.go b/environments.go index 1dfb79a8..7d5936c2 100644 --- a/environments.go +++ b/environments.go @@ -46,7 +46,7 @@ type ( // https://docs.gitlab.com/api/environments/#create-a-new-environment CreateEnvironment(pid any, opt *CreateEnvironmentOptions, options ...RequestOptionFunc) (*Environment, *Response, error) - // EditEnvironment updates a project team environment to a specified access level.. + // EditEnvironment updates a project team environment to a specified access level. // // GitLab API docs: // https://docs.gitlab.com/api/environments/#update-an-existing-environment diff --git a/epic_issues.go b/epic_issues.go index cd51bb81..2a191b3e 100644 --- a/epic_issues.go +++ b/epic_issues.go @@ -28,21 +28,21 @@ type ( // Will be removed in v5 of the API, use Work Items API instead // ListEpicIssues get a list of epic issues. // - // Gitlab API docs: + // GitLab API docs: // https://docs.gitlab.com/api/epic_issues/#list-issues-for-an-epic ListEpicIssues(gid any, epic int, opt *ListOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) // AssignEpicIssue assigns an existing issue to an epic. // Will be removed in v5 of the API, use Work Items API instead // - // Gitlab API Docs: + // GitLab API Docs: // https://docs.gitlab.com/api/epic_issues/#assign-an-issue-to-the-epic AssignEpicIssue(gid any, epic, issue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) // RemoveEpicIssue removes an issue from an epic. // Will be removed in v5 of the API, use Work Items API instead // - // Gitlab API Docs: + // GitLab API Docs: // https://docs.gitlab.com/api/epic_issues/#remove-an-issue-from-the-epic RemoveEpicIssue(gid any, epic, epicIssue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) @@ -50,7 +50,7 @@ type ( // options. // Will be removed in v5 of the API, use Work Items API instead // - // Gitlab API Docs: + // GitLab API Docs: // https://docs.gitlab.com/api/epic_issues/#update-epic---issue-association UpdateEpicIssueAssignment(gid any, epic, epicIssue int, opt *UpdateEpicIssueAssignmentOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) } -- GitLab