labclient 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/labclient.rb +6 -0
- data/lib/labclient/client.rb +7 -2
- data/lib/labclient/feature_flags/create.rb +48 -0
- data/lib/labclient/feature_flags/delete.rb +23 -0
- data/lib/labclient/feature_flags/feature_flag.rb +35 -0
- data/lib/labclient/feature_flags/list.rb +49 -0
- data/lib/labclient/generator/generator.rb +10 -0
- data/lib/labclient/klass.rb +6 -1
- data/lib/labclient/overview.rb +12 -3
- data/lib/labclient/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c77fa948bc39c9ec7d677340949a7bc52ed03999c4cb5286d125154edb06f9b
|
4
|
+
data.tar.gz: fa96ed5df9a9ddf7eea56cd7eb7a34832b4a9509d982159fd8069c5ae49de241
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2148330fb1c533956e2f51085729c7c8e96b8fc27e21b43bbbac2b492906047bc52d964b203fe42ac86fc2f041310ab6c6b4e7f90ae5935efcedaf11674a4363
|
7
|
+
data.tar.gz: 004cbd92b60fd45996a4ecd9ae38039b3bae703a22f4d804e34390a56662a0f0859992295a83bf0d53f7e4e6191e2c9f416fcc4b7618e54e1b944c73aa4478fc
|
data/lib/labclient.rb
CHANGED
@@ -857,6 +857,12 @@ require 'labclient/resource_labels/merge_requests/client'
|
|
857
857
|
require 'labclient/resource_labels/merge_requests/list'
|
858
858
|
require 'labclient/resource_labels/merge_requests/show'
|
859
859
|
|
860
|
+
# Feature Flags
|
861
|
+
require 'labclient/feature_flags/create'
|
862
|
+
require 'labclient/feature_flags/delete'
|
863
|
+
require 'labclient/feature_flags/list'
|
864
|
+
require 'labclient/feature_flags/feature_flag'
|
865
|
+
|
860
866
|
require 'labclient/resource_labels/resource_label'
|
861
867
|
|
862
868
|
# Generators
|
data/lib/labclient/client.rb
CHANGED
@@ -37,8 +37,8 @@ module LabClient
|
|
37
37
|
discussions: Discussions,
|
38
38
|
epics: Epics,
|
39
39
|
events: Events,
|
40
|
+
feature_flags: FeatureFlags,
|
40
41
|
files: Files,
|
41
|
-
wizard: Generator::Wizard,
|
42
42
|
groups: Groups,
|
43
43
|
impersonation_tokens: ImpersonationTokens,
|
44
44
|
issues: Issues,
|
@@ -69,7 +69,8 @@ module LabClient
|
|
69
69
|
todos: Todos,
|
70
70
|
users: Users,
|
71
71
|
version: Version,
|
72
|
-
wikis: Wikis
|
72
|
+
wikis: Wikis,
|
73
|
+
wizard: Generator::Wizard
|
73
74
|
}
|
74
75
|
|
75
76
|
@subclasses.each do |name, obj|
|
@@ -116,6 +117,10 @@ module LabClient
|
|
116
117
|
self.http = HTTP.new(@settings)
|
117
118
|
end
|
118
119
|
|
120
|
+
def base_url
|
121
|
+
"#{settings[:url]}/api/v4/"
|
122
|
+
end
|
123
|
+
|
119
124
|
def prompt_for_url
|
120
125
|
print 'Enter GitLab URL (e.g. https://gitlab.com): '
|
121
126
|
@settings[:url] = $stdin.gets.chomp
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Specifics
|
4
|
+
class FeatureFlags < Common
|
5
|
+
doc 'Create' do
|
6
|
+
title 'Set or create a feature'
|
7
|
+
example 'client.feature_flags.create(:create_eks_clusters, value: true)'
|
8
|
+
result <<~DOC
|
9
|
+
=> #<FeatureFlag name: create_eks_clusters, state: on
|
10
|
+
DOC
|
11
|
+
end
|
12
|
+
|
13
|
+
doc 'Attributes' do
|
14
|
+
desc 'Register a new Application'
|
15
|
+
markdown <<~DOC
|
16
|
+
| Attribute | Type | Required | Description |
|
17
|
+
| --------- | ---- | -------- | ----------- |
|
18
|
+
| name | string | yes | Name of the feature to create or update |
|
19
|
+
| value | integer/string | yes | `true` or `false` to enable/disable, or an integer for percentage of time |
|
20
|
+
| feature_group | string | no | A Feature group name |
|
21
|
+
| user | string | no | A GitLab username |
|
22
|
+
| group | string | no | A GitLab group's path, for example gitlab-org |
|
23
|
+
| project | string | no | A projects path, for example gitlab-org/gitlab-foss |
|
24
|
+
|
25
|
+
Note that you can enable or disable a feature for a `feature_group`, a `user`,
|
26
|
+
a `group`, and a `project` in a single API call.
|
27
|
+
DOC
|
28
|
+
end
|
29
|
+
|
30
|
+
doc 'Create' do
|
31
|
+
example <<~DOC
|
32
|
+
client.applications.create(
|
33
|
+
name: "Grafana",
|
34
|
+
redirect_uri: "https://gitlab.com/-/grafana/login/gitlab",
|
35
|
+
scopes: "email"
|
36
|
+
)
|
37
|
+
DOC
|
38
|
+
result <<~DOC
|
39
|
+
#<Application id: 11, Grafana>
|
40
|
+
DOC
|
41
|
+
end
|
42
|
+
|
43
|
+
# Create
|
44
|
+
def create(name, query = {})
|
45
|
+
client.request(:post, "features/#{name}", FeatureFlag, query)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Specifics
|
4
|
+
class FeatureFlags < Common
|
5
|
+
doc 'Delete' do
|
6
|
+
title 'Delete a feature'
|
7
|
+
example 'client.feature_flags.delete(:name)'
|
8
|
+
end
|
9
|
+
|
10
|
+
doc 'Delete' do
|
11
|
+
desc 'Delete via FeatureFlag'
|
12
|
+
example <<~DOC
|
13
|
+
feature = client.feature_flags.list.first
|
14
|
+
feature.delete
|
15
|
+
DOC
|
16
|
+
end
|
17
|
+
|
18
|
+
# Delete
|
19
|
+
def delete(name)
|
20
|
+
client.request(:delete, "features/#{name}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Inspect Helper
|
4
|
+
class FeatureFlag < Klass
|
5
|
+
include ClassHelpers
|
6
|
+
def inspect
|
7
|
+
"#<FeatureFlag name: #{name}, state: #{state}>"
|
8
|
+
end
|
9
|
+
|
10
|
+
def delete
|
11
|
+
client.feature_flags.delete name
|
12
|
+
end
|
13
|
+
|
14
|
+
def update(query)
|
15
|
+
update_self client.feature_flags.create(name, query)
|
16
|
+
end
|
17
|
+
|
18
|
+
def toggle
|
19
|
+
if state == 'off'
|
20
|
+
update(value: true)
|
21
|
+
else
|
22
|
+
update(value: false)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
date_time_attrs %i[created_at]
|
27
|
+
|
28
|
+
help do
|
29
|
+
subtitle 'Feature Flag'
|
30
|
+
option 'delete', 'Delete this specific feature flag'
|
31
|
+
option 'toggle', 'Disable / Turn on feature'
|
32
|
+
option 'update', 'Create flag / Update with values [Hash]'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Top namespace
|
2
|
+
module LabClient
|
3
|
+
# Specifics
|
4
|
+
class FeatureFlags < Common
|
5
|
+
doc 'List' do
|
6
|
+
title 'List all features'
|
7
|
+
desc 'Get a list of all persisted features, with its gate values.'
|
8
|
+
example 'client.feature_flags.list'
|
9
|
+
result <<~DOC
|
10
|
+
=> [#<Feature name: create_eks_clusters, state: on>]
|
11
|
+
DOC
|
12
|
+
end
|
13
|
+
|
14
|
+
doc 'List' do
|
15
|
+
title 'View detail of features'
|
16
|
+
desc 'Retrieve detailed information of feature flags'
|
17
|
+
example 'client.feature_flags.list.each(&:verbose)'
|
18
|
+
result <<~DOC
|
19
|
+
LabClient::Feature {
|
20
|
+
:name => "create_eks_clusters",
|
21
|
+
:state => "on",
|
22
|
+
:gates => [
|
23
|
+
[0] OpenStruct {
|
24
|
+
:key => "boolean",
|
25
|
+
:value => true
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
29
|
+
=> [#<Feature name: create_eks_clusters, state: on>]
|
30
|
+
DOC
|
31
|
+
end
|
32
|
+
|
33
|
+
doc 'List' do
|
34
|
+
title 'Toggle all features on or off'
|
35
|
+
example <<~DOC
|
36
|
+
client.feature_flags.list.each(&:toggle)
|
37
|
+
DOC
|
38
|
+
result <<~DOC
|
39
|
+
[#<Feature name: create_eks_clusters, state: off>,
|
40
|
+
#<Feature name: merge_train1, state: off>,
|
41
|
+
#<Feature name: merge_train2, state: off>]
|
42
|
+
DOC
|
43
|
+
end
|
44
|
+
|
45
|
+
def list
|
46
|
+
client.request(:get, 'features', FeatureFlag)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -26,6 +26,16 @@ module LabClient
|
|
26
26
|
example 'gem install faker'
|
27
27
|
end
|
28
28
|
|
29
|
+
doc 'Wizard' do
|
30
|
+
title 'Quickstart'
|
31
|
+
desc 'To run, create the client/wizard and run!'
|
32
|
+
example <<~DOC
|
33
|
+
require 'labclient'
|
34
|
+
client = LabClient::Client.new(url: 'https://labclient', token: 'super_secret')
|
35
|
+
client.wizard.run!
|
36
|
+
DOC
|
37
|
+
end
|
38
|
+
|
29
39
|
doc 'Wizard' do
|
30
40
|
title 'Client'
|
31
41
|
desc <<-DOC
|
data/lib/labclient/klass.rb
CHANGED
@@ -61,7 +61,12 @@ module LabClient
|
|
61
61
|
|
62
62
|
# TODO: Combine all of these?
|
63
63
|
def collect_project_id(position = 1)
|
64
|
-
|
64
|
+
# Check if Path / Pagination will be blank
|
65
|
+
if response.path.nil?
|
66
|
+
response.request.base_url.split(@client.base_url, 2)[position]
|
67
|
+
else
|
68
|
+
response.path.split('/')[position]
|
69
|
+
end
|
65
70
|
end
|
66
71
|
|
67
72
|
alias collect_group_id collect_project_id
|
data/lib/labclient/overview.rb
CHANGED
@@ -8,11 +8,20 @@ module LabClient
|
|
8
8
|
doc 'Overview' do
|
9
9
|
title 'About'
|
10
10
|
markdown <<~DOC
|
11
|
-
|
11
|
+
LabClient is a Gitlab API Gem. Focusing on ease of use, documentation, helpers, and snippets.
|
12
12
|
|
13
|
-
|
13
|
+
- Objects for resources (User, Project)
|
14
|
+
- Method Chaining ( project.branch(:master).pipelines )
|
15
|
+
|
16
|
+
Lots of Helpers
|
17
|
+
|
18
|
+
- Pagination
|
19
|
+
- IRB/Pry
|
20
|
+
- Setup: credentials file, profiles, and prompt
|
21
|
+
- Permission Levels
|
22
|
+
- Curl generator
|
14
23
|
|
15
|
-
Here
|
24
|
+
Here is a quick whirlwind example of some of the features:
|
16
25
|
DOC
|
17
26
|
|
18
27
|
demo '350689'
|
data/lib/labclient/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: labclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davin Walker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -398,6 +398,10 @@ files:
|
|
398
398
|
- lib/labclient/events/list.rb
|
399
399
|
- lib/labclient/events/project.rb
|
400
400
|
- lib/labclient/events/user.rb
|
401
|
+
- lib/labclient/feature_flags/create.rb
|
402
|
+
- lib/labclient/feature_flags/delete.rb
|
403
|
+
- lib/labclient/feature_flags/feature_flag.rb
|
404
|
+
- lib/labclient/feature_flags/list.rb
|
401
405
|
- lib/labclient/files/create.rb
|
402
406
|
- lib/labclient/files/delete.rb
|
403
407
|
- lib/labclient/files/show.rb
|
@@ -909,7 +913,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
909
913
|
- !ruby/object:Gem::Version
|
910
914
|
version: '0'
|
911
915
|
requirements: []
|
912
|
-
rubygems_version: 3.
|
916
|
+
rubygems_version: 3.1.4
|
913
917
|
signing_key:
|
914
918
|
specification_version: 4
|
915
919
|
summary: Gitlab API Client
|