Commit df6c9365 authored by Sander van Harmelen's avatar Sander van Harmelen

Update `VisibilityLevel` to just `Visibility` (#176)

parent 0d95cf7f
......@@ -87,7 +87,7 @@ func main() {
Description: gitlab.String("Just a test project to play with"),
MergeRequestsEnabled: gitlab.Bool(true),
SnippetsEnabled: gitlab.Bool(true),
VisibilityLevel: gitlab.VisibilityLevel(gitlab.PublicVisibility),
Visibility: gitlab.VisibilityLevel(gitlab.PublicVisibility),
}
project, _, err := git.Projects.CreateProject(p)
if err != nil {
......@@ -99,7 +99,7 @@ func main() {
Title: gitlab.String("Dummy Snippet"),
FileName: gitlab.String("snippet.go"),
Code: gitlab.String("package main...."),
VisibilityLevel: gitlab.VisibilityLevel(gitlab.PublicVisibility),
Visibility: gitlab.VisibilityLevel(gitlab.PublicVisibility),
}
_, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s)
if err != nil {
......
......@@ -47,7 +47,7 @@ type PushEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
Commits []*Commit `json:"commits"`
......@@ -82,7 +82,7 @@ type TagEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
Commits []*Commit `json:"commits"`
......@@ -110,7 +110,7 @@ type IssueEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
ObjectAttributes struct {
......@@ -159,7 +159,7 @@ type CommitCommentEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
ObjectAttributes struct {
......@@ -211,7 +211,7 @@ type MergeCommentEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
ObjectAttributes struct {
......@@ -255,7 +255,7 @@ type IssueCommentEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
ObjectAttributes struct {
......@@ -299,7 +299,7 @@ type SnippetCommentEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Repository *Repository `json:"repository"`
ObjectAttributes struct {
......@@ -342,7 +342,7 @@ type MergeEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
ObjectAttributes struct {
ID int `json:"id"`
......@@ -425,7 +425,7 @@ type WikiPageEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Wiki struct {
WebURL string `json:"web_url"`
......@@ -482,7 +482,7 @@ type PipelineEvent struct {
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
WebURL string `json:"web_url"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
} `json:"project"`
Commit struct {
ID string `json:"id"`
......
......@@ -15,7 +15,7 @@ func projectExample() {
Description: gitlab.String("Just a test project to play with"),
MergeRequestsEnabled: gitlab.Bool(true),
SnippetsEnabled: gitlab.Bool(true),
VisibilityLevel: gitlab.VisibilityLevel(gitlab.PublicVisibility),
Visibility: gitlab.Visibility(gitlab.PublicVisibility),
}
project, _, err := git.Projects.CreateProject(p)
if err != nil {
......@@ -27,7 +27,7 @@ func projectExample() {
Title: gitlab.String("Dummy Snippet"),
FileName: gitlab.String("snippet.go"),
Code: gitlab.String("package main...."),
VisibilityLevel: gitlab.VisibilityLevel(gitlab.PublicVisibility),
Visibility: gitlab.Visibility(gitlab.PublicVisibility),
}
_, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s)
if err != nil {
......
......@@ -127,18 +127,18 @@ var notificationLevelTypes = map[string]NotificationLevelValue{
"custom": CustomNotificationLevel,
}
// VisibilityLevelValue represents a visibility level within GitLab.
// VisibilityValue represents a visibility level within GitLab.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/
type VisibilityLevelValue string
type VisibilityValue string
// List of available visibility levels
//
// GitLab API docs: https://docs.gitlab.com/ce/api/
const (
PrivateVisibility VisibilityLevelValue = "private"
InternalVisibility VisibilityLevelValue = "internal"
PublicVisibility VisibilityLevelValue = "public"
PrivateVisibility VisibilityValue = "private"
InternalVisibility VisibilityValue = "internal"
PublicVisibility VisibilityValue = "public"
)
// A Client manages communication with the GitLab API.
......@@ -602,10 +602,10 @@ func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue {
return p
}
// VisibilityLevel is a helper routine that allocates a new VisibilityLevelValue
// Visibility is a helper routine that allocates a new VisibilityValue
// to store v and returns a pointer to it.
func VisibilityLevel(v VisibilityLevelValue) *VisibilityLevelValue {
p := new(VisibilityLevelValue)
func Visibility(v VisibilityValue) *VisibilityValue {
p := new(VisibilityValue)
*p = v
return p
}
......@@ -45,7 +45,7 @@ type Group struct {
Projects []*Project `json:"projects"`
Statistics *StorageStatistics `json:"statistics"`
RequestAccessEnabled bool `json:"request_access_enabled"`
Visibility *VisibilityLevelValue `json:"visibility"`
Visibility *VisibilityValue `json:"visibility"`
WebURL string `json:"web_url"`
}
......@@ -114,7 +114,7 @@ type CreateGroupOptions struct {
Description *string `url:"description,omitempty" json:"description,omitempty"`
LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
VisibilityLevel *VisibilityLevelValue `url:"visibility,omitempty" json:"visibility,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
}
// CreateGroup creates a new project group. Available only for users who can
......
......@@ -122,7 +122,7 @@ type CreateSnippetOptions struct {
Title *string `url:"title,omitempty" json:"title,omitempty"`
FileName *string `url:"file_name,omitempty" json:"file_name,omitempty"`
Code *string `url:"code,omitempty" json:"code,omitempty"`
VisibilityLevel *VisibilityLevelValue `url:"visibility,omitempty" json:"visibility,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
}
// CreateSnippet creates a new project snippet. The user must have permission
......@@ -159,7 +159,7 @@ type UpdateSnippetOptions struct {
Title *string `url:"title,omitempty" json:"title,omitempty"`
FileName *string `url:"file_name,omitempty" json:"file_name,omitempty"`
Code *string `url:"code,omitempty" json:"code,omitempty"`
VisibilityLevel *VisibilityLevelValue `url:"visibility,omitempty" json:"visibility,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
}
// UpdateSnippet updates an existing project snippet. The user must have
......
......@@ -38,7 +38,7 @@ type Project struct {
Description string `json:"description"`
DefaultBranch string `json:"default_branch"`
Public bool `json:"public"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
SSHURLToRepo string `json:"ssh_url_to_repo"`
HTTPURLToRepo string `json:"http_url_to_repo"`
WebURL string `json:"web_url"`
......@@ -72,6 +72,7 @@ type Project struct {
OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"`
LFSEnabled bool `json:"lfs_enabled"`
RequestAccessEnabled bool `json:"request_access_enabled"`
ForkedFromProject *ForkParent `json:"forked_from_project"`
SharedWithGroups []struct {
GroupID int `json:"group_id"`
GroupName string `json:"group_name"`
......@@ -89,7 +90,7 @@ type Repository struct {
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel VisibilityLevelValue `json:"visibility"`
Visibility VisibilityValue `json:"visibility"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
Homepage string `json:"homepage"`
......@@ -141,6 +142,17 @@ type GroupAccess struct {
NotificationLevel NotificationLevelValue `json:"notification_level"`
}
// ForkParent represents the parent project when this is a fork.
type ForkParent struct {
HTTPURLToRepo string `json:"http_url_to_repo"`
ID int `json:"id"`
Name string `json:"name"`
NameWithNamespace string `json:"name_with_namespace"`
Path string `json:"path"`
PathWithNamespace string `json:"path_with_namespace"`
WebURL string `json:"web_url"`
}
func (s Project) String() string {
return Stringify(s)
}
......@@ -159,7 +171,7 @@ type ListProjectsOptions struct {
Membership *bool `url:"membership,omitempty" json:"membership,omitempty"`
Starred *bool `url:"starred,omitempty" json:"starred,omitempty"`
Statistics *bool `url:"statistics,omitempty" json:"statistics,omitempty"`
Visibility *VisibilityLevelValue `url:"visibility,omitempty" json:"visibility,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
}
// ListProjects gets a list of projects accessible by the authenticated user.
......@@ -285,7 +297,7 @@ type CreateProjectOptions struct {
SnippetsEnabled *bool `url:"snippets_enabled,omitempty" json:"snippets_enabled,omitempty"`
ContainerRegistryEnabled *bool `url:"container_registry_enabled,omitempty" json:"container_registry_enabled,omitempty"`
SharedRunnersEnabled *bool `url:"shared_runners_enabled,omitempty" json:"shared_runners_enabled,omitempty"`
Visibility *VisibilityLevelValue `url:"visibility,omitempty" json:"visibility,omitempty"`
Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"`
ImportURL *string `url:"import_url,omitempty" json:"import_url,omitempty"`
PublicJobs *bool `url:"public_jobs,omitempty" json:"public_jobs,omitempty"`
OnlyAllowMergeIfPipelineSucceeds *bool `url:"only_allow_merge_if_pipeline_succeeds,omitempty" json:"only_allow_merge_if_pipeline_succeeds,omitempty"`
......
......@@ -33,7 +33,7 @@ func TestListProjects(t *testing.T) {
Sort: String("asc"),
Search: String("query"),
Simple: Bool(true),
Visibility: VisibilityLevel(PublicVisibility),
Visibility: Visibility(PublicVisibility),
}
projects, _, err := client.Projects.ListProjects(opt)
......@@ -75,7 +75,7 @@ func TestListOwnedProjects(t *testing.T) {
Search: String("query"),
Simple: Bool(true),
Owned: Bool(true),
Visibility: VisibilityLevel(PublicVisibility),
Visibility: Visibility(PublicVisibility),
}
projects, _, err := client.Projects.ListProjects(opt)
......@@ -117,7 +117,7 @@ func TestListStarredProjects(t *testing.T) {
Search: String("query"),
Simple: Bool(true),
Starred: Bool(true),
Visibility: VisibilityLevel(PublicVisibility),
Visibility: Visibility(PublicVisibility),
}
projects, _, err := client.Projects.ListProjects(opt)
......
......@@ -43,7 +43,7 @@ type Settings struct {
HomePageURL string `json:"home_page_url"`
DefaultBranchProtection int `json:"default_branch_protection"`
TwitterSharingEnabled bool `json:"twitter_sharing_enabled"`
RestrictedVisibilityLevels []VisibilityLevelValue `json:"restricted_visibility_levels"`
RestrictedVisibilityLevels []VisibilityValue `json:"restricted_visibility_levels"`
MaxAttachmentSize int `json:"max_attachment_size"`
SessionExpireDelay int `json:"session_expire_delay"`
DefaultProjectVisibility int `json:"default_project_visibility"`
......@@ -89,7 +89,7 @@ type UpdateSettingsOptions struct {
HomePageURL *string `url:"home_page_url,omitempty" json:"home_page_url,omitempty"`
DefaultBranchProtection *int `url:"default_branch_protection,omitempty" json:"default_branch_protection,omitempty"`
TwitterSharingEnabled *bool `url:"twitter_sharing_enabled,omitempty" json:"twitter_sharing_enabled,omitempty"`
RestrictedVisibilityLevels []VisibilityLevelValue `url:"restricted_visibility_levels,omitempty" json:"restricted_visibility_levels,omitempty"`
RestrictedVisibilityLevels []VisibilityValue `url:"restricted_visibility_levels,omitempty" json:"restricted_visibility_levels,omitempty"`
MaxAttachmentSize *int `url:"max_attachment_size,omitempty" json:"max_attachment_size,omitempty"`
SessionExpireDelay *int `url:"session_expire_delay,omitempty" json:"session_expire_delay,omitempty"`
DefaultProjectVisibility *int `url:"default_project_visibility,omitempty" json:"default_project_visibility,omitempty"`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment