class Saklient::Cloud::Resources::Router

ルータの実体1つに対応し, 属性の取得や操作を行うためのクラス.

Attributes

_activity[RW]

@private @return [RouterActivity]

activity[R]

アクティビティ

@return [RouterActivity]

band_width_mbps[RW]

帯域幅

@return [Fixnum]

description[RW]

説明

@return [String]

id[R]

ID

@return [String]

m_band_width_mbps[RW]

帯域幅

@return [Fixnum]

m_description[RW]

説明

@return [String]

m_id[RW]

ID

@return [String]

m_name[RW]

名前

@return [String]

m_network_mask_len[RW]

ネットワークのマスク長

@return [Fixnum]

m_swytch_id[RW]

スイッチ

@return [String]

n_band_width_mbps[RW]

@return [bool]

n_description[RW]

@return [bool]

n_id[RW]

@return [bool]

n_name[RW]

@return [bool]

n_network_mask_len[RW]

@return [bool]

n_swytch_id[RW]

@return [bool]

name[RW]

名前

@return [String]

network_mask_len[RW]

ネットワークのマスク長

@return [Fixnum]

swytch_id[R]

スイッチ

@return [String]

Public Class Methods

new(client, obj, wrapped = false) click to toggle source

@private @param [Saklient::Cloud::Client] client @param [any] obj @param [bool] wrapped

# File lib/saklient/cloud/resources/router.rb, line 127
def initialize(client, obj, wrapped = false)
  super(client)
  Saklient::Util::validate_type(client, 'Saklient::Cloud::Client')
  Saklient::Util::validate_type(wrapped, 'bool')
  @_activity = Saklient::Cloud::Resources::RouterActivity.new(client)
  api_deserialize(obj, wrapped)
end

Public Instance Methods

_class_name() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 76
def _class_name
  return 'Router'
end
_id() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 82
def _id
  return get_id
end
add_ipv6_net() click to toggle source

このルータ+スイッチでIPv6アドレスを有効にします.

@return [Ipv6Net] 有効化されたIPv6ネットワーク

# File lib/saklient/cloud/resources/router.rb, line 197
def add_ipv6_net
  result = @_client.request('POST', _api_path + '/' + Saklient::Util::url_encode(_id) + '/ipv6net')
  reload
  return Saklient::Cloud::Resources::Ipv6Net.new(@_client, result[:IPv6Net])
end
add_static_route(maskLen, nextHop) click to toggle source

このルータ+スイッチにスタティックルートを追加します.

@param [Fixnum] maskLen @param [String] nextHop @return [Ipv4Net] 追加されたスタティックルート

# File lib/saklient/cloud/resources/router.rb, line 219
def add_static_route(maskLen, nextHop)
  Saklient::Util::validate_type(maskLen, 'Fixnum')
  Saklient::Util::validate_type(nextHop, 'String')
  q = {}
  Saklient::Util::set_by_path(q, 'NetworkMaskLen', maskLen)
  Saklient::Util::set_by_path(q, 'NextHop', nextHop)
  result = @_client.request('POST', _api_path + '/' + Saklient::Util::url_encode(_id) + '/subnet', q)
  reload
  return Saklient::Cloud::Resources::Ipv4Net.new(@_client, result[:Subnet])
end
after_create(timeoutSec, &callback) click to toggle source

作成中のルータが利用可能になるまで待機します.

@private @yield [Saklient::Cloud::Resources::Router, bool] @yieldreturn [void] @param [Fixnum] timeoutSec @return [void]

# File lib/saklient/cloud/resources/router.rb, line 154
def after_create(timeoutSec, &callback)
  Saklient::Util::validate_type(timeoutSec, 'Fixnum')
  Saklient::Util::validate_type(callback, 'Proc')
  ret = sleep_while_creating(timeoutSec)
  callback.call(self, ret)
end
band_width_mbps=(v) click to toggle source
# File lib/saklient/cloud/resources/router.rb, line 439
def band_width_mbps=(v)
  set_band_width_mbps(v)
end
change_plan(bandWidthMbps) click to toggle source

このルータ+スイッチの帯域プランを変更します.

成功時はリソースIDが変わることにご注意ください.

@param [Fixnum] bandWidthMbps @return [Router] this

# File lib/saklient/cloud/resources/router.rb, line 247
def change_plan(bandWidthMbps)
  Saklient::Util::validate_type(bandWidthMbps, 'Fixnum')
  path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/bandwidth'
  q = {}
  Saklient::Util::set_by_path(q, 'Internet.BandWidthMbps', bandWidthMbps)
  result = @_client.request('PUT', path, q)
  api_deserialize(result, true)
  return self
