[Vendor] Update xanzy/go-gitlab v0.31.0 => v0.37.0 (#12701)
* update github.com/xanzy/go-gitlab v0.31.0 => v0.37.0 * vendor * adapt changes Co-authored-by: techknowlogick <techknowlogick@gitea.io>tokarchuk/v1.17
parent
0ed5e103fe
commit
0c6a802731
@ -1,12 +0,0 @@ |
||||
sudo: false |
||||
|
||||
language: go |
||||
|
||||
go: |
||||
- 1.12.4 |
||||
|
||||
branches: |
||||
only: |
||||
- master |
||||
|
||||
script: make updatedeps test |
@ -0,0 +1,133 @@ |
||||
package gitlab |
||||
|
||||
import "fmt" |
||||
|
||||
// EpicIssuesService handles communication with the epic issue related methods
|
||||
// of the GitLab API.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ee/api/epic_issues.html
|
||||
type EpicIssuesService struct { |
||||
client *Client |
||||
} |
||||
|
||||
// EpicIssueAssignment contains both the epic and issue objects returned from
|
||||
// Gitlab with the assignment ID.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ee/api/epic_issues.html
|
||||
type EpicIssueAssignment struct { |
||||
ID int `json:"id"` |
||||
Epic *Epic `json:"epic"` |
||||
Issue *Issue `json:"issue"` |
||||
} |
||||
|
||||
// ListEpicIssues get a list of epic issues.
|
||||
//
|
||||
// Gitlab API docs:
|
||||
// https://docs.gitlab.com/ee/api/epic_issues.html#list-issues-for-an-epic
|
||||
func (s *EpicIssuesService) ListEpicIssues(gid interface{}, epic int, opt *ListOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) { |
||||
group, err := parseID(gid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("groups/%s/epics/%d/issues", pathEscape(group), epic) |
||||
|
||||
req, err := s.client.NewRequest("GET", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
var is []*Issue |
||||
resp, err := s.client.Do(req, &is) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return is, resp, err |
||||
} |
||||
|
||||
// AssignEpicIssue assigns an existing issue to an epic.
|
||||
//
|
||||
// Gitlab API Docs:
|
||||
// https://docs.gitlab.com/ee/api/epic_issues.html#assign-an-issue-to-the-epic
|
||||
func (s *EpicIssuesService) AssignEpicIssue(gid interface{}, epic, issue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) { |
||||
group, err := parseID(gid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, issue) |
||||
|
||||
req, err := s.client.NewRequest("POST", u, nil, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
a := new(EpicIssueAssignment) |
||||
resp, err := s.client.Do(req, a) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return a, resp, err |
||||
} |
||||
|
||||
// RemoveEpicIssue removes an issue from an epic.
|
||||
//
|
||||
// Gitlab API Docs:
|
||||
// https://docs.gitlab.com/ee/api/epic_issues.html#remove-an-issue-from-the-epic
|
||||
func (s *EpicIssuesService) RemoveEpicIssue(gid interface{}, epic, epicIssue int, options ...RequestOptionFunc) (*EpicIssueAssignment, *Response, error) { |
||||
group, err := parseID(gid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, epicIssue) |
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, nil, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
a := new(EpicIssueAssignment) |
||||
resp, err := s.client.Do(req, a) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return a, resp, err |
||||
} |
||||
|
||||
// UpdateEpicIsssueAssignmentOptions describes the UpdateEpicIssueAssignment()
|
||||
// options.
|
||||
//
|
||||
// Gitlab API Docs:
|
||||
// https://docs.gitlab.com/ee/api/epic_issues.html#update-epic---issue-association
|
||||
type UpdateEpicIsssueAssignmentOptions struct { |
||||
*ListOptions |
||||
MoveBeforeID *int `url:"move_before_id,omitempty" json:"move_before_id,omitempty"` |
||||
MoveAfterID *int `url:"move_after_id,omitempty" json:"move_after_id,omitempty"` |
||||
} |
||||
|
||||
// UpdateEpicIssueAssignment moves an issue before or after another issue in an
|
||||
// epic issue list.
|
||||
//
|
||||
// Gitlab API Docs:
|
||||
// https://docs.gitlab.com/ee/api/epic_issues.html#update-epic---issue-association
|
||||
func (s *EpicIssuesService) UpdateEpicIssueAssignment(gid interface{}, epic, epicIssue int, opt *UpdateEpicIsssueAssignmentOptions, options ...RequestOptionFunc) ([]*Issue, *Response, error) { |
||||
group, err := parseID(gid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("groups/%s/epics/%d/issues/%d", pathEscape(group), epic, epicIssue) |
||||
|
||||
req, err := s.client.NewRequest("PUT", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
var is []*Issue |
||||
resp, err := s.client.Do(req, &is) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return is, resp, err |
||||
} |
@ -0,0 +1,151 @@ |
||||
//
|
||||
// Copyright 2020, Serena Fang
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package gitlab |
||||
|
||||
import ( |
||||
"fmt" |
||||
"time" |
||||
) |
||||
|
||||
// InstanceClustersService handles communication with the
|
||||
// instance clusters related methods of the GitLab API.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_clusters.html
|
||||
type InstanceClustersService struct { |
||||
client *Client |
||||
} |
||||
|
||||
// InstanceCluster represents a GitLab Instance Cluster.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ee/api/instance_clusters.html
|
||||
type InstanceCluster struct { |
||||
ID int `json:"id"` |
||||
Name string `json:"name"` |
||||
Domain string `json:"domain"` |
||||
CreatedAt *time.Time `json:"created_at"` |
||||
ProviderType string `json:"provider_type"` |
||||
PlatformType string `json:"platform_type"` |
||||
EnvironmentScope string `json:"environment_scope"` |
||||
ClusterType string `json:"cluster_type"` |
||||
User *User `json:"user"` |
||||
PlatformKubernetes *PlatformKubernetes `json:"platform_kubernetes"` |
||||
ManagementProject *ManagementProject `json:"management_project"` |
||||
} |
||||
|
||||
func (v InstanceCluster) String() string { |
||||
return Stringify(v) |
||||
} |
||||
|
||||
// ListClusters gets a list of all instance clusters.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_clusters.html#list-instance-clusters
|
||||
func (s *InstanceClustersService) ListClusters(options ...RequestOptionFunc) ([]*InstanceCluster, *Response, error) { |
||||
u := "admin/clusters" |
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
var ics []*InstanceCluster |
||||
resp, err := s.client.Do(req, &ics) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return ics, resp, err |
||||
} |
||||
|
||||
// GetCluster gets an instance cluster.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_clusters.html#get-a-single-instance-cluster
|
||||
func (s *InstanceClustersService) GetCluster(cluster int, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) { |
||||
u := fmt.Sprintf("admin/clusters/%d", cluster) |
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
ic := new(InstanceCluster) |
||||
resp, err := s.client.Do(req, &ic) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return ic, resp, err |
||||
} |
||||
|
||||
// AddCluster adds an existing cluster to the instance.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_clusters.html#add-existing-instance-cluster
|
||||
func (s *InstanceClustersService) AddCluster(opt *AddClusterOptions, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) { |
||||
u := "admin/clusters/add" |
||||
|
||||
req, err := s.client.NewRequest("POST", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
ic := new(InstanceCluster) |
||||
resp, err := s.client.Do(req, ic) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return ic, resp, err |
||||
} |
||||
|
||||
// EditCluster updates an existing instance cluster.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_clusters.html#edit-instance-cluster
|
||||
func (s *InstanceClustersService) EditCluster(cluster int, opt *EditClusterOptions, options ...RequestOptionFunc) (*InstanceCluster, *Response, error) { |
||||
u := fmt.Sprintf("admin/clusters/%d", cluster) |
||||
|
||||
req, err := s.client.NewRequest("PUT", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
ic := new(InstanceCluster) |
||||
resp, err := s.client.Do(req, ic) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return ic, resp, err |
||||
} |
||||
|
||||
// DeleteCluster deletes an existing instance cluster.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_clusters.html#delete-instance-cluster
|
||||
func (s *InstanceClustersService) DeleteCluster(cluster int, options ...RequestOptionFunc) (*Response, error) { |
||||
u := fmt.Sprintf("admin/clusters/%d", cluster) |
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, nil, options) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
return s.client.Do(req, nil) |
||||
} |
@ -0,0 +1,179 @@ |
||||
//
|
||||
// Copyright 2018, Patrick Webster
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package gitlab |
||||
|
||||
import ( |
||||
"fmt" |
||||
"net/url" |
||||
) |
||||
|
||||
// InstanceVariablesService handles communication with the
|
||||
// instance level CI variables related methods of the GitLab API.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html
|
||||
type InstanceVariablesService struct { |
||||
client *Client |
||||
} |
||||
|
||||
// InstanceVariable represents a GitLab instance level CI Variable.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html
|
||||
type InstanceVariable struct { |
||||
Key string `json:"key"` |
||||
Value string `json:"value"` |
||||
VariableType VariableTypeValue `json:"variable_type"` |
||||
Protected bool `json:"protected"` |
||||
Masked bool `json:"masked"` |
||||
} |
||||
|
||||
func (v InstanceVariable) String() string { |
||||
return Stringify(v) |
||||
} |
||||
|
||||
// ListInstanceVariablesOptions represents the available options for listing variables
|
||||
// for an instance.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html#list-all-instance-variables
|
||||
type ListInstanceVariablesOptions ListOptions |
||||
|
||||
// ListVariables gets a list of all variables for an instance.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html#list-all-instance-variables
|
||||
func (s *InstanceVariablesService) ListVariables(opt *ListInstanceVariablesOptions, options ...RequestOptionFunc) ([]*InstanceVariable, *Response, error) { |
||||
u := "admin/ci/variables" |
||||
|
||||
req, err := s.client.NewRequest("GET", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
var vs []*InstanceVariable |
||||
resp, err := s.client.Do(req, &vs) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return vs, resp, err |
||||
} |
||||
|
||||
// GetVariable gets a variable.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html#show-instance-variable-details
|
||||
func (s *InstanceVariablesService) GetVariable(key string, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) { |
||||
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key)) |
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
v := new(InstanceVariable) |
||||
resp, err := s.client.Do(req, v) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return v, resp, err |
||||
} |
||||
|
||||
// CreateInstanceVariableOptions represents the available CreateVariable()
|
||||
// options.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html#create-instance-variable
|
||||
type CreateInstanceVariableOptions struct { |
||||
Key *string `url:"key,omitempty" json:"key,omitempty"` |
||||
Value *string `url:"value,omitempty" json:"value,omitempty"` |
||||
VariableType *VariableTypeValue `url:"variable_type,omitempty" json:"variable_type,omitempty"` |
||||
Protected *bool `url:"protected,omitempty" json:"protected,omitempty"` |
||||
Masked *bool `url:"masked,omitempty" json:"masked,omitempty"` |
||||
} |
||||
|
||||
// CreateVariable creates a new instance level CI variable.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html#create-instance-variable
|
||||
func (s *InstanceVariablesService) CreateVariable(opt *CreateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) { |
||||
u := "admin/ci/variables" |
||||
|
||||
req, err := s.client.NewRequest("POST", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
v := new(InstanceVariable) |
||||
resp, err := s.client.Do(req, v) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return v, resp, err |
||||
} |
||||
|
||||
// UpdateInstanceVariableOptions represents the available UpdateVariable()
|
||||
// options.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html#update-instance-variable
|
||||
type UpdateInstanceVariableOptions struct { |
||||
Value *string `url:"value,omitempty" json:"value,omitempty"` |
||||
VariableType *VariableTypeValue `url:"variable_type,omitempty" json:"variable_type,omitempty"` |
||||
Protected *bool `url:"protected,omitempty" json:"protected,omitempty"` |
||||
Masked *bool `url:"masked,omitempty" json:"masked,omitempty"` |
||||
} |
||||
|
||||
// UpdateVariable updates the position of an existing
|
||||
// instance level CI variable.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html#update-instance-variable
|
||||
func (s *InstanceVariablesService) UpdateVariable(key string, opt *UpdateInstanceVariableOptions, options ...RequestOptionFunc) (*InstanceVariable, *Response, error) { |
||||
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key)) |
||||
|
||||
req, err := s.client.NewRequest("PUT", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
v := new(InstanceVariable) |
||||
resp, err := s.client.Do(req, v) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return v, resp, err |
||||
} |
||||
|
||||
// RemoveVariable removes an instance level CI variable.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/instance_level_ci_variables.html#remove-instance-variable
|
||||
func (s *InstanceVariablesService) RemoveVariable(key string, options ...RequestOptionFunc) (*Response, error) { |
||||
u := fmt.Sprintf("admin/ci/variables/%s", url.PathEscape(key)) |
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, nil, options) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
return s.client.Do(req, nil) |
||||
} |
@ -0,0 +1,186 @@ |
||||
//
|
||||
// Copyright 2017, Sander van Harmelen
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package gitlab |
||||
|
||||
import ( |
||||
"fmt" |
||||
"time" |
||||
) |
||||
|
||||
// IssuesStatisticsService handles communication with the issues statistics
|
||||
// related methods of the GitLab API.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ee/api/issues_statistics.html
|
||||
type IssuesStatisticsService struct { |
||||
client *Client |
||||
} |
||||
|
||||
// IssuesStatistics represents a GitLab issues statistic.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ee/api/issues_statistics.html
|
||||
type IssuesStatistics struct { |
||||
Statistics struct { |
||||
Counts struct { |
||||
All int `json:"all"` |
||||
Closed int `json:"closed"` |
||||
Opened int `json:"opened"` |
||||
} `json:"counts"` |
||||
} `json:"statistics"` |
||||
} |
||||
|
||||
func (n IssuesStatistics) String() string { |
||||
return Stringify(n) |
||||
} |
||||
|
||||
// GetIssuesStatisticsOptions represents the available GetIssuesStatistics() options.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/issues_statistics.html#get-issues-statistics
|
||||
type GetIssuesStatisticsOptions struct { |
||||
Labels *Labels `url:"labels,omitempty" json:"labels,omitempty"` |
||||
Milestone *Milestone `url:"milestone,omitempty" json:"milestone,omitempty"` |
||||
Scope *string `url:"scope,omitempty" json:"scope,omitempty"` |
||||
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"` |
||||
AuthorUsername *string `url:"author_username,omitempty" json:"author_username,omitempty"` |
||||
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"` |
||||
AssigneeUsername []string `url:"assignee_username,omitempty" json:"assignee_username,omitempty"` |
||||
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"` |
||||
IIDs []int `url:"iids,omitempty" json:"iids,omitempty"` |
||||
Search *string `url:"search,omitempty" json:"search,omitempty"` |
||||
In *string `url:"in,omitempty" json:"in,omitempty"` |
||||
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"` |
||||
CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"` |
||||
UpdatedAfter *time.Time `url:"updated_after,omitempty" json:"updated_after,omitempty"` |
||||
UpdatedBefore *time.Time `url:"updated_before,omitempty" json:"updated_before,omitempty"` |
||||
Confidential *bool `url:"confidential,omitempty" json:"confidential,omitempty"` |
||||
} |
||||
|
||||
// GetIssuesStatistics gets issues statistics on all issues the authenticated
|
||||
// user has access to.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/issues_statistics.html#get-issues-statistics
|
||||
func (s *IssuesStatisticsService) GetIssuesStatistics(opt *GetIssuesStatisticsOptions, options ...RequestOptionFunc) (*IssuesStatistics, *Response, error) { |
||||
req, err := s.client.NewRequest("GET", "issues_statistics", opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
is := new(IssuesStatistics) |
||||
resp, err := s.client.Do(req, is) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return is, resp, err |
||||
} |
||||
|
||||
// GetGroupIssuesStatisticsOptions represents the available GetGroupIssuesStatistics()
|
||||
// options.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/issues_statistics.html#get-group-issues-statistics
|
||||
type GetGroupIssuesStatisticsOptions struct { |
||||
Labels *Labels `url:"labels,omitempty" json:"labels,omitempty"` |
||||
IIDs []int `url:"iids,omitempty" json:"iids,omitempty"` |
||||
Milestone *Milestone `url:"milestone,omitempty" json:"milestone,omitempty"` |
||||
Scope *string `url:"scope,omitempty" json:"scope,omitempty"` |
||||
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"` |
||||
AuthorUsername *string `url:"author_username,omitempty" json:"author_username,omitempty"` |
||||
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"` |
||||
AssigneeUsername []string `url:"assignee_username,omitempty" json:"assignee_username,omitempty"` |
||||
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"` |
||||
Search *string `url:"search,omitempty" json:"search,omitempty"` |
||||
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"` |
||||
CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"` |
||||
UpdatedAfter *time.Time `url:"updated_after,omitempty" json:"updated_after,omitempty"` |
||||
UpdatedBefore *time.Time `url:"updated_before,omitempty" json:"updated_before,omitempty"` |
||||
Confidential *bool `url:"confidential,omitempty" json:"confidential,omitempty"` |
||||
} |
||||
|
||||
// GetGroupIssuesStatistics gets issues count statistics for given group.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/issues_statistics.html#get-group-issues-statistics
|
||||
func (s *IssuesStatisticsService) GetGroupIssuesStatistics(gid interface{}, opt *GetGroupIssuesStatisticsOptions, options ...RequestOptionFunc) (*IssuesStatistics, *Response, error) { |
||||
group, err := parseID(gid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("groups/%s/issues_statistics", pathEscape(group)) |
||||
|
||||
req, err := s.client.NewRequest("GET", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
is := new(IssuesStatistics) |
||||
resp, err := s.client.Do(req, is) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return is, resp, err |
||||
} |
||||
|
||||
// GetProjectIssuesStatisticsOptions represents the available
|
||||
// GetProjectIssuesStatistics() options.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/issues_statistics.html#get-project-issues-statistics
|
||||
type GetProjectIssuesStatisticsOptions struct { |
||||
IIDs []int `url:"iids,omitempty" json:"iids,omitempty"` |
||||
Labels *Labels `url:"labels,omitempty" json:"labels,omitempty"` |
||||
Milestone *Milestone `url:"milestone,omitempty" json:"milestone,omitempty"` |
||||
Scope *string `url:"scope,omitempty" json:"scope,omitempty"` |
||||
AuthorID *int `url:"author_id,omitempty" json:"author_id,omitempty"` |
||||
AuthorUsername *string `url:"author_username,omitempty" json:"author_username,omitempty"` |
||||
AssigneeID *int `url:"assignee_id,omitempty" json:"assignee_id,omitempty"` |
||||
AssigneeUsername []string `url:"assignee_username,omitempty" json:"assignee_username,omitempty"` |
||||
MyReactionEmoji *string `url:"my_reaction_emoji,omitempty" json:"my_reaction_emoji,omitempty"` |
||||
Search *string `url:"search,omitempty" json:"search,omitempty"` |
||||
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"` |
||||
CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"` |
||||
UpdatedAfter *time.Time `url:"updated_after,omitempty" json:"updated_after,omitempty"` |
||||
UpdatedBefore *time.Time `url:"updated_before,omitempty" json:"updated_before,omitempty"` |
||||
Confidential *bool `url:"confidential,omitempty" json:"confidential,omitempty"` |
||||
} |
||||
|
||||
// GetProjectIssuesStatistics gets issues count statistics for given project.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ee/api/issues_statistics.html#get-project-issues-statistics
|
||||
func (s *IssuesStatisticsService) GetProjectIssuesStatistics(pid interface{}, opt *GetProjectIssuesStatisticsOptions, options ...RequestOptionFunc) (*IssuesStatistics, *Response, error) { |
||||
project, err := parseID(pid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("projects/%s/issues_statistics", pathEscape(project)) |
||||
|
||||
req, err := s.client.NewRequest("GET", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
is := new(IssuesStatistics) |
||||
resp, err := s.client.Do(req, is) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return is, resp, err |
||||
} |
@ -0,0 +1,145 @@ |
||||
//
|
||||
// Copyright 2017, Sander van Harmelen
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package gitlab |
||||
|
||||
import ( |
||||
"fmt" |
||||
"time" |
||||
) |
||||
|
||||
// ProjectMirrorService handles communication with the project mirror
|
||||
// related methods of the GitLab API.
|
||||
//
|
||||
// GitLAb API docs: https://docs.gitlab.com/ce/api/remote_mirrors.html
|
||||
type ProjectMirrorService struct { |
||||
client *Client |
||||
} |
||||
|
||||
// ProjectMirror represents a project mirror configuration.
|
||||
//
|
||||
// GitLAb API docs: https://docs.gitlab.com/ce/api/remote_mirrors.html
|
||||
type ProjectMirror struct { |
||||
Enabled bool `json:"enabled"` |
||||
ID int `json:"id"` |
||||
LastError string `json:"last_error"` |
||||
LastSuccessfulUpdateAt *time.Time `json:"last_successful_update_at"` |
||||
LastUpdateAt *time.Time `json:"last_update_at"` |
||||
LastUpdateStartedAt *time.Time `json:"last_update_started_at"` |
||||
OnlyProtectedBranches bool `json:"only_protected_branches"` |
||||
KeepDivergentRefs bool `json:"keep_divergent_refs"` |
||||
UpdateStatus string `json:"update_status"` |
||||
URL string `json:"url"` |
||||
} |
||||
|
||||
// ListProjectMirror gets a list of mirrors configured on the project.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ce/api/remote_mirrors.html#list-a-projects-remote-mirrors
|
||||
func (s *ProjectMirrorService) ListProjectMirror(pid interface{}, options ...RequestOptionFunc) ([]*ProjectMirror, *Response, error) { |
||||
project, err := parseID(pid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("projects/%s/remote_mirrors", pathEscape(project)) |
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
var pm []*ProjectMirror |
||||
resp, err := s.client.Do(req, &pm) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return pm, resp, err |
||||
|
||||
} |
||||
|
||||
// AddProjectMirrorOptions contains the properties requires to create
|
||||
// a new project mirror.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ce/api/remote_mirrors.html#create-a-remote-mirror
|
||||
type AddProjectMirrorOptions struct { |
||||
URL *string `url:"url,omitempty" json:"url,omitempty"` |
||||
Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"` |
||||
OnlyProtectedBranches *bool `url:"only_protected_branches,omitempty" json:"only_protected_branches,omitempty"` |
||||
KeepDivergentRefs *bool `url:"keep_divergent_refs,omitempty" json:"keep_divergent_refs,omitempty"` |
||||
} |
||||
|
||||
// AddProjectMirror creates a new mirror on the project.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ce/api/remote_mirrors.html#create-a-remote-mirror
|
||||
func (s *ProjectMirrorService) AddProjectMirror(pid interface{}, opt *AddProjectMirrorOptions, options ...RequestOptionFunc) (*ProjectMirror, *Response, error) { |
||||
project, err := parseID(pid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("projects/%s/remote_mirrors", pathEscape(project)) |
||||
|
||||
req, err := s.client.NewRequest("POST", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
pm := new(ProjectMirror) |
||||
resp, err := s.client.Do(req, pm) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return pm, resp, err |
||||
} |
||||
|
||||
// EditProjectMirrorOptions contains the properties requires to edit
|
||||
// an existing project mirror.
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ce/api/remote_mirrors.html#update-a-remote-mirrors-attributes
|
||||
type EditProjectMirrorOptions struct { |
||||
Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"` |
||||
OnlyProtectedBranches *bool `url:"only_protected_branches,omitempty" json:"only_protected_branches,omitempty"` |
||||
KeepDivergentRefs *bool `url:"keep_divergent_refs,omitempty" json:"keep_divergent_refs,omitempty"` |
||||
} |
||||
|
||||
// EditProjectMirror updates a project team member to a specified access level..
|
||||
//
|
||||
// GitLab API docs:
|
||||
// https://docs.gitlab.com/ce/api/remote_mirrors.html#update-a-remote-mirrors-attributes
|
||||
func (s *ProjectMirrorService) EditProjectMirror(pid interface{}, mirror int, opt *EditProjectMirrorOptions, options ...RequestOptionFunc) (*ProjectMirror, *Response, error) { |
||||
project, err := parseID(pid) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
u := fmt.Sprintf("projects/%s/remote_mirrors/%d", pathEscape(project), mirror) |
||||
|
||||
req, err := s.client.NewRequest("PUT", u, opt, options) |
||||
if err != nil { |
||||
return nil, nil, err |
||||
} |
||||
|
||||
pm := new(ProjectMirror) |
||||
resp, err := s.client.Do(req, pm) |
||||
if err != nil { |
||||
return nil, resp, err |
||||
} |
||||
|
||||
return pm, resp, err |
||||
} |
@ -0,0 +1,430 @@ |
||||
package gitlab |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"errors" |
||||
"fmt" |
||||
"net/url" |
||||
"time" |
||||
) |
||||
|
||||
// AccessControlValue represents an access control value within GitLab,
|
||||
// used for managing access to certain project features.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html
|
||||
type AccessControlValue string |
||||
|
||||
// List of available access control values.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html
|
||||
const ( |
||||
DisabledAccessControl AccessControlValue = "disabled" |
||||
EnabledAccessControl AccessControlValue = "enabled" |
||||
PrivateAccessControl AccessControlValue = "private" |
||||
PublicAccessControl AccessControlValue = "public" |
||||
) |
||||
|
||||
// AccessControl is a helper routine that allocates a new AccessControlValue
|
||||
// to store v and returns a pointer to it.
|
||||
func AccessControl(v AccessControlValue) *AccessControlValue { |
||||
p := new(AccessControlValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// AccessLevelValue represents a permission level within GitLab.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/permissions/permissions.html
|
||||
type AccessLevelValue int |
||||
|
||||
// List of available access levels
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/permissions/permissions.html
|
||||
const ( |
||||
NoPermissions AccessLevelValue = 0 |
||||
GuestPermissions AccessLevelValue = 10 |
||||
ReporterPermissions AccessLevelValue = 20 |
||||
DeveloperPermissions AccessLevelValue = 30 |
||||
MaintainerPermissions AccessLevelValue = 40 |
||||
OwnerPermissions AccessLevelValue = 50 |
||||
|
||||
// These are deprecated and should be removed in a future version
|
||||
MasterPermissions AccessLevelValue = 40 |
||||
OwnerPermission AccessLevelValue = 50 |
||||
) |
||||
|
||||
// AccessLevel is a helper routine that allocates a new AccessLevelValue
|
||||
// to store v and returns a pointer to it.
|
||||
func AccessLevel(v AccessLevelValue) *AccessLevelValue { |
||||
p := new(AccessLevelValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// BuildStateValue represents a GitLab build state.
|
||||
type BuildStateValue string |
||||
|
||||
// These constants represent all valid build states.
|
||||
const ( |
||||
Pending BuildStateValue = "pending" |
||||
Created BuildStateValue = "created" |
||||
Running BuildStateValue = "running" |
||||
Success BuildStateValue = "success" |
||||
Failed BuildStateValue = "failed" |
||||
Canceled BuildStateValue = "canceled" |
||||
Skipped BuildStateValue = "skipped" |
||||
Manual BuildStateValue = "manual" |
||||
) |
||||
|
||||
// BuildState is a helper routine that allocates a new BuildStateValue
|
||||
// to store v and returns a pointer to it.
|
||||
func BuildState(v BuildStateValue) *BuildStateValue { |
||||
p := new(BuildStateValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// DeploymentStatusValue represents a Gitlab deployment status.
|
||||
type DeploymentStatusValue string |
||||
|
||||
// These constants represent all valid deployment statuses.
|
||||
const ( |
||||
DeploymentStatusCreated DeploymentStatusValue = "created" |
||||
DeploymentStatusRunning DeploymentStatusValue = "running" |
||||
DeploymentStatusSuccess DeploymentStatusValue = "success" |
||||
DeploymentStatusFailed DeploymentStatusValue = "failed" |
||||
DeploymentStatusCanceled DeploymentStatusValue = "canceled" |
||||
) |
||||
|
||||
// DeploymentStatus is a helper routine that allocates a new
|
||||
// DeploymentStatusValue to store v and returns a pointer to it.
|
||||
func DeploymentStatus(v DeploymentStatusValue) *DeploymentStatusValue { |
||||
p := new(DeploymentStatusValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// ISOTime represents an ISO 8601 formatted date
|
||||
type ISOTime time.Time |
||||
|
||||
// ISO 8601 date format
|
||||
const iso8601 = "2006-01-02" |
||||
|
||||
// MarshalJSON implements the json.Marshaler interface
|
||||
func (t ISOTime) MarshalJSON() ([]byte, error) { |
||||
if y := time.Time(t).Year(); y < 0 || y >= 10000 { |
||||
// ISO 8901 uses 4 digits for the years
|
||||
return nil, errors.New("json: ISOTime year outside of range [0,9999]") |
||||
} |
||||
|
||||
b := make([]byte, 0, len(iso8601)+2) |
||||
b = append(b, '"') |
||||
b = time.Time(t).AppendFormat(b, iso8601) |
||||
b = append(b, '"') |
||||
|
||||
return b, nil |
||||
} |
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface
|
||||
func (t *ISOTime) UnmarshalJSON(data []byte) error { |
||||
// Ignore null, like in the main JSON package
|
||||
if string(data) == "null" { |
||||
return nil |
||||
} |
||||
|
||||
isotime, err := time.Parse(`"`+iso8601+`"`, string(data)) |
||||
*t = ISOTime(isotime) |
||||
|
||||
return err |
||||
} |
||||
|
||||
// EncodeValues implements the query.Encoder interface
|
||||
func (t *ISOTime) EncodeValues(key string, v *url.Values) error { |
||||
if t == nil || (time.Time(*t)).IsZero() { |
||||
return nil |
||||
} |
||||
v.Add(key, t.String()) |
||||
return nil |
||||
} |
||||
|
||||
// String implements the Stringer interface
|
||||
func (t ISOTime) String() string { |
||||
return time.Time(t).Format(iso8601) |
||||
} |
||||
|
||||
// NotificationLevelValue represents a notification level.
|
||||
type NotificationLevelValue int |
||||
|
||||
// String implements the fmt.Stringer interface.
|
||||
func (l NotificationLevelValue) String() string { |
||||
return notificationLevelNames[l] |
||||
} |
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (l NotificationLevelValue) MarshalJSON() ([]byte, error) { |
||||
return json.Marshal(l.String()) |
||||
} |
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (l *NotificationLevelValue) UnmarshalJSON(data []byte) error { |
||||
var raw interface{} |
||||
if err := json.Unmarshal(data, &raw); err != nil { |
||||
return err |
||||
} |
||||
|
||||
switch raw := raw.(type) { |
||||
case float64: |
||||
*l = NotificationLevelValue(raw) |
||||
case string: |
||||
*l = notificationLevelTypes[raw] |
||||
case nil: |
||||
// No action needed.
|
||||
default: |
||||
return fmt.Errorf("json: cannot unmarshal %T into Go value of type %T", raw, *l) |
||||
} |
||||
|
||||
return nil |
||||
} |
||||
|
||||
// List of valid notification levels.
|
||||
const ( |
||||
DisabledNotificationLevel NotificationLevelValue = iota |
||||
ParticipatingNotificationLevel |
||||
WatchNotificationLevel |
||||
GlobalNotificationLevel |
||||
MentionNotificationLevel |
||||
CustomNotificationLevel |
||||
) |
||||
|
||||
var notificationLevelNames = [...]string{ |
||||
"disabled", |
||||
"participating", |
||||
"watch", |
||||
"global", |
||||
"mention", |
||||
"custom", |
||||
} |
||||
|
||||
var notificationLevelTypes = map[string]NotificationLevelValue{ |
||||
"disabled": DisabledNotificationLevel, |
||||
"participating": ParticipatingNotificationLevel, |
||||
"watch": WatchNotificationLevel, |
||||
"global": GlobalNotificationLevel, |
||||
"mention": MentionNotificationLevel, |
||||
"custom": CustomNotificationLevel, |
||||
} |
||||
|
||||
// NotificationLevel is a helper routine that allocates a new NotificationLevelValue
|
||||
// to store v and returns a pointer to it.
|
||||
func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue { |
||||
p := new(NotificationLevelValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// VisibilityValue represents a visibility level within GitLab.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/
|
||||
type VisibilityValue string |
||||
|
||||
// List of available visibility levels.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/
|
||||
const ( |
||||
PrivateVisibility VisibilityValue = "private" |
||||
InternalVisibility VisibilityValue = "internal" |
||||
PublicVisibility VisibilityValue = "public" |
||||
) |
||||
|
||||
// Visibility is a helper routine that allocates a new VisibilityValue
|
||||
// to store v and returns a pointer to it.
|
||||
func Visibility(v VisibilityValue) *VisibilityValue { |
||||
p := new(VisibilityValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// ProjectCreationLevelValue represents a project creation level within GitLab.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/
|
||||
type ProjectCreationLevelValue string |
||||
|
||||
// List of available project creation levels.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/
|
||||
const ( |
||||
NoOneProjectCreation ProjectCreationLevelValue = "noone" |
||||
MaintainerProjectCreation ProjectCreationLevelValue = "maintainer" |
||||
DeveloperProjectCreation ProjectCreationLevelValue = "developer" |
||||
) |
||||
|
||||
// ProjectCreationLevel is a helper routine that allocates a new ProjectCreationLevelValue
|
||||
// to store v and returns a pointer to it.
|
||||
func ProjectCreationLevel(v ProjectCreationLevelValue) *ProjectCreationLevelValue { |
||||
p := new(ProjectCreationLevelValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// SubGroupCreationLevelValue represents a sub group creation level within GitLab.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/
|
||||
type SubGroupCreationLevelValue string |
||||
|
||||
// List of available sub group creation levels.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/
|
||||
const ( |
||||
OwnerSubGroupCreationLevelValue SubGroupCreationLevelValue = "owner" |
||||
MaintainerSubGroupCreationLevelValue SubGroupCreationLevelValue = "maintainer" |
||||
) |
||||
|
||||
// SubGroupCreationLevel is a helper routine that allocates a new SubGroupCreationLevelValue
|
||||
// to store v and returns a pointer to it.
|
||||
func SubGroupCreationLevel(v SubGroupCreationLevelValue) *SubGroupCreationLevelValue { |
||||
p := new(SubGroupCreationLevelValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// VariableTypeValue represents a variable type within GitLab.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/
|
||||
type VariableTypeValue string |
||||
|
||||
// List of available variable types.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/
|
||||
const ( |
||||
EnvVariableType VariableTypeValue = "env_var" |
||||
FileVariableType VariableTypeValue = "file" |
||||
) |
||||
|
||||
// VariableType is a helper routine that allocates a new VariableTypeValue
|
||||
// to store v and returns a pointer to it.
|
||||
func VariableType(v VariableTypeValue) *VariableTypeValue { |
||||
p := new(VariableTypeValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// MergeMethodValue represents a project merge type within GitLab.
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#project-merge-method
|
||||
type MergeMethodValue string |
||||
|
||||
// List of available merge type
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#project-merge-method
|
||||
const ( |
||||
NoFastForwardMerge MergeMethodValue = "merge" |
||||
FastForwardMerge MergeMethodValue = "ff" |
||||
RebaseMerge MergeMethodValue = "rebase_merge" |
||||
) |
||||
|
||||
// MergeMethod is a helper routine that allocates a new MergeMethod
|
||||
// to sotre v and returns a pointer to it.
|
||||
func MergeMethod(v MergeMethodValue) *MergeMethodValue { |
||||
p := new(MergeMethodValue) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// EventTypeValue represents actions type for contribution events
|
||||
type EventTypeValue string |
||||
|
||||
// List of available action type
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/events.html#action-types
|
||||
const ( |
||||
CreatedEventType EventTypeValue = "created" |
||||
UpdatedEventType EventTypeValue = "updated" |
||||
ClosedEventType EventTypeValue = "closed" |
||||
ReopenedEventType EventTypeValue = "reopened" |
||||
PushedEventType EventTypeValue = "pushed" |
||||
CommentedEventType EventTypeValue = "commented" |
||||
MergedEventType EventTypeValue = "merged" |
||||
JoinedEventType EventTypeValue = "joined" |
||||
LeftEventType EventTypeValue = "left" |
||||
DestroyedEventType EventTypeValue = "destroyed" |
||||
ExpiredEventType EventTypeValue = "expired" |
||||
) |
||||
|
||||
// EventTargetTypeValue represents actions type value for contribution events
|
||||
type EventTargetTypeValue string |
||||
|
||||
// List of available action type
|
||||
//
|
||||
// GitLab API docs: https://docs.gitlab.com/ce/api/events.html#target-types
|
||||
const ( |
||||
IssueEventTargetType EventTargetTypeValue = "issue" |
||||
MilestoneEventTargetType EventTargetTypeValue = "milestone" |
||||
MergeRequestEventTargetType EventTargetTypeValue = "merge_request" |
||||
NoteEventTargetType EventTargetTypeValue = "note" |
||||
ProjectEventTargetType EventTargetTypeValue = "project" |
||||
SnippetEventTargetType EventTargetTypeValue = "snippet" |
||||
UserEventTargetType EventTargetTypeValue = "user" |
||||
) |
||||
|
||||
// Bool is a helper routine that allocates a new bool value
|
||||
// to store v and returns a pointer to it.
|
||||
func Bool(v bool) *bool { |
||||
p := new(bool) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// Int is a helper routine that allocates a new int32 value
|
||||
// to store v and returns a pointer to it, but unlike Int32
|
||||
// its argument value is an int.
|
||||
func Int(v int) *int { |
||||
p := new(int) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// String is a helper routine that allocates a new string value
|
||||
// to store v and returns a pointer to it.
|
||||
func String(v string) *string { |
||||
p := new(string) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// Time is a helper routine that allocates a new time.Time value
|
||||
// to store v and returns a pointer to it.
|
||||
func Time(v time.Time) *time.Time { |
||||
p := new(time.Time) |
||||
*p = v |
||||
return p |
||||
} |
||||
|
||||
// BoolValue is a boolean value with advanced json unmarshaling features.
|
||||
type BoolValue bool |
||||
|
||||
// UnmarshalJSON allows 1, 0, "true", and "false" to be considered as boolean values
|
||||
// Needed for:
|
||||
// https://gitlab.com/gitlab-org/gitlab-ce/issues/50122
|
||||
// https://gitlab.com/gitlab-org/gitlab/-/issues/233941
|
||||
// https://github.com/gitlabhq/terraform-provider-gitlab/issues/348
|
||||
func (t *BoolValue) UnmarshalJSON(b []byte) error { |
||||
switch string(b) { |
||||
case `"1"`: |
||||
*t = true |
||||
return nil |
||||
case `"0"`: |
||||
*t = false |
||||
return nil |
||||
case `"true"`: |
||||
*t = true |
||||
return nil |
||||
case `"false"`: |
||||
*t = false |
||||
return nil |
||||
default: |
||||
var v bool |
||||
err := json.Unmarshal(b, &v) |
||||
*t = BoolValue(v) |
||||
return err |
||||
} |
||||
} |
Loading…
Reference in new issue