Class: Megam::CloudToolSetting
- Inherits:
-
Object
- Object
- Megam::CloudToolSetting
- Defined in:
- lib/megam/core/cloudtoolsetting.rb
Class Method Summary collapse
- .create(o) ⇒ Object
- .from_hash(o) ⇒ Object
- .json_create(o) ⇒ Object
-
.list ⇒ Object
Load all cloudtoolsettings - returns a cloudtoolsettingsCollection don't return self.
-
.show(p_name) ⇒ Object
Show a particular cloudtoolsetting by name, Megam::cloudtoolsetting.
Instance Method Summary collapse
- #accounts_id(arg = nil) ⇒ Object
- #cloud_tool_setting ⇒ Object
- #cloud_type(arg = nil) ⇒ Object
-
#create ⇒ Object
Create the cloudtoolsetting via the REST API.
- #created_at(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize ⇒ CloudToolSetting
constructor
Each notify entry is a resource/action pair, modeled as an Struct with a #resource and #action member.
- #megam_rest ⇒ Object
- #repo(arg = nil) ⇒ Object
- #some_msg(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
-
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat.
- #to_s ⇒ Object
- #vault_location(arg = nil) ⇒ Object
Constructor Details
#initialize ⇒ CloudToolSetting
Each notify entry is a resource/action pair, modeled as an Struct with a #resource and #action member
21 22 23 24 25 26 27 28 29 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 21 def initialize @id = nil @accounts_id = nil @cloud_type = nil @repo = nil @vault_location=nil @created_at = nil @some_msg = {} end |
Class Method Details
.create(o) ⇒ Object
166 167 168 169 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 166 def self.create(o) acct = from_hash(o) acct.create end |
.from_hash(o) ⇒ Object
150 151 152 153 154 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 150 def self.from_hash(o) cts = self.new() cts.from_hash(o) cts end |
.json_create(o) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 133 def self.json_create(o) cts = new cts.id(o["id"]) if o.has_key?("id") cts.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id") cts.cloud_type(o["cloud_type"]) if o.has_key?("cloud_type") cts.repo(o["repo"]) if o.has_key?("repo") cts.vault_location(o["vault_location"]) if o.has_key?("vault_location") cts.created_at(o["created_at"]) if o.has_key?("created_at") #success or error cts.some_msg[:code] = o["code"] if o.has_key?("code") cts.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") cts.some_msg[:msg]= o["msg"] if o.has_key?("msg") cts.some_msg[:links] = o["links"] if o.has_key?("links") cts end |
.list ⇒ Object
Load all cloudtoolsettings - returns a cloudtoolsettingsCollection don't return self. check if the Megam::cloudtoolsettingCollection is returned.
179 180 181 182 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 179 def self.list cts = self.new() cts.megam_rest.get_cloudtoolsettings end |
.show(p_name) ⇒ Object
Show a particular cloudtoolsetting by name, Megam::cloudtoolsetting
186 187 188 189 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 186 def self.show(p_name) pre = self.new() pre.megam_rest.get_cloudtoolsetting(p_name) end |
Instance Method Details
#accounts_id(arg = nil) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 48 def accounts_id(arg=nil) if arg != nil @accounts_id= arg else @accounts_id end end |
#cloud_tool_setting ⇒ Object
31 32 33 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 31 def cloud_tool_setting self end |
#cloud_type(arg = nil) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 56 def cloud_type(arg=nil) if arg != nil @cloud_type = arg else @cloud_type end end |
#create ⇒ Object
Create the cloudtoolsetting via the REST API
172 173 174 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 172 def create megam_rest.post_cloudtoolsetting(to_hash) end |
#created_at(arg = nil) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 80 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
96 97 98 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 96 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 120 def for_json result = { "id" => id, "accounts_id" => accounts_id, "cloud_type" => cloud_type, "repo" => repo, "vault_location" => vault_location, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 156 def from_hash(o) @id = o[:id] if o.has_key?(:id) @accounts_id = o[:accounts_id] if o.has_key?(:accounts_id) @cloud_type = o[:cloud_type] if o.has_key?(:cloud_type) @repo = o[:repo] if o.has_key?(:repo) @vault_location = o[:vault_location] if o.has_key?(:vault_location) @created_at = o[:created_at] if o.has_key?(:created_at) self end |
#id(arg = nil) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 40 def id(arg=nil) if arg != nil @id = arg else @id end end |
#megam_rest ⇒ Object
35 36 37 38 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 35 def megam_rest = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]} Megam::API.new() end |
#repo(arg = nil) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 64 def repo(arg=nil) if arg != nil @repo = arg else @repo end end |
#some_msg(arg = nil) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 88 def some_msg(arg=nil) if arg != nil @some_msg = arg else @some_msg end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 101 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["accounts_id"] = accounts_id index_hash["cloud_type"] = cloud_type index_hash["repo"] = repo index_hash["vault_location"] = vault_location index_hash["created_at"] = created_at index_hash["some_msg"] = some_msg index_hash end |
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
116 117 118 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 116 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
191 192 193 194 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 191 def to_s Megam::Stuff.styled_hash(to_hash) #"---> Megam::Account:[error=#{error?}]\n"+ end |
#vault_location(arg = nil) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 72 def vault_location(arg=nil) if arg != nil @vault_location= arg else @vault_location end end |