Class: Fog::SakuraCloud::Script::Real
- Inherits:
-
Object
- Object
- Fog::SakuraCloud::Script::Real
- Includes:
- Utils::Request
- Defined in:
- lib/fog/sakuracloud/script.rb,
lib/fog/sakuracloud/requests/script/list_notes.rb,
lib/fog/sakuracloud/requests/script/create_note.rb,
lib/fog/sakuracloud/requests/script/delete_note.rb,
lib/fog/sakuracloud/requests/script/modify_note.rb
Instance Method Summary collapse
- #create_note(options) ⇒ Object
- #delete_note(id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_notes(options = {}) ⇒ Object
- #modify_note(options) ⇒ Object
Methods included from Utils::Request
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/sakuracloud/script.rb', line 22 def initialize( = {}) @auth_encode = Base64.strict_encode64([ [:sakuracloud_api_token], [:sakuracloud_api_token_secret] ].join(':')) Fog.credentials[:sakuracloud_api_token] = [:sakuracloud_api_token] Fog.credentials[:sakuracloud_api_token_secret] = [:sakuracloud_api_token_secret] @sakuracloud_api_url = [:sakuracloud_api_url] || 'https://secure.sakura.ad.jp' @api_zone = [:api_zone] || Fog.credentials[:sakuracloud_api_zone] || 'is1b' Fog::SakuraCloud.validate_api_zone!(@api_zone) @connection = Fog::Core::Connection.new(@sakuracloud_api_url) end |
Instance Method Details
#create_note(options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/sakuracloud/requests/script/create_note.rb', line 7 def create_note() body = { "Note" => { "Name" => [:name], "Content" => [:content] } } request( :headers => { 'Authorization' => "Basic #{@auth_encode}" }, :expects => 201, :method => 'POST', :path => "#{Fog::SakuraCloud.build_endpoint(@api_zone)}/note", :body => Fog::JSON.encode(body) ) end |
#delete_note(id) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/sakuracloud/requests/script/delete_note.rb', line 7 def delete_note( id ) request( :headers => { 'Authorization' => "Basic #{@auth_encode}" }, :expects => [200], :method => 'DELETE', :path => "#{Fog::SakuraCloud.build_endpoint(@api_zone)}/note/#{id}" ) end |
#list_notes(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/sakuracloud/requests/script/list_notes.rb', line 7 def list_notes( = {}) request( :headers => { 'Authorization' => "Basic #{@auth_encode}" }, :method => 'GET', :path => "#{Fog::SakuraCloud.build_endpoint(@api_zone)}/note" ) end |
#modify_note(options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fog/sakuracloud/requests/script/modify_note.rb', line 7 def modify_note( ) body = { "Note" => { "Name" => [:name], "Content" => [:content] } } request( :headers => { 'Authorization' => "Basic #{@auth_encode}" }, :expects => [200], :method => 'PUT', :path => "#{Fog::SakuraCloud.build_endpoint(@api_zone)}/note/#{[:id]}", :body => Fog::JSON.encode(body) ) end |