Class: Qtc::Cli::Platform::User
- Inherits:
-
Object
- Object
- Qtc::Cli::Platform::User
show all
- Includes:
- Common
- Defined in:
- lib/qtc/cli/platform/user.rb
Instance Attribute Summary
Attributes included from Common
#datacenter_id
Instance Method Summary
collapse
Methods included from Common
#client, #current_cloud_dc, #current_cloud_id, #current_cloud_token, #extract_app_in_dir, #ini_filename, #inifile, #instance_info, #platform_base_url, #platform_client
Instance Method Details
#login(opts) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/qtc/cli/platform/user.rb', line 8
def login(opts)
if opts.token
inifile['platform']['token'] = opts.token
else
pass = password("Personal Access Token (copy from https://console.qtcloudservices.com/#/user/profile):")
inifile['platform']['token'] = pass
end
response = platform_client(pass).get('/user/accounts', {}) rescue nil
if response
inifile.save(filename: ini_filename)
else
print color('Invalid Personal Access Token', :red)
end
end
|
#logout ⇒ Object
24
25
26
27
|
# File 'lib/qtc/cli/platform/user.rb', line 24
def logout
inifile['platform'].delete('token')
inifile.save(filename: ini_filename)
end
|