end
description=(v) click to toggle source
# File lib/saklient/cloud/resources/router.rb, line 357
def description=(v)
  set_description(v)
end
get_activity() click to toggle source

@private @return [RouterActivity]

# File lib/saklient/cloud/resources/router.rb, line 110
def get_activity
  return @_activity
end
get_swytch() click to toggle source

このルータが接続されているスイッチを取得します.

@return [Swytch]

# File lib/saklient/cloud/resources/router.rb, line 188
def get_swytch
  model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Swytch', [@_client])
  id = get_swytch_id
  return model.get_by_id(id)
end
name=(v) click to toggle source
# File lib/saklient/cloud/resources/router.rb, line 317
def name=(v)
  set_name(v)
end
network_mask_len=(v) click to toggle source
# File lib/saklient/cloud/resources/router.rb, line 398
def network_mask_len=(v)
  set_network_mask_len(v)
end
reload() click to toggle source

最新のリソース情報を再取得します.

@return [Router] this

# File lib/saklient/cloud/resources/router.rb, line 96
def reload
  return _reload
end
remove_ipv6_net(ipv6Net) click to toggle source

このルータ+スイッチでIPv6アドレスを無効にします.

@param [Ipv6Net] ipv6Net @return [Router] this

# File lib/saklient/cloud/resources/router.rb, line 207
def remove_ipv6_net(ipv6Net)
  Saklient::Util::validate_type(ipv6Net, 'Saklient::Cloud::Resources::Ipv6Net')
  @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/ipv6net/' + ipv6Net._id)
  reload
  return self
end
remove_static_route(ipv4Net) click to toggle source

このルータ+スイッチからスタティックルートを削除します.

@param [Ipv4Net] ipv4Net @return [Router] this

# File lib/saklient/cloud/resources/router.rb, line 234
def remove_static_route(ipv4Net)
  Saklient::Util::validate_type(ipv4Net, 'Saklient::Cloud::Resources::Ipv4Net')
  @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/subnet/' + ipv4Net._id)
  reload
  return self
end
save() click to toggle source

このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.

@return [Router] this

# File lib/saklient/cloud/resources/router.rb, line 89
def save
  return _save
end
sleep_while_creating(timeoutSec = 120) click to toggle source

作成中のルータが利用可能になるまで待機します.

@param [Fixnum] timeoutSec @return [bool] 成功時はtrue, タイムアウトやエラーによる失敗時はfalseを返します.

# File lib/saklient/cloud/resources/router.rb, line 165
def sleep_while_creating(timeoutSec = 120)
  Saklient::Util::validate_type(timeoutSec, 'Fixnum')
  step = 3
  isOk = false
  while 0 < timeoutSec do
    begin
      if exists
        reload
        isOk = true
      end
    rescue Saklient::Errors::HttpException
      {}
    end
    timeoutSec -= step
    timeoutSec = 0 if isOk
    sleep(step) if 0 < timeoutSec
  end
  return isOk
end

Protected Instance Methods

_api_path() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 56
def _api_path
  return '/internet'
end
_on_after_api_deserialize(r, root) click to toggle source

@private @param [any] r @param [any] root @return [void]

# File lib/saklient/cloud/resources/router.rb, line 141
def _on_after_api_deserialize(r, root)
  @_activity.set_source_id(_id) if !(r).nil?
end
_root_key() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 62
def _root_key
  return 'Internet'
end
_root_key_m() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 68
def _root_key_m
  return 'Internet'
end
api_deserialize_impl(r) click to toggle source

