Module: Superbot::Cloud
- Defined in:
- lib/superbot/cloud.rb,
lib/superbot/cloud/api.rb,
lib/superbot/cloud/web.rb,
lib/superbot/cloud/version.rb,
lib/superbot/cloud/cli/run_command.rb,
lib/superbot/cloud/cli/validations.rb,
lib/superbot/cloud/cli/root_command.rb,
lib/superbot/cloud/cli/test_command.rb,
lib/superbot/cloud/cli/login_command.rb,
lib/superbot/cloud/cli/token_command.rb,
lib/superbot/cloud/cli/logout_command.rb,
lib/superbot/cloud/cli/member_command.rb,
lib/superbot/cloud/cli/version_command.rb,
lib/superbot/cloud/cli/run/base_command.rb,
lib/superbot/cloud/cli/run/list_command.rb,
lib/superbot/cloud/cli/schedule_command.rb,
lib/superbot/cloud/cli/run/abort_command.rb,
lib/superbot/cloud/cli/run/scale_command.rb,
lib/superbot/cloud/cli/test/base_command.rb,
lib/superbot/cloud/cli/test/list_command.rb,
lib/superbot/cloud/cli/webdriver_command.rb,
lib/superbot/cloud/cli/member/add_command.rb,
lib/superbot/cloud/cli/run/create_command.rb,
lib/superbot/cloud/cli/token/base_command.rb,
lib/superbot/cloud/cli/token/list_command.rb,
lib/superbot/cloud/cli/member/base_command.rb,
lib/superbot/cloud/cli/member/list_command.rb,
lib/superbot/cloud/cli/run/console_command.rb,
lib/superbot/cloud/cli/test/delete_command.rb,
lib/superbot/cloud/cli/test/upload_command.rb,
lib/superbot/cloud/cli/organization_command.rb,
lib/superbot/cloud/cli/token/revoke_command.rb,
lib/superbot/cloud/cli/member/remove_command.rb,
lib/superbot/cloud/cli/schedule/base_command.rb,
lib/superbot/cloud/cli/schedule/list_command.rb,
lib/superbot/cloud/cli/test/download_command.rb,
lib/superbot/cloud/cli/login_required_command.rb,
lib/superbot/cloud/cli/token/generate_command.rb,
lib/superbot/cloud/cli/webdriver/base_command.rb,
lib/superbot/cloud/cli/webdriver/list_command.rb,
lib/superbot/cloud/cli/schedule/cancel_command.rb,
lib/superbot/cloud/cli/schedule/create_command.rb,
lib/superbot/cloud/cli/webdriver/create_command.rb,
lib/superbot/cloud/cli/webdriver/delete_command.rb,
lib/superbot/cloud/cli/organization/base_command.rb,
lib/superbot/cloud/cli/organization/list_command.rb,
lib/superbot/cloud/cli/organization_based_command.rb,
lib/superbot/cloud/cli/organization/default_command.rb
Defined Under Namespace
Modules: Api, CLI, Validations, Web
Constant Summary
collapse
- BASE_URI =
"#{Superbot::URI_SCHEME}://#{Superbot::DOMAIN}"
- LOGIN_URI =
"#{BASE_URI}/login/cloud"
- VERSION =
"0.3.8"
Class Method Summary
collapse
Class Method Details
.all_credentials ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/superbot/cloud.rb', line 16
def self.all_credentials
@all_credentials ||=
if File.exist?(CREDENTIALS_FILE_PATH)
JSON.parse(File.read(CREDENTIALS_FILE_PATH), symbolize_names: true)
else
{}
end
end
|
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/superbot/cloud.rb', line 37
def self.
@authorization_header ||= format(
'%<auth_type>s %<auth_token>s',
auth_type: ENV['SUPERBOT_TOKEN'] ? 'Bearer' : 'Basic',
auth_token: Base64.urlsafe_encode64(
ENV.fetch(
'SUPERBOT_TOKEN',
credentials&.values_at(:username, :token)&.join(':').to_s
)
)
)
end
|
.credentials ⇒ Object
12
13
14
|
# File 'lib/superbot/cloud.rb', line 12
def self.credentials
all_credentials[Superbot::DOMAIN.to_sym]
end
|
.remove_credentials ⇒ Object
31
32
33
34
35
|
# File 'lib/superbot/cloud.rb', line 31
def self.remove_credentials
abort "You are not logged in yet." unless credentials
all_credentials.delete(Superbot::DOMAIN.to_sym)
File.write CREDENTIALS_FILE_PATH, all_credentials.to_json
end
|
.save_credentials(data) ⇒ Object
25
26
27
28
29
|
# File 'lib/superbot/cloud.rb', line 25
def self.save_credentials(data)
all_credentials[Superbot::DOMAIN.to_sym] = data.transform_keys!(&:to_sym)
FileUtils.mkdir_p CREDENTIALS_PATH
File.write CREDENTIALS_FILE_PATH, all_credentials.to_json
end
|