gitlab-customer-support-operations_gitlab 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/support_ops_gitlab/gitlab/badges.rb +229 -0
- data/lib/support_ops_gitlab/gitlab/base.rb +552 -0
- data/lib/support_ops_gitlab/gitlab/client.rb +51 -0
- data/lib/support_ops_gitlab/gitlab/commits.rb +198 -0
- data/lib/support_ops_gitlab/gitlab/configuration.rb +86 -0
- data/lib/support_ops_gitlab/gitlab/epics.rb +325 -0
- data/lib/support_ops_gitlab/gitlab/events.rb +167 -0
- data/lib/support_ops_gitlab/gitlab/gpg_keys.rb +64 -0
- data/lib/support_ops_gitlab/gitlab/group_memberships.rb +33 -0
- data/lib/support_ops_gitlab/gitlab/groups.rb +431 -0
- data/lib/support_ops_gitlab/gitlab/invitations.rb +72 -0
- data/lib/support_ops_gitlab/gitlab/issues.rb +606 -0
- data/lib/support_ops_gitlab/gitlab/jobs.rb +61 -0
- data/lib/support_ops_gitlab/gitlab/markdown.rb +54 -0
- data/lib/support_ops_gitlab/gitlab/merge_requests.rb +411 -0
- data/lib/support_ops_gitlab/gitlab/milestones.rb +195 -0
- data/lib/support_ops_gitlab/gitlab/namespaces.rb +184 -0
- data/lib/support_ops_gitlab/gitlab/notes.rb +182 -0
- data/lib/support_ops_gitlab/gitlab/pipelines.rb +258 -0
- data/lib/support_ops_gitlab/gitlab/project_access_tokens.rb +245 -0
- data/lib/support_ops_gitlab/gitlab/project_memberships.rb +33 -0
- data/lib/support_ops_gitlab/gitlab/project_webhook_events.rb +33 -0
- data/lib/support_ops_gitlab/gitlab/project_webhooks.rb +218 -0
- data/lib/support_ops_gitlab/gitlab/projects.rb +741 -0
- data/lib/support_ops_gitlab/gitlab/repository_files.rb +102 -0
- data/lib/support_ops_gitlab/gitlab/repository_submodules.rb +78 -0
- data/lib/support_ops_gitlab/gitlab/ssh_keys.rb +67 -0
- data/lib/support_ops_gitlab/gitlab/user_emails.rb +147 -0
- data/lib/support_ops_gitlab/gitlab/user_memberships.rb +21 -0
- data/lib/support_ops_gitlab/gitlab/user_tokens.rb +344 -0
- data/lib/support_ops_gitlab/gitlab/users.rb +1059 -0
- data/lib/support_ops_gitlab/gitlab.rb +45 -0
- data/lib/support_ops_gitlab.rb +28 -0
- metadata +251 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module SupportOps.
|
4
|
+
module SupportOps
|
5
|
+
# Defines the module GitLab
|
6
|
+
module GitLab
|
7
|
+
##
|
8
|
+
# Defines the class Events within the module {SupportOps::GitLab}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.0
|
12
|
+
# @attr [String] action_name
|
13
|
+
# @attr [Hash] author
|
14
|
+
# @attr [Integer] author_id
|
15
|
+
# @attr [String] author_username
|
16
|
+
# @attr [Integer] id
|
17
|
+
# @attr [Boolean] imported
|
18
|
+
# @attr [String] imported_from
|
19
|
+
# @attr [Integer] project_id
|
20
|
+
# @attr [Integer] target_id
|
21
|
+
# @attr [Integer] target_iid
|
22
|
+
# @attr [String] target_title
|
23
|
+
# @attr [String] target_type
|
24
|
+
# @attr [String] title
|
25
|
+
# @todo Document attribute definitions
|
26
|
+
# @todo List all events > https://docs.gitlab.com/api/events/#list-all-events
|
27
|
+
class Events < SupportOps::GitLab::Base
|
28
|
+
define_attributes :action_name, :author, :author_id, :author_username,
|
29
|
+
:id, :imported, :imported_from, :project_id, :target_id,
|
30
|
+
:target_iid, :target_title, :target_type, :title
|
31
|
+
readonly_attributes :action_name, :author, :author_id, :author_username,
|
32
|
+
:id, :imported, :imported_from, :project_id,
|
33
|
+
:target_id, :target_iid, :target_title, :target_type,
|
34
|
+
:title
|
35
|
+
|
36
|
+
##
|
37
|
+
# Get contribution events for a user
|
38
|
+
#
|
39
|
+
# @author Jason Colyer
|
40
|
+
# @since 1.0.0
|
41
|
+
# @overload list(key: value)
|
42
|
+
# @param user_id [Integer or String required] The ID or username of the
|
43
|
+
# user to get events for
|
44
|
+
# @param action [String optional] If defined, returns events with the
|
45
|
+
# specified action type (approved, closed, commented, created,
|
46
|
+
# destroyed, expired, joined, left, merge, pushed, reopened, updated)
|
47
|
+
# @param after [String optional] If defined, returns tokens created
|
48
|
+
# after the specified date (expects ISO 8601 format)
|
49
|
+
# @param before [String optional] If defined, returns tokens created
|
50
|
+
# before the specified date (expects ISO 8601 format)
|
51
|
+
# @param sort [String optional] Direction to sort the results by
|
52
|
+
# creation date; possible values: asc, desc
|
53
|
+
# @param target_type [String optional] If defined, returns events with
|
54
|
+
# the specified target type (epic, issue, merge_request, milestone,
|
55
|
+
# note, project, snippet, user)
|
56
|
+
# @return [Array]
|
57
|
+
# @see
|
58
|
+
# https://docs.gitlab.com/api/events/#get-contribution-events-for-a-user
|
59
|
+
# GitLab API > Events > Get contribution events for a user
|
60
|
+
# @see SupportOps::GitLab::Configuration Setting up a client
|
61
|
+
# @example
|
62
|
+
# require 'support_ops_gitlab'
|
63
|
+
#
|
64
|
+
# SupportOps::GitLab::Configuration.configure do |config|
|
65
|
+
# config.url = 'https://gitlab.example.com/api/v4'
|
66
|
+
# config.token = 'abc123'
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# events = SupportOps::GitLab::Events.list(user_id: 123456)
|
70
|
+
# pp events.count
|
71
|
+
# # => 30
|
72
|
+
# pp events.last.action_name
|
73
|
+
# # => "closed"
|
74
|
+
def self.list_user(**args)
|
75
|
+
raise 'You have to provide a user_id' if args[:user_id].nil?
|
76
|
+
args[:action] = nil unless args[:action]
|
77
|
+
args[:after] = nil unless args[:after]
|
78
|
+
args[:before] = nil unless args[:before]
|
79
|
+
args[:sort] = nil unless args[:sort]
|
80
|
+
args[:target_type] = nil unless args[:target_type]
|
81
|
+
params = ''
|
82
|
+
params += "action=#{args[:action]}&" unless args[:action].nil?
|
83
|
+
params += "after=#{args[:after]}&" unless args[:after].nil?
|
84
|
+
params += "before=#{args[:before]}&" unless args[:before].nil?
|
85
|
+
params += "sort=#{args[:sort]}&" unless args[:sort].nil?
|
86
|
+
params += "target_type=#{args[:target_type]}&" unless args[:target_type].nil?
|
87
|
+
array = []
|
88
|
+
page = 1
|
89
|
+
loop do
|
90
|
+
response = client.connection.get("users/#{args[:user_id]}/events?#{params}&page=#{page}&per_page=100")
|
91
|
+
body = Oj.load(response.body)
|
92
|
+
array += body.map { |e| Events.new(e) }
|
93
|
+
break if body.count < 100
|
94
|
+
|
95
|
+
page += 1
|
96
|
+
end
|
97
|
+
array
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# List all visible events for a project
|
102
|
+
#
|
103
|
+
# @author Jason Colyer
|
104
|
+
# @since 1.0.0
|
105
|
+
# @overload list(key: value)
|
106
|
+
# @param project_id [Integer or String required] The ID or URL-encoded
|
107
|
+
# path of the project to get events for
|
108
|
+
# @param action [String optional] If defined, returns events with the
|
109
|
+
# specified action type (approved, closed, commented, created,
|
110
|
+
# destroyed, expired, joined, left, merge, pushed, reopened, updated)
|
111
|
+
# @param after [String optional] If defined, returns tokens created
|
112
|
+
# after the specified date (expects ISO 8601 format)
|
113
|
+
# @param before [String optional] If defined, returns tokens created
|
114
|
+
# before the specified date (expects ISO 8601 format)
|
115
|
+
# @param sort [String optional] Direction to sort the results by
|
116
|
+
# creation date; possible values: asc, desc
|
117
|
+
# @param target_type [String optional] If defined, returns events with
|
118
|
+
# the specified target type (epic, issue, merge_request, milestone,
|
119
|
+
# note, project, snippet, user)
|
120
|
+
# @return [Array]
|
121
|
+
# @see
|
122
|
+
# https://docs.gitlab.com/api/events/#list-all-visible-events-for-a-project
|
123
|
+
# GitLab API > Events > List all visible events for a project
|
124
|
+
# @see SupportOps::GitLab::Configuration Setting up a client
|
125
|
+
# @example
|
126
|
+
# require 'support_ops_gitlab'
|
127
|
+
#
|
128
|
+
# SupportOps::GitLab::Configuration.configure do |config|
|
129
|
+
# config.url = 'https://gitlab.example.com/api/v4'
|
130
|
+
# config.token = 'abc123'
|
131
|
+
# end
|
132
|
+
#
|
133
|
+
# events = SupportOps::GitLab::Events.list(project_id: 123456)
|
134
|
+
# pp events.count
|
135
|
+
# # => 48
|
136
|
+
# pp events.last.action_name
|
137
|
+
# # => "opened"
|
138
|
+
def self.list_project(**args)
|
139
|
+
raise 'You have to provide a project_id' if args[:project_id].nil?
|
140
|
+
args[:action] = nil unless args[:action]
|
141
|
+
args[:after] = nil unless args[:after]
|
142
|
+
args[:before] = nil unless args[:before]
|
143
|
+
args[:sort] = nil unless args[:sort]
|
144
|
+
args[:target_type] = nil unless args[:target_type]
|
145
|
+
params = ''
|
146
|
+
params += "action=#{args[:action]}&" unless args[:action].nil?
|
147
|
+
params += "after=#{args[:after]}&" unless args[:after].nil?
|
148
|
+
params += "before=#{args[:before]}&" unless args[:before].nil?
|
149
|
+
params += "sort=#{args[:sort]}&" unless args[:sort].nil?
|
150
|
+
params += "target_type=#{args[:target_type]}&" unless args[:target_type].nil?
|
151
|
+
array = []
|
152
|
+
page = 1
|
153
|
+
loop do
|
154
|
+
response = client.connection.get("projects/#{args[:project_id]}/events?#{params}&page=#{page}&per_page=100")
|
155
|
+
body = Oj.load(response.body)
|
156
|
+
array += body.map { |e| Events.new(e) }
|
157
|
+
break if body.count < 100
|
158
|
+
|
159
|
+
page += 1
|
160
|
+
end
|
161
|
+
array
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module SupportOps.
|
4
|
+
module SupportOps
|
5
|
+
# Defines the module GitLab
|
6
|
+
module GitLab
|
7
|
+
##
|
8
|
+
# Defines the class GPGKeys within the module {SupportOps::GitLab}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.0
|
12
|
+
# @attr [String] created_at Timestamp for when the key was created
|
13
|
+
# @attr [Integer] id ID value of the key
|
14
|
+
# @attr [String] key Public key value
|
15
|
+
# @todo Get an GPG key for a user > https://docs.gitlab.com/api/user_keys/#get-a-gpg-key-for-a-user
|
16
|
+
# @todo Add an GPG key for a user > https://docs.gitlab.com/api/user_keys/#add-a-gpg-key-for-a-user
|
17
|
+
# @todo Delete an GPG key for a user > https://docs.gitlab.com/api/user_keys/#delete-n-gpg-key-for-a-user
|
18
|
+
class GPGKeys < SupportOps::GitLab::Base
|
19
|
+
define_attributes :created_at, :id, :key
|
20
|
+
readonly_attributes :created_at, :id
|
21
|
+
|
22
|
+
##
|
23
|
+
# Lists all GPG keys for a user
|
24
|
+
#
|
25
|
+
# @author Jason Colyer
|
26
|
+
# @since 1.0.0
|
27
|
+
# @overload list(key: value)
|
28
|
+
# @param user_id [Integer optional] The user ID to get SSH keys of (not
|
29
|
+
# including this does it for the current user)
|
30
|
+
# @return [Array]
|
31
|
+
# @see
|
32
|
+
# https://docs.gitlab.com/api/user_keys/#list-all-gpg-keys-for-a-user
|
33
|
+
# GitLab API > SSH and GPG Keys > List all GPG keys for a user
|
34
|
+
# @see SupportOps::GitLab::Configuration Setting up a client
|
35
|
+
# @example
|
36
|
+
# require 'support_ops_gitlab'
|
37
|
+
#
|
38
|
+
# SupportOps::GitLab::Configuration.configure do |config|
|
39
|
+
# config.url = 'https://gitlab.example.com/api/v4'
|
40
|
+
# config.token = 'abc123'
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# keys = SupportOps::GitLab::GPGKeys.list(user_id: 123456)
|
44
|
+
# pp keys.count
|
45
|
+
# # => 3
|
46
|
+
# pp keys.last.id
|
47
|
+
# # => 789
|
48
|
+
def self.list(**args)
|
49
|
+
args[:user_id] = nil unless args[:user_id]
|
50
|
+
url = if args[:user_id].nil?
|
51
|
+
'user/gpg_keys'
|
52
|
+
else
|
53
|
+
"users/#{args[:user_id]}/gpg_keys"
|
54
|
+
end
|
55
|
+
response = client.connection.get(url)
|
56
|
+
body = Oj.load(response.body)
|
57
|
+
raise "Unable to get GPG keys of user => #{body}" if response.status != 200
|
58
|
+
body.map { |g| GPGKeys.new(g) }
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module SupportOps.
|
4
|
+
module SupportOps
|
5
|
+
# Defines the module GitLab
|
6
|
+
module GitLab
|
7
|
+
##
|
8
|
+
# Defines the class GroupMemberships within the module {SupportOps::GitLab}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.0
|
12
|
+
# @attr [Integer] access_level The membership level
|
13
|
+
# @attr [String] avatar_url URL of the user's avatar
|
14
|
+
# @attr [String] created_at The time the membership was created at
|
15
|
+
# @attr [Hash] created_by A hash containing information on who created the membership
|
16
|
+
# @attr [String] email The email of the user
|
17
|
+
# @attr [String] expires_at The timestamp when the membership expires
|
18
|
+
# @attr [Hash] group_saml_identity A hash containing the group's SAML information tied to the membership
|
19
|
+
# @attr [Integer] id The user's ID
|
20
|
+
# @attr [String] name The name of the user
|
21
|
+
# @attr [String] state The state of the membership, can be awaiting or active
|
22
|
+
# @attr [String] username The username of the user
|
23
|
+
# @attr [String] web_url The web URL of theuser
|
24
|
+
class GroupMemberships < SupportOps::GitLab::Base
|
25
|
+
define_attributes :access_level, :avatar_url, :created_at, :created_by,
|
26
|
+
:email, :expires_at, :group_saml_identity, :id, :name,
|
27
|
+
:state, :username, :web_url
|
28
|
+
readonly_attributes :access_level, :avatar_url, :created_at, :created_by,
|
29
|
+
:email, :expires_at, :group_saml_identity, :id, :name,
|
30
|
+
:state, :username, :web_url
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|