(This method is generated in Translator_default#buildImpl)

@param [any] r

# File lib/saklient/cloud/resources/router.rb, line 472
def api_deserialize_impl(r)
  @is_new = (r).nil?
  r = {} if @is_new
  @is_incomplete = false
  if Saklient::Util::exists_path(r, 'ID')
    @m_id = (Saklient::Util::get_by_path(r, 'ID')).nil? ? nil : Saklient::Util::get_by_path(r, 'ID').to_s
  else
    @m_id = nil
    @is_incomplete = true
  end
  @n_id = false
  if Saklient::Util::exists_path(r, 'Name')
    @m_name = (Saklient::Util::get_by_path(r, 'Name')).nil? ? nil : Saklient::Util::get_by_path(r, 'Name').to_s
  else
    @m_name = nil
    @is_incomplete = true
  end
  @n_name = false
  if Saklient::Util::exists_path(r, 'Description')
    @m_description = (Saklient::Util::get_by_path(r, 'Description')).nil? ? nil : Saklient::Util::get_by_path(r, 'Description').to_s
  else
    @m_description = nil
    @is_incomplete = true
  end
  @n_description = false
  if Saklient::Util::exists_path(r, 'NetworkMaskLen')
    @m_network_mask_len = (Saklient::Util::get_by_path(r, 'NetworkMaskLen')).nil? ? nil : (Saklient::Util::get_by_path(r, 'NetworkMaskLen').to_s).to_s().to_i(10)
  else
    @m_network_mask_len = nil
    @is_incomplete = true
  end
  @n_network_mask_len = false
  if Saklient::Util::exists_path(r, 'BandWidthMbps')
    @m_band_width_mbps = (Saklient::Util::get_by_path(r, 'BandWidthMbps')).nil? ? nil : (Saklient::Util::get_by_path(r, 'BandWidthMbps').to_s).to_s().to_i(10)
  else
    @m_band_width_mbps = nil
    @is_incomplete = true
  end
  @n_band_width_mbps = false
  if Saklient::Util::exists_path(r, 'Switch.ID')
    @m_swytch_id = (Saklient::Util::get_by_path(r, 'Switch.ID')).nil? ? nil : Saklient::Util::get_by_path(r, 'Switch.ID').to_s
  else
    @m_swytch_id = nil
    @is_incomplete = true
  end
  @n_swytch_id = false
end
api_serialize_impl(withClean = false) click to toggle source

@private @param [bool] withClean @return [any]

# File lib/saklient/cloud/resources/router.rb, line 523
def api_serialize_impl(withClean = false)
  Saklient::Util::validate_type(withClean, 'bool')
  missing = []
  ret = {}
  Saklient::Util::set_by_path(ret, 'ID', @m_id) if withClean || @n_id
  if withClean || @n_name
    Saklient::Util::set_by_path(ret, 'Name', @m_name)
  else
    missing << 'name' if @is_new
  end
  Saklient::Util::set_by_path(ret, 'Description', @m_description) if withClean || @n_description
  if withClean || @n_network_mask_len
    Saklient::Util::set_by_path(ret, 'NetworkMaskLen', @m_network_mask_len)
  else
    missing << 'network_mask_len' if @is_new
  end
  if withClean || @n_band_width_mbps
    Saklient::Util::set_by_path(ret, 'BandWidthMbps', @m_band_width_mbps)
  else
    missing << 'band_width_mbps' if @is_new
  end
  Saklient::Util::set_by_path(ret, 'Switch.ID', @m_swytch_id) if withClean || @n_swytch_id
  raise Saklient::Errors::SaklientException.new('required_field', 'Required fields must be set before the Router creation: ' + missing.join(', ')) if missing.length > 0
  return ret
end
get_band_width_mbps() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Fixnum]

# File lib/saklient/cloud/resources/router.rb, line 411
def get_band_width_mbps
  return @m_band_width_mbps
end
get_description() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 330
def get_description
  return @m_description
end
get_id() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 266
def get_id
  return @m_id
end
get_name() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 290
def get_name
  return @m_name
end
get_network_mask_len() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Fixnum]

# File lib/saklient/cloud/resources/router.rb, line 370
def get_network_mask_len
  return @m_network_mask_len
end
get_swytch_id() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/router.rb, line 452
def get_swytch_id
  return @m_swytch_id
end
set_band_width_mbps(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [Fixnum] v @return [Fixnum]

# File lib/saklient/cloud/resources/router.rb, line 420
def set_band_width_mbps(v)
  Saklient::Util::validate_type(v, 'Fixnum')
  raise Saklient::Errors::SaklientException.new('immutable_field', 'Immutable fields cannot be modified after the resource creation: ' + 'Saklient::Cloud::Resources::Router#band_width_mbps') if !@is_new
  @m_band_width_mbps = v
  @n_band_width_mbps = true
  return @m_band_width_mbps
end
set_description(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [String] v @return [String]

# File lib/saklient/cloud/resources/router.rb, line 339
def set_description(v)
  Saklient::Util::validate_type(v, 'String')
  @m_description = v
  @n_description = true
  return @m_description
end
set_name(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [String] v @return [String]

# File lib/saklient/cloud/resources/router.rb, line 299
def set_name(v)
  Saklient::Util::validate_type(v, 'String')
  @m_name = v
  @n_name = true
  return @m_name
end
set_network_mask_len(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [Fixnum] v @return [Fixnum]

# File lib/saklient/cloud/resources/router.rb, line 379
def set_network_mask_len(v)
  Saklient::Util::validate_type(v, 'Fixnum')
  raise Saklient::Errors::SaklientException.new('immutable_field', 'Immutable fields cannot be modified after the resource creation: ' + 'Saklient::Cloud::Resources::Router#network_mask_len') if !@is_new
  @m_network_mask_len = v
  @n_network_mask_len = true
  return @m_network_mask_len
end