Repository: xanzy/go-gitlab
Pull request #1543 (2022-09-05 14:46:08)

Add request options to `GetLicense()` function


Patch:
diff --git a/event_webhook_types.go b/event_webhook_types.go
index f3900dc..a0162e0 100644
--- a/event_webhook_types.go
+++ b/event_webhook_types.go
@@ -537,10 +537,6 @@ type MergeEvent struct {
 			Previous []*EventUser `json:"previous"`
 			Current  []*EventUser `json:"current"`
 		} `json:"assignees"`
-		Reviewers struct {
-			Previous []*EventUser `json:"previous"`
-			Current  []*EventUser `json:"current"`
-		} `json:"reviewers"`
 		Description struct {
 			Previous string `json:"previous"`
 			Current  string `json:"current"`
diff --git a/groups.go b/groups.go
index 96a1e3a..feeac74 100644
--- a/groups.go
+++ b/groups.go
@@ -105,8 +105,8 @@ type LDAPGroupLink struct {
 //
 // GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#saml-group-links
 type SAMLGroupLink struct {
-	Name        string           `json:"name"`
-	AccessLevel AccessLevelValue `json:"access_level"`
+	Name        string `json:"name"`
+	AccessLevel string `json:"access_level"`
 }
 
 // ListGroupsOptions represents the available ListGroups() options.
@@ -810,8 +810,8 @@ func (s *GroupsService) GetGroupSAMLLink(gid interface{}, samlGroupName string,
 // GitLab API docs:
 // https://docs.gitlab.com/ee/api/groups.html#add-saml-group-link
 type AddGroupSAMLLinkOptions struct {
-	SAMLGroupName *string           `url:"saml_group_name,omitempty" json:"saml_group_name,omitempty"`
-	AccessLevel   *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"`
+	SAMLGroupName *string `url:"saml_group_name,omitempty" json:"saml_group_name,omitempty"`
+	AccessLevel   *string `url:"access_level,omitempty" json:"access_level,omitempty"`
 }
 
 // AddGroupSAMLLink creates a new group SAML link. Available only for users who
diff --git a/license.go b/license.go
index 618fde6..ddec3be 100644
--- a/license.go
+++ b/license.go
@@ -70,8 +70,8 @@ func (l License) String() string {
 //
 // GitLab API docs:
 // https://docs.gitlab.com/ee/api/license.html#retrieve-information-about-the-current-license
-func (s *LicenseService) GetLicense() (*License, *Response, error) {
-	req, err := s.client.NewRequest(http.MethodGet, "license", nil, nil)
+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
 	}
diff --git a/projects.go b/projects.go
index 5111926..ffd42dc 100644
--- a/projects.go
+++ b/projects.go
@@ -82,7 +82,7 @@ type Project struct {
 	ForksCount                                int                        `json:"forks_count"`
 	StarCount                                 int                        `json:"star_count"`
 	RunnersToken                              string                     `json:"runners_token"`
-	PublicJobs                                bool                       `json:"public_jobs"`
+	PublicBuilds                              bool                       `json:"public_builds"`
 	AllowMergeOnSkippedPipeline               bool                       `json:"allow_merge_on_skipped_pipeline"`
 	OnlyAllowMergeIfPipelineSucceeds          bool                       `json:"only_allow_merge_if_pipeline_succeeds"`
 	OnlyAllowMergeIfAllDiscussionsAreResolved bool                       `json:"only_allow_merge_if_all_discussions_are_resolved"`
@@ -144,9 +144,6 @@ type Project struct {
 	ExternalAuthorizationClassificationLabel string             `json:"external_authorization_classification_label"`
 	RequirementsAccessLevel                  AccessControlValue `json:"requirements_access_level"`
 	SecurityAndComplianceAccessLevel         AccessControlValue `json:"security_and_compliance_access_level"`
-
-	// Deprecated members
-	PublicBuilds bool `json:"public_builds"`
 }
 
 // BasicProject included in other service responses (such as todos).
diff --git a/users.go b/users.go
index d03e7e1..b170e28 100644
--- a/users.go
+++ b/users.go
@@ -117,7 +117,6 @@ type ListUsersOptions struct {
 	Active          *bool `url:"active,omitempty" json:"active,omitempty"`
 	Blocked         *bool `url:"blocked,omitempty" json:"blocked,omitempty"`
 	ExcludeInternal *bool `url:"exclude_internal,omitempty" json:"exclude_internal,omitempty"`
-	ExcludeExternal *bool `url:"exclude_external,omitempty" json:"exclude_external,omitempty"`
 
 	// The options below are only available for admins.
 	Search               *string    `url:"search,omitempty" json:"search,omitempty"`


Test patch:
diff --git a/event_webhook_types_test.go b/event_webhook_types_test.go
index a61a0f9..5ac45d0 100644
--- a/event_webhook_types_test.go
+++ b/event_webhook_types_test.go
@@ -234,18 +234,6 @@ func TestMergeEventUnmarshal(t *testing.T) {
 	if event.Assignees[0].Email != expectedEmail {
 		t.Errorf("Assignees[0].Email is %v, want %v", event.Assignees[0].Email, expectedEmail)
 	}
-
-	if len(event.Changes.Reviewers.Previous) != 0 {
-		t.Errorf("Changes.Reviewer.Previeous length is %d, want %d", len(event.Changes.Reviewers.Previous), 0)
-	}
-
-	if len(event.Changes.Reviewers.Current) != 1 {
-		t.Errorf("Changes.Reviewer.Current length is %d, want %d", len(event.Changes.Reviewers.Current), 1)
-	}
-
-	if event.Changes.Reviewers.Current[0].Username != expectedUsername {
-		t.Errorf("Changes.Reviewer.Current[0].Username is %v, want %v", event.Changes.Reviewers.Current[0].Username, expectedUsername)
-	}
 }
 
 func TestMergeEventUnmarshalFromGroup(t *testing.T) {
diff --git a/groups_test.go b/groups_test.go
index 0ab7b6b..41edb45 100644
--- a/groups_test.go
+++ b/groups_test.go
@@ -373,11 +373,11 @@ func TestListGroupSAMLLinks(t *testing.T) {
 			testMethod(t, r, http.MethodGet)
 			fmt.Fprint(w, `[
 	{
-		"access_level":30,
+		"access_level":"Developer",
 		"name":"gitlab_group_example_developer"
 	},
 	{
-		"access_level":40,
+		"access_level":"Maintainer",
 		"name":"gitlab_group_example_maintainer"
 	}
 ]`)
@@ -390,11 +390,11 @@ func TestListGroupSAMLLinks(t *testing.T) {
 
 	want := []*SAMLGroupLink{
 		{
-			AccessLevel: DeveloperPermissions,
+			AccessLevel: "Developer",
 			Name:        "gitlab_group_example_developer",
 		},
 		{
-			AccessLevel: MaintainerPermissions,
+			AccessLevel: "Maintainer",
 			Name:        "gitlab_group_example_maintainer",
 		},
 	}
@@ -412,7 +412,7 @@ func TestGetGroupSAMLLink(t *testing.T) {
 			testMethod(t, r, http.MethodGet)
 			fmt.Fprint(w, `
 {
-	"access_level":30,
+	"access_level":"Developer",
 	"name":"gitlab_group_example_developer"
 }`)
 		})
@@ -423,7 +423,7 @@ func TestGetGroupSAMLLink(t *testing.T) {
 	}
 
 	want := &SAMLGroupLink{
-		AccessLevel: DeveloperPermissions,
+		AccessLevel: "Developer",
 		Name:        "gitlab_group_example_developer",
 	}
 	if !reflect.DeepEqual(want, links) {
@@ -440,14 +440,14 @@ func TestAddGroupSAMLLink(t *testing.T) {
 			testMethod(t, r, http.MethodPost)
 			fmt.Fprint(w, `
 {
-	"access_level":30,
+	"access_level":"Developer",
 	"name":"gitlab_group_example_developer"
 }`)
 		})
 
 	opt := &AddGroupSAMLLinkOptions{
 		SAMLGroupName: String("gitlab_group_example_developer"),
-		AccessLevel:   AccessLevel(DeveloperPermissions),
+		AccessLevel:   String("Developer"),
 	}
 
 	link, _, err := client.Groups.AddGroupSAMLLink(1, opt)
@@ -456,7 +456,7 @@ func TestAddGroupSAMLLink(t *testing.T) {
 	}
 
 	want := &SAMLGroupLink{
-		AccessLevel: DeveloperPermissions,
+		AccessLevel: "Developer",
 		Name:        "gitlab_group_example_developer",
 	}
 	if !reflect.DeepEqual(want, link) {
diff --git a/testdata/webhooks/merge_request.json b/testdata/webhooks/merge_request.json
index 721dd89..c52d560 100644
--- a/testdata/webhooks/merge_request.json
+++ b/testdata/webhooks/merge_request.json
@@ -159,18 +159,6 @@
         "type": "ProjectLabel",
         "group_id": 41
       }]
-    },
-    "reviewers": {
-      "previous": [],
-      "current": [
-        {
-          "id": 1,
-          "name": "User1",
-          "username": "user1",
-          "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40&d=identicon",
-          "email": "[REDACTED]"
-        }
-      ]
     }
   }
 }