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
- #conf_location(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
- #repo_name(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
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 20 def initialize @id = nil @accounts_id = nil @cloud_type = nil @repo_name = nil @repo = nil @vault_location=nil @conf_location=nil @created_at = nil @some_msg = {} end |
Class Method Details
.create(o) ⇒ Object
191 192 193 194 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 191 def self.create(o) acct = from_hash(o) acct.create end |
.from_hash(o) ⇒ Object
173 174 175 176 177 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 173 def self.from_hash(o) cts = self.new() cts.from_hash(o) cts end |
.json_create(o) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 154 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_name(o["repo_name"]) if o.has_key?("repo_name") cts.repo(o["repo"]) if o.has_key?("repo") cts.vault_location(o["vault_location"]) if o.has_key?("vault_location") cts.conf_location(o["conf_location"]) if o.has_key?("conf_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.
204 205 206 207 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 204 def self.list cts = self.new() cts.megam_rest.get_cloudtoolsettings end |
.show(p_name) ⇒ Object
Show a particular cloudtoolsetting by name, Megam::cloudtoolsetting
211 212 213 214 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 211 def self.show(p_name) pre = self.new() pre.megam_rest.get_cloudtoolsetting(p_name) end |
Instance Method Details
#accounts_id(arg = nil) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 49 def accounts_id(arg=nil) if arg != nil @accounts_id= arg else @accounts_id end end |
#cloud_tool_setting ⇒ Object
32 33 34 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 32 def cloud_tool_setting self end |
#cloud_type(arg = nil) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 57 def cloud_type(arg=nil) if arg != nil @cloud_type = arg else @cloud_type end end |
#conf_location(arg = nil) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 89 def conf_location(arg=nil) if arg != nil @conf_location= arg else @conf_location end end |
#create ⇒ Object
Create the cloudtoolsetting via the REST API
197 198 199 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 197 def create megam_rest.post_cloudtoolsetting(to_hash) end |
#created_at(arg = nil) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 97 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
113 114 115 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 113 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 139 def for_json result = { "id" => id, "accounts_id" => accounts_id, "cloud_type" => cloud_type, "repo" => repo, "repo_name" => repo_name, "vault_location" => vault_location, "conf_location" => conf_location, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 179 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_name = o[:repo_name] if o.has_key?(:repo_name) @repo = o[:repo] if o.has_key?(:repo) @vault_location = o[:vault_location] if o.has_key?(:vault_location) @conf_location = o[:conf_location] if o.has_key?(:conf_location) @created_at = o[:created_at] if o.has_key?(:created_at) self end |
#id(arg = nil) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 41 def id(arg=nil) if arg != nil @id = arg else @id end end |
#megam_rest ⇒ Object
36 37 38 39 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 36 def megam_rest = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]} Megam::API.new() end |
#repo(arg = nil) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 73 def repo(arg=nil) if arg != nil @repo = arg else @repo end end |
#repo_name(arg = nil) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 65 def repo_name(arg=nil) if arg != nil @repo_name = arg else @repo_name end end |
#some_msg(arg = nil) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 105 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
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 118 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_name"] = repo_name index_hash["repo"] = repo index_hash["vault_location"] = vault_location index_hash["conf_location"] = conf_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.
135 136 137 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 135 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
216 217 218 219 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 216 def to_s Megam::Stuff.styled_hash(to_hash) #"---> Megam::Account:[error=#{error?}]\n"+ end |
#vault_location(arg = nil) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/megam/core/cloudtoolsetting.rb', line 81 def vault_location(arg=nil) if arg != nil @vault_location= arg else @vault_location end end |