Class: Saklient::Cloud::API

Inherits:
Object
  • Object
show all
Defined in:
lib/saklient/cloud/api.rb

Overview

さくらのクラウドAPIクライアントを利用する際, 最初にアクセスすべきルートとなるクラス.

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#applianceSaklient::Cloud::Models::Model_Appliance (readonly)

アプライアンスにアクセスするためのモデル.



186
187
188
# File 'lib/saklient/cloud/api.rb', line 186

def appliance
  @appliance
end

#archiveSaklient::Cloud::Models::Model_Archive (readonly)

アーカイブにアクセスするためのモデル.



209
210
211
# File 'lib/saklient/cloud/api.rb', line 209

def archive
  @archive
end

#bridgeSaklient::Cloud::Models::Model_Bridge (readonly)

ブリッジにアクセスするためのモデル.



324
325
326
# File 'lib/saklient/cloud/api.rb', line 324

def bridge
  @bridge
end

#clientClient (readonly)

Returns:



48
49
50
# File 'lib/saklient/cloud/api.rb', line 48

def client
  @client
end

#common_service_itemSaklient::Cloud::Models::Model_CommonServiceItem (readonly)

共通サービス契約にアクセスするためのモデル.



393
394
395
# File 'lib/saklient/cloud/api.rb', line 393

def common_service_item
  @common_service_item
end

#diskSaklient::Cloud::Models::Model_Disk (readonly)

ディスクにアクセスするためのモデル.



163
164
165
# File 'lib/saklient/cloud/api.rb', line 163

def disk
  @disk
end

#facilityFacility (readonly)

設備情報にアクセスするためのモデルを集めたオブジェクト.

Returns:



94
95
96
# File 'lib/saklient/cloud/api.rb', line 94

def facility
  @facility
end

#iconSaklient::Cloud::Models::Model_Icon (readonly)

アイコンにアクセスするためのモデル.



117
118
119
# File 'lib/saklient/cloud/api.rb', line 117

def icon
  @icon
end

#ifaceSaklient::Cloud::Models::Model_Iface (readonly)

インタフェースにアクセスするためのモデル.



255
256
257
# File 'lib/saklient/cloud/api.rb', line 255

def iface
  @iface
end

#ipv6_netSaklient::Cloud::Models::Model_Ipv6Net (readonly)

IPv6ネットワークにアクセスするためのモデル.



347
348
349
# File 'lib/saklient/cloud/api.rb', line 347

def ipv6_net
  @ipv6_net
end

#iso_imageSaklient::Cloud::Models::Model_IsoImage (readonly)

ISOイメージにアクセスするためのモデル.



232
233
234
# File 'lib/saklient/cloud/api.rb', line 232

def iso_image
  @iso_image
end

#licenseSaklient::Cloud::Models::Model_License (readonly)

ライセンスにアクセスするためのモデル.



416
417
418
# File 'lib/saklient/cloud/api.rb', line 416

def license
  @license
end

#productProduct (readonly)

商品情報にアクセスするためのモデルを集めたオブジェクト.

Returns:



71
72
73
# File 'lib/saklient/cloud/api.rb', line 71

def product
  @product
end

#routerSaklient::Cloud::Models::Model_Router (readonly)

ルータにアクセスするためのモデル.



301
302
303
# File 'lib/saklient/cloud/api.rb', line 301

def router
  @router
end

#scriptSaklient::Cloud::Models::Model_Script (readonly)

スクリプトにアクセスするためのモデル.



370
371
372
# File 'lib/saklient/cloud/api.rb', line 370

def script
  @script
end

#serverSaklient::Cloud::Models::Model_Server (readonly)

サーバにアクセスするためのモデル.



140
141
142
# File 'lib/saklient/cloud/api.rb', line 140

def server
  @server
end

#swytchSaklient::Cloud::Models::Model_Swytch (readonly)

スイッチにアクセスするためのモデル.



278
279
280
# File 'lib/saklient/cloud/api.rb', line 278

def swytch
  @swytch
end

Class Method Details

.authorize(token, secret, zone = nil) ⇒ API

指定した認証情報を用いてアクセスを行うAPIクライアントを作成します.

必要な認証情報は, コントロールパネル右上にあるアカウントのプルダウンから 「設定」を選択し, 「APIキー」のページにて作成できます.

Parameters:

  • token (String)

    ACCESS TOKEN

  • secret (String)

    ACCESS TOKEN SECRET

  • zone (String) (defaults to: nil)

    ゾーン名

Returns:

  • (API)

    APIクライアント



458
459
460
461
462
463
464
465
# File 'lib/saklient/cloud/api.rb', line 458

def self.authorize(token, secret, zone = nil)
  Saklient::Util::validate_type(token, 'String')
  Saklient::Util::validate_type(secret, 'String')
  Saklient::Util::validate_type(zone, 'String')
  c = Saklient::Cloud::Client.new(token, secret)
  ret = Saklient::Cloud::API.new(c)
  return !(zone).nil? ? ret.in_zone(zone) : ret
end

Instance Method Details

#in_zone(name) ⇒ API

認証情報を引き継ぎ, 指定したゾーンへのアクセスを行うAPIクライアントを作成します.

Parameters:

  • name (String)

    ゾーン名

Returns:

  • (API)

    APIクライアント



471
472
473
474
475
476
477
478
479
# File 'lib/saklient/cloud/api.rb', line 471

def in_zone(name)
  Saklient::Util::validate_type(name, 'String')
  ret = Saklient::Cloud::API.new(@_client.clone_instance)
  suffix = ''
  suffix = '-test' if name == 'is1x' || name == 'is1y' || name == 'is1z' || name == 'tk1s'
  ret._client.set_api_root('https://secure.sakura.ad.jp/cloud' + suffix + '/')
  ret._client.set_api_root_suffix('zone/' + name)
  return ret
end