Class: Ruboty::Niftycloud::Actions::Base
- Inherits:
-
Object
- Object
- Ruboty::Niftycloud::Actions::Base
show all
- Defined in:
- lib/ruboty/niftycloud/actions/base.rb
Direct Known Subclasses
AccountList, AccountUse, ComputingAddressList, ComputingAvailabilityZoneList, ComputingImageList, ComputingImageShow, ComputingInstanceList, ComputingInstanceShow, ComputingKeyPairList, ComputingLoadBalancerList, ComputingLoadBalancerShow, ComputingRegionList, ComputingRegionUse, ComputingSecurityGroupList, ComputingSecurityGroupShow, ComputingSslCertificateList, ComputingSslCertificateShow, ComputingVolumeList, ComputingVolumeShow, RdbDbInstanceList, RdbDbInstanceShow
Constant Summary
collapse
- NAMESPACE =
"niftycloud"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(message) ⇒ Base
Returns a new instance of Base.
12
13
14
|
# File 'lib/ruboty/niftycloud/actions/base.rb', line 12
def initialize(message)
@message = message
end
|
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
10
11
12
|
# File 'lib/ruboty/niftycloud/actions/base.rb', line 10
def message
@message
end
|
Instance Method Details
#accounts ⇒ Object
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/ruboty/niftycloud/actions/base.rb', line 16
def accounts
ENV["NIFTYCLOUD_ACCOUNTS"].split(",").map do |account|
{
name: account,
description: ENV["NIFTYCLOUD_ACCOUNT_#{account}_DESCRIPTION"],
access_key_id: ENV["NIFTYCLOUD_ACCOUNT_#{account}_ACCESS_KEY_ID"],
secret_access_key: ENV["NIFTYCLOUD_ACCOUNT_#{account}_SECRET_ACCESS_KEY"],
}
end
end
|
#computing ⇒ Object
46
47
48
49
50
|
# File 'lib/ruboty/niftycloud/actions/base.rb', line 46
def computing
AceClient::Niftycloud::Computing.build_client(
current_account.merge(endpoint: "#{current_region}.cp.cloud.nifty.com", path: '/api')
)
end
|
#current_account(account = nil) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/ruboty/niftycloud/actions/base.rb', line 27
def current_account(account=nil)
message.robot.brain.data[NAMESPACE] ||= {}
if account
message.robot.brain.data[NAMESPACE]["current_account"] = account
else
name = message.robot.brain.data[NAMESPACE]["current_account"] || ENV["NIFTYCLOUD_DEFAULT_ACCOUNT"]
accounts.find {|account| account[:name] == name }
end
end
|
#current_region(region = nil) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/ruboty/niftycloud/actions/base.rb', line 37
def current_region(region=nil)
message.robot.brain.data[NAMESPACE] ||= {}
if region
message.robot.brain.data[NAMESPACE]["current_region"] = region
else
message.robot.brain.data[NAMESPACE]["current_region"] || 'east-1'
end
end
|
#rdb ⇒ Object
52
53
54
55
56
|
# File 'lib/ruboty/niftycloud/actions/base.rb', line 52
def rdb
AceClient::Niftycloud::Rdb.build_client(
current_account.merge(endpoint: "rdb.jp-#{current_region}.api.cloud.nifty.com")
)
end
|