class Fog::SakuraCloud::Script::Real
Public Class Methods
new(options = {})
click to toggle source
# File lib/fog/sakuracloud/script.rb, line 20 def initialize(options = {}) @auth_encode = Base64.strict_encode64([ options[:sakuracloud_api_token], options[:sakuracloud_api_token_secret] ].join(':')) Fog.credentials[:sakuracloud_api_token] = options[:sakuracloud_api_token] Fog.credentials[:sakuracloud_api_token_secret] = options[:sakuracloud_api_token_secret] @sakuracloud_api_url = options[:sakuracloud_api_url] || 'https://secure.sakura.ad.jp' @connection = Fog::Core::Connection.new(@sakuracloud_api_url) end
Public Instance Methods
create_note(options)
click to toggle source
# File lib/fog/sakuracloud/requests/script/create_note.rb, line 6 def create_note(options) body = { "Note" => { "Name" => options[:name], "Content" => options[:content] } } request( :headers => { 'Authorization' => "Basic #{@auth_encode}" }, :expects => 201, :method => 'POST', :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/note", :body => Fog::JSON.encode(body) ) end
delete_note( id )
click to toggle source
# File lib/fog/sakuracloud/requests/script/delete_note.rb, line 6 def delete_note( id ) request( :headers => { 'Authorization' => "Basic #{@auth_encode}" }, :expects => [200], :method => 'DELETE', :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/note/#{id}" ) end
list_notes(options = {})
click to toggle source
# File lib/fog/sakuracloud/requests/script/list_notes.rb, line 6 def list_notes(options = {}) request( :headers => { 'Authorization' => "Basic #{@auth_encode}" }, :method => 'GET', :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/note" ) end
modify_note( options )
click to toggle source
# File lib/fog/sakuracloud/requests/script/modify_note.rb, line 6 def modify_note( options ) body = { "Note" => { "Name" => options[:name], "Content" => options[:content] } } request( :headers => { 'Authorization' => "Basic #{@auth_encode}" }, :expects => [200], :method => 'PUT', :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/note/#{options[:id]}", :body => Fog::JSON.encode(body) ) end
request(params)
click to toggle source
# File lib/fog/sakuracloud/script.rb, line 33 def request(params) response = parse @connection.request(params) response end
Private Instance Methods
parse(response)
click to toggle source
# File lib/fog/sakuracloud/script.rb, line 39 def parse(response) return response if response.body.empty? response.body = Fog::JSON.decode(response.body) response end