diff options
Diffstat (limited to 'vendor/github.com/xanzy/go-gitlab/protected_branches.go')
-rw-r--r-- | vendor/github.com/xanzy/go-gitlab/protected_branches.go | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/vendor/github.com/xanzy/go-gitlab/protected_branches.go b/vendor/github.com/xanzy/go-gitlab/protected_branches.go index 8c1fcff1f2..bcc0369dbd 100644 --- a/vendor/github.com/xanzy/go-gitlab/protected_branches.go +++ b/vendor/github.com/xanzy/go-gitlab/protected_branches.go @@ -1,5 +1,5 @@ // -// Copyright 2017, Sander van Harmelen, Michael Lihs +// Copyright 2021, Sander van Harmelen, Michael Lihs // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) @@ -30,18 +31,6 @@ type ProtectedBranchesService struct { client *Client } -// BranchAccessDescription represents the access description for a protected -// branch. -// -// GitLab API docs: -// https://docs.gitlab.com/ce/api/protected_branches.html#protected-branches-api -type BranchAccessDescription struct { - AccessLevel AccessLevelValue `json:"access_level"` - UserID int `json:"user_id"` - GroupID int `json:"group_id"` - AccessLevelDescription string `json:"access_level_description"` -} - // ProtectedBranch represents a protected branch. // // GitLab API docs: @@ -55,6 +44,18 @@ type ProtectedBranch struct { CodeOwnerApprovalRequired bool `json:"code_owner_approval_required"` } +// BranchAccessDescription represents the access description for a protected +// branch. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/protected_branches.html#protected-branches-api +type BranchAccessDescription struct { + AccessLevel AccessLevelValue `json:"access_level"` + AccessLevelDescription string `json:"access_level_description"` + UserID int `json:"user_id"` + GroupID int `json:"group_id"` +} + // ListProtectedBranchesOptions represents the available ListProtectedBranches() // options. // @@ -73,7 +74,7 @@ func (s *ProtectedBranchesService) ListProtectedBranches(pid interface{}, opt *L } u := fmt.Sprintf("projects/%s/protected_branches", pathEscape(project)) - req, err := s.client.NewRequest("GET", u, opt, options) + req, err := s.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } @@ -98,7 +99,7 @@ func (s *ProtectedBranchesService) GetProtectedBranch(pid interface{}, branch st } u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch)) - req, err := s.client.NewRequest("GET", u, nil, options) + req, err := s.client.NewRequest(http.MethodGet, u, nil, options) if err != nil { return nil, nil, err } @@ -118,21 +119,21 @@ func (s *ProtectedBranchesService) GetProtectedBranch(pid interface{}, branch st // GitLab API docs: // https://docs.gitlab.com/ce/api/protected_branches.html#protect-repository-branches type ProtectRepositoryBranchesOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - PushAccessLevel *AccessLevelValue `url:"push_access_level,omitempty" json:"push_access_level,omitempty"` - MergeAccessLevel *AccessLevelValue `url:"merge_access_level,omitempty" json:"merge_access_level,omitempty"` - UnprotectAccessLevel *AccessLevelValue `url:"unprotect_access_level,omitempty" json:"unprotect_access_level,omitempty"` - AllowedToPush []*ProtectBranchPermissionOptions `url:"allowed_to_push,omitempty" json:"allowed_to_push,omitempty"` - AllowedToMerge []*ProtectBranchPermissionOptions `url:"allowed_to_merge,omitempty" json:"allowed_to_merge,omitempty"` - AllowedToUnprotect []*ProtectBranchPermissionOptions `url:"allowed_to_unprotect,omitempty" json:"allowed_to_unprotect,omitempty"` - CodeOwnerApprovalRequired *bool `url:"code_owner_approval_required,omitempty" json:"code_owner_approval_required,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + PushAccessLevel *AccessLevelValue `url:"push_access_level,omitempty" json:"push_access_level,omitempty"` + MergeAccessLevel *AccessLevelValue `url:"merge_access_level,omitempty" json:"merge_access_level,omitempty"` + UnprotectAccessLevel *AccessLevelValue `url:"unprotect_access_level,omitempty" json:"unprotect_access_level,omitempty"` + AllowedToPush []*BranchPermissionOptions `url:"allowed_to_push,omitempty" json:"allowed_to_push,omitempty"` + AllowedToMerge []*BranchPermissionOptions `url:"allowed_to_merge,omitempty" json:"allowed_to_merge,omitempty"` + AllowedToUnprotect []*BranchPermissionOptions `url:"allowed_to_unprotect,omitempty" json:"allowed_to_unprotect,omitempty"` + CodeOwnerApprovalRequired *bool `url:"code_owner_approval_required,omitempty" json:"code_owner_approval_required,omitempty"` } -// ProtectBranchPermissionOptions represents a branch permission option. +// BranchPermissionOptions represents a branch permission option. // // GitLab API docs: // https://docs.gitlab.com/ce/api/protected_branches.html#protect-repository-branches -type ProtectBranchPermissionOptions struct { +type BranchPermissionOptions struct { UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"` GroupID *int `url:"group_id,omitempty" json:"group_id,omitempty"` AccessLevel *AccessLevelValue `url:"access_level,omitempty" json:"access_level,omitempty"` @@ -150,7 +151,7 @@ func (s *ProtectedBranchesService) ProtectRepositoryBranches(pid interface{}, op } u := fmt.Sprintf("projects/%s/protected_branches", pathEscape(project)) - req, err := s.client.NewRequest("POST", u, opt, options) + req, err := s.client.NewRequest(http.MethodPost, u, opt, options) if err != nil { return nil, nil, err } @@ -176,7 +177,7 @@ func (s *ProtectedBranchesService) UnprotectRepositoryBranches(pid interface{}, } u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch)) - req, err := s.client.NewRequest("DELETE", u, nil, options) + req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) if err != nil { return nil, err } @@ -204,7 +205,7 @@ func (s *ProtectedBranchesService) RequireCodeOwnerApprovals(pid interface{}, br } u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch)) - req, err := s.client.NewRequest("PATCH", u, opt, options) + req, err := s.client.NewRequest(http.MethodPatch, u, opt, options) if err != nil { return nil, err } |