superbot-cloud 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/superbot/cloud/api.rb +9 -6
- data/lib/superbot/cloud/cli/organization_based_command.rb +1 -1
- data/lib/superbot/cloud/cli/root_command.rb +3 -1
- data/lib/superbot/cloud/cli/token/base_command.rb +12 -0
- data/lib/superbot/cloud/cli/token/generate_command.rb +22 -0
- data/lib/superbot/cloud/cli/token/list_command.rb +35 -0
- data/lib/superbot/cloud/cli/token/revoke_command.rb +22 -0
- data/lib/superbot/cloud/cli/token_command.rb +18 -0
- data/lib/superbot/cloud/cli/webdriver/list_command.rb +0 -2
- data/lib/superbot/cloud/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4dbcec81d287ce7f963412a81a3061645dd519fe8951919b1bcabc870007857
|
4
|
+
data.tar.gz: aeafad6a71e729648875cbf35e7052864e7e09bf3ed9cc6c3966db0c93e19006
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa8790116ed3dd57d05b8b89760bd0e9ea2c38122cfa35b74c8ec0c2050828da54c6b3f26595830810a21fab989b9052d6fa0a4a9b8b1f3b85ea0646d24a89e2
|
7
|
+
data.tar.gz: 1b3544b4cc35c66cb80f63e645d78f69d3f2ec65d54aa86d2a7fb4c08a849ab31a9fddb890e1f8cec05c2492b37eec80e6718a0e38410ef28ce23d1533dbaa92
|
data/Gemfile.lock
CHANGED
data/lib/superbot/cloud/api.rb
CHANGED
@@ -18,6 +18,7 @@ module Superbot
|
|
18
18
|
cancel_schedule: { method: :delete, endpoint: 'schedules', required_param: :id },
|
19
19
|
webdriver_session_list: { method: :get, endpoint: 'webdriver_sessions' },
|
20
20
|
delete_webdriver_session: { method: :delete, endpoint: 'webdriver_sessions', required_param: :session_id },
|
21
|
+
get_webdriver_session: { method: :get, endpoint: 'webdriver_sessions', required_param: :session_id },
|
21
22
|
member_list: { method: :get, endpoint: 'members' },
|
22
23
|
add_member: { method: :post, endpoint: 'members' },
|
23
24
|
remove_member: { method: :delete, endpoint: 'members', required_param: :username },
|
@@ -25,7 +26,10 @@ module Superbot
|
|
25
26
|
abort_interactive_run: { method: :delete, endpoint: 'interactive_runs', required_param: :id },
|
26
27
|
update_interactive_run: { method: :patch, endpoint: 'interactive_runs', required_param: :id },
|
27
28
|
show_interactive_run: { method: :get, endpoint: 'interactive_runs', required_param: :id },
|
28
|
-
interactive_run_list: { method: :get, endpoint: 'interactive_runs' }
|
29
|
+
interactive_run_list: { method: :get, endpoint: 'interactive_runs' },
|
30
|
+
access_token_list: { method: :get, endpoint: 'access_tokens' },
|
31
|
+
create_access_token: { method: :post, endpoint: 'access_tokens' },
|
32
|
+
revoke_access_token: { method: :delete, endpoint: 'access_tokens', required_param: :token }
|
29
33
|
}.freeze
|
30
34
|
|
31
35
|
def self.request(type, params: {})
|
@@ -46,11 +50,10 @@ module Superbot
|
|
46
50
|
request_class.new(uri).tap { |r| r.set_form_data(params) }
|
47
51
|
end
|
48
52
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
)
|
53
|
+
auth_token = ENV['SUPERBOT_TOKEN'] || Superbot::Cloud.credentials&.slice(:username, :token)&.values&.join(':')
|
54
|
+
if auth_token
|
55
|
+
auth_type = ENV['SUPERBOT_TOKEN'] ? 'Bearer' : 'Basic'
|
56
|
+
req['Authorization'] = "#{auth_type} #{Base64.urlsafe_encode64(auth_token)}"
|
54
57
|
end
|
55
58
|
|
56
59
|
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
@@ -4,7 +4,7 @@ module Superbot
|
|
4
4
|
module Cloud
|
5
5
|
module CLI
|
6
6
|
class OrganizationBasedCommand < LoginRequiredCommand
|
7
|
-
option ["--org"], "ORGANIZATION", "Name of organization to take action on",
|
7
|
+
option ["--org"], "ORGANIZATION", "Name of organization to take action on", environment_variable: "SUPERBOT_ORG", required: ENV['SUPERBOT_TOKEN'].to_s.empty?, attribute_name: :organization
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -12,6 +12,7 @@ require_relative 'webdriver_command'
|
|
12
12
|
require_relative 'member_command'
|
13
13
|
require_relative 'schedule_command'
|
14
14
|
require_relative 'run_command'
|
15
|
+
require_relative 'token_command'
|
15
16
|
|
16
17
|
module Superbot
|
17
18
|
module Cloud
|
@@ -25,7 +26,8 @@ module Superbot
|
|
25
26
|
subcommand ['webdriver'], "Manage your webdriver sessions", WebdriverCommand
|
26
27
|
subcommand ['member'], "Manage your organization members", MemberCommand
|
27
28
|
subcommand ['schedule'], "Manage your schedules", ScheduleCommand
|
28
|
-
subcommand(['run'], "
|
29
|
+
subcommand(['run'], "Manage your interactive cloud runs", RunCommand) if ENV['SUPERBOT_FEAT_CLOUD_RUNS'] == 'true'
|
30
|
+
subcommand ['token'], "Manage your organization tokens", TokenCommand
|
29
31
|
|
30
32
|
option ['-v', '--version'], :flag, "Show version information" do
|
31
33
|
puts Superbot::Cloud::VERSION
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Superbot
|
4
|
+
module Cloud
|
5
|
+
module CLI
|
6
|
+
module Token
|
7
|
+
class GenerateCommand < BaseCommand
|
8
|
+
parameter "NAME", "Token title", required: true
|
9
|
+
|
10
|
+
def execute
|
11
|
+
generate_token
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_token
|
15
|
+
api_response = Superbot::Cloud::Api.request(:create_access_token, params: { organization_name: organization, name: name })
|
16
|
+
puts api_response[:token]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Superbot
|
4
|
+
module Cloud
|
5
|
+
module CLI
|
6
|
+
module Token
|
7
|
+
class ListCommand < BaseCommand
|
8
|
+
OUTPUT_HEADERS = {
|
9
|
+
name: "Title",
|
10
|
+
token: "Token",
|
11
|
+
scope: "API scope"
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
def execute
|
15
|
+
list_tokens
|
16
|
+
end
|
17
|
+
|
18
|
+
def list_tokens
|
19
|
+
api_response = Superbot::Cloud::Api.request(:access_token_list, params: { organization_name: organization })
|
20
|
+
puts "Organization: #{api_response[:organization]}"
|
21
|
+
puts "Access Tokens:"
|
22
|
+
puts(api_response[:access_tokens].map { |m| m[:username] })
|
23
|
+
|
24
|
+
puts "Organization: #{api_response[:organization]}"
|
25
|
+
puts OUTPUT_HEADERS.values.map { |header| header.ljust(35) }.join
|
26
|
+
puts ''.ljust(35 * OUTPUT_HEADERS.length, '-')
|
27
|
+
api_response[:access_tokens].each do |webdriver_session|
|
28
|
+
puts webdriver_session.slice(*OUTPUT_HEADERS.keys).values.map { |v| v.to_s.ljust(35) }.join
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Superbot
|
4
|
+
module Cloud
|
5
|
+
module CLI
|
6
|
+
module Token
|
7
|
+
class RevokeCommand < BaseCommand
|
8
|
+
parameter "TOKEN", "Access token to remove"
|
9
|
+
|
10
|
+
def execute
|
11
|
+
revoke_token
|
12
|
+
end
|
13
|
+
|
14
|
+
def revoke_token
|
15
|
+
api_response = Superbot::Cloud::Api.request(:revoke_access_token, params: { organization_name: organization, token: token })
|
16
|
+
puts "Token was successfully revoked"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'token/base_command'
|
4
|
+
require_relative 'token/generate_command'
|
5
|
+
require_relative 'token/revoke_command'
|
6
|
+
require_relative 'token/list_command'
|
7
|
+
|
8
|
+
module Superbot
|
9
|
+
module Cloud
|
10
|
+
module CLI
|
11
|
+
class TokenCommand < LoginRequiredCommand
|
12
|
+
subcommand ['generate'], "Generate new access token", Token::GenerateCommand
|
13
|
+
subcommand ['revoke'], "Revoke token", Token::RevokeCommand
|
14
|
+
subcommand ['list'], "List your organization access tokens", Token::ListCommand
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -21,8 +21,6 @@ module Superbot
|
|
21
21
|
def list_sessions
|
22
22
|
states = all? ? nil : %w[idle proxying]
|
23
23
|
api_response = Superbot::Cloud::Api.request(:webdriver_session_list, params: { organization_name: organization, 'aasm_state[]': states })
|
24
|
-
abort api_response[:error] if api_response[:error]
|
25
|
-
|
26
24
|
abort "No active sessions found for #{api_response[:organization]} organization" if api_response[:webdriver_sessions].empty?
|
27
25
|
|
28
26
|
if quiet?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superbot-cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Superbots
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|
@@ -166,6 +166,11 @@ files:
|
|
166
166
|
- lib/superbot/cloud/cli/test/list_command.rb
|
167
167
|
- lib/superbot/cloud/cli/test/upload_command.rb
|
168
168
|
- lib/superbot/cloud/cli/test_command.rb
|
169
|
+
- lib/superbot/cloud/cli/token/base_command.rb
|
170
|
+
- lib/superbot/cloud/cli/token/generate_command.rb
|
171
|
+
- lib/superbot/cloud/cli/token/list_command.rb
|
172
|
+
- lib/superbot/cloud/cli/token/revoke_command.rb
|
173
|
+
- lib/superbot/cloud/cli/token_command.rb
|
169
174
|
- lib/superbot/cloud/cli/validations.rb
|
170
175
|
- lib/superbot/cloud/cli/version_command.rb
|
171
176
|
- lib/superbot/cloud/cli/webdriver/base_command.rb
|