Class: Fog::SakuraCloud::Script::Mock
- Inherits:
-
Object
- Object
- Fog::SakuraCloud::Script::Mock
- Defined in:
- lib/fog/sakuracloud/requests/script/create_note.rb,
lib/fog/sakuracloud/script.rb,
lib/fog/sakuracloud/requests/script/list_notes.rb,
lib/fog/sakuracloud/requests/script/delete_note.rb,
lib/fog/sakuracloud/requests/script/modify_note.rb
Overview
Real
Class Method Summary collapse
Instance Method Summary collapse
- #create_note(options) ⇒ Object
- #data ⇒ Object
- #delete_note(id) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_notes(options = {}) ⇒ Object
- #modify_note(options) ⇒ Object
- #reset_data ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
51 52 53 54 |
# File 'lib/fog/sakuracloud/script.rb', line 51 def initialize(={}) @sakuracloud_api_token = [:sakuracloud_api_token] @sakuracloud_api_token_secret = [:sakuracloud_api_token_secret] end |
Class Method Details
.data ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/fog/sakuracloud/script.rb', line 39 def self.data @data ||= Hash.new do |hash, key| hash[key] = { :notes => [] } end end |
.reset ⇒ Object
47 48 49 |
# File 'lib/fog/sakuracloud/script.rb', line 47 def self.reset @data = nil end |
Instance Method Details
#create_note(options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/sakuracloud/requests/script/create_note.rb', line 28 def create_note() response = Excon::Response.new response.status = 201 response.body = { "Note"=> {"ID"=>"112700759852", "Name"=>"foobar", "Class"=>"shell", "Scope"=>"user", "Content"=>"#!/bin/bash", "Description"=>"", "Remark"=>nil, "Availability"=>"available", "CreatedAt"=>"2015-09-05T20:32:12+09:00", "ModifiedAt"=>"2015-09-05T20:32:12+09:00", "Icon"=>nil, "Tags"=>[]}, "Success"=>true, "is_ok"=>true} response end |
#data ⇒ Object
56 57 58 59 |
# File 'lib/fog/sakuracloud/script.rb', line 56 def data self.class.data[@sakuracloud_api_token] self.class.data[@sakuracloud_api_token_secret] end |
#delete_note(id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fog/sakuracloud/requests/script/delete_note.rb', line 20 def delete_note( id ) response = Excon::Response.new response.status = 200 response.body = { "Note"=> {"ID"=>"112700759822", "Name"=>"hogehoge2", "Class"=>"shell", "Scope"=>"user", "Content"=>"", "Description"=>"", "Remark"=>nil, "Availability"=>"available", "CreatedAt"=>"2015-09-05T20:04:24+09:00", "ModifiedAt"=>"2015-09-05T20:04:24+09:00", "Icon"=>nil, "Tags"=>[]}, "Success"=>true, "is_ok"=>true } response end |
#list_notes(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/sakuracloud/requests/script/list_notes.rb', line 19 def list_notes( = {}) response = Excon::Response.new response.status = 200 response.body = { "Internet"=>[ {"Index"=>0, "ID"=>"112600707538", "Switch"=>{ "ID"=>"112600707539", "Name"=>"router2" } } ], "is_ok"=>true } response end |
#modify_note(options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fog/sakuracloud/requests/script/modify_note.rb', line 28 def modify_note( ) response = Excon::Response.new response.status = 200 response.body = { "Note"=> {"ID"=>"112700759822", "Name"=>"hogehoge2", "Class"=>"shell", "Scope"=>"user", "Content"=>"", "Description"=>"", "Remark"=>nil, "Availability"=>"available", "CreatedAt"=>"2015-09-05T20:04:24+09:00", "ModifiedAt"=>"2015-09-05T20:04:24+09:00", "Icon"=>nil, "Tags"=>[]}, "Success"=>true, "is_ok"=>true } response end |
#reset_data ⇒ Object
61 62 63 64 |
# File 'lib/fog/sakuracloud/script.rb', line 61 def reset_data self.class.data.delete(@sakuracloud_api_token) self.class.data.delete(@sakuracloud_api_token_secret) end |