class Saklient::Cloud::Resources::Archive

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

Attributes

_ftp_info[RW]

@private @return [FtpInfo]

_source[RW]

@private @return [Resource]

availability[R]

有効状態 {Saklient::Cloud::Enums::EAvailability}

@return [String]

description[RW]

説明

@return [String]

display_order[RW]

表示順序

@return [Fixnum]

ftp_info[R]

FTP情報

@return [FtpInfo]

icon[RW]

アイコン

@return [Icon]

id[R]

ID

@return [String]

is_available[R]

ディスクが利用可能なときtrueを返します.

@return [bool]

m_availability[RW]

有効状態 {Saklient::Cloud::Enums::EAvailability}

@return [String]

m_description[RW]

説明

@return [String]

m_display_order[RW]

表示順序

@return [Fixnum]

m_icon[RW]

アイコン

@return [Icon]

m_id[RW]

ID

@return [String]

m_name[RW]

名前

@return [String]

m_plan[RW]

プラン

@return [DiskPlan]

m_scope[RW]

スコープ {Saklient::Cloud::Enums::EScope}

@return [String]

m_service_class[RW]

サービスクラス

@return [String]

m_size_mib[RW]

サイズ

@return [Fixnum]

m_tags[RW]

タグ文字列の配列

@return [Array<String>]

n_availability[RW]

@return [bool]

n_description[RW]

@return [bool]

n_display_order[RW]

@return [bool]

n_icon[RW]

@return [bool]

n_id[RW]

@return [bool]

n_name[RW]

@return [bool]

n_plan[RW]

@return [bool]

n_scope[RW]

@return [bool]

n_service_class[RW]

@return [bool]

n_size_mib[RW]

@return [bool]

n_tags[RW]

@return [bool]

name[RW]

名前

@return [String]

plan[R]

プラン

@return [DiskPlan]

scope[R]

スコープ {Saklient::Cloud::Enums::EScope}

@return [String]

service_class[R]

サービスクラス

@return [String]

size_gib[RW]

サイズ

@return [Fixnum]

size_mib[RW]

サイズ

@return [Fixnum]

source[RW]

アーカイブのコピー元

@return [Resource]

tags[RW]

タグ文字列の配列

@return [Array<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/archive.rb, line 129
def initialize(client, obj, wrapped = false)
  super(client)
  Saklient::Util::validate_type(client, 'Saklient::Cloud::Client')
  Saklient::Util::validate_type(wrapped, 'bool')
  api_deserialize(obj, wrapped)
end

Public Instance Methods

_class_name() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 101
def _class_name
  return 'Archive'
end
_id() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 107
def _id
  return get_id
end
close_ftp() click to toggle source

FTPSを終了し, アーカイブを利用可能な状態にします.

@return [Archive] this

# File lib/saklient/cloud/resources/archive.rb, line 322
def close_ftp
  path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/ftp'
  @_client.request('DELETE', path)
  @_ftp_info = nil
  return self
end
description=(v) click to toggle source
# File lib/saklient/cloud/resources/archive.rb, line 475
def description=(v)
  set_description(v)
end
display_order=(v) click to toggle source
# File lib/saklient/cloud/resources/archive.rb, line 596
def display_order=(v)
  set_display_order(v)
end
get_ftp_info() click to toggle source

@private @return [FtpInfo]

# File lib/saklient/cloud/resources/archive.rb, line 234
def get_ftp_info
  return @_ftp_info
end
get_source() click to toggle source

@private @return [Resource]

# File lib/saklient/cloud/resources/archive.rb, line 198
def get_source
  return @_source
end
icon=(v) click to toggle source
# File lib/saklient/cloud/resources/archive.rb, line 556
def icon=(v)
  set_icon(v)
end
name=(v) click to toggle source
# File lib/saklient/cloud/resources/archive.rb, line 435
def name=(v)
  set_name(v)
end
open_ftp(reset = false) click to toggle source

FTPSを開始し, イメージファイルをアップロード・ダウンロードできる状態にします.

アカウント情報は, ftpInfo プロパティから取得することができます.

@param [bool] reset 既にFTPSが開始されているとき, trueを指定してこのメソッドを呼ぶことでパスワードを再設定します. @return [Archive] this

# File lib/saklient/cloud/resources/archive.rb, line 309
def open_ftp(reset = false)
  Saklient::Util::validate_type(reset, 'bool')
  path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/ftp'
  q = {}
  Saklient::Util::set_by_path(q, 'ChangePassword', reset)
  result = @_client.request('PUT', path, q)
  _on_after_api_deserialize(nil, result)
  return self
end
reload() click to toggle source

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

@return [Archive] this

# File lib/saklient/cloud/resources/archive.rb, line 121
def reload
  return _reload
end
save() click to toggle source

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

@return [Archive] this

# File lib/saklient/cloud/resources/archive.rb, line 114
def save
  return _save
end
set_source(source) click to toggle source

@private @param [Resource] source @return [Resource]

# File lib/saklient/cloud/resources/archive.rb, line 205
def set_source(source)
  Saklient::Util::validate_type(source, 'Saklient::Cloud::Resources::Resource')
  @_source = source
  return source
end
size_gib=(v) click to toggle source
# File lib/saklient/cloud/resources/archive.rb, line 184
def size_gib=(v)
  set_size_gib(v)
end
size_mib=(v) click to toggle source
# File lib/saklient/cloud/resources/archive.rb, line 637
def size_mib=(v)
  set_size_mib(v)
end
sleep_while_copying(timeoutSec = 3600) click to toggle source

コピー中のアーカイブが利用可能になるまで待機します.

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

# File lib/saklient/cloud/resources/archive.rb, line 333
def sleep_while_copying(timeoutSec = 3600)
  Saklient::Util::validate_type(timeoutSec, 'Fixnum')
  step = 3
  while 0 < timeoutSec do
    begin
      reload
    rescue Saklient::Errors::HttpException
      {}
    end
    a = get_availability
    return true if a == Saklient::Cloud::Enums::EAvailability::available
    timeoutSec = 0 if a != Saklient::Cloud::Enums::EAvailability::migrating
    timeoutSec -= step
    sleep(step) if 0 < timeoutSec
  end
  return false
end
source=(v) click to toggle source
# File lib/saklient/cloud/resources/archive.rb, line 220
def source=(v)
  set_source(v)
end
tags=(v) click to toggle source
# File lib/saklient/cloud/resources/archive.rb, line 516
def tags=(v)
  set_tags(v)
end

Protected Instance Methods

_api_path() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 81
def _api_path
  return '/archive'
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/archive.rb, line 253
def _on_after_api_deserialize(r, root)
  if !(root).nil?
    if !root.nil? && root.key?(:FTPServer)
      ftp = root[:FTPServer]
      @_ftp_info = Saklient::Cloud::Resources::FtpInfo.new(ftp) if !(ftp).nil?
    end
  end
  if !(r).nil?
    if !r.nil? && r.key?(:SourceArchive)
      s = r[:SourceArchive]
      if !(s).nil?
        id = s[:ID]
        @_source = Saklient::Cloud::Resources::Archive.new(@_client, s) if !(id).nil?
      end
    end
    if !r.nil? && r.key?(:SourceDisk)
      s = r[:SourceDisk]
      if !(s).nil?
        id = s[:ID]
        @_source = Saklient::Cloud::Resources::Resource::create_with('Disk', @_client, s) if !(id).nil?
      end
    end
  end
end
_on_after_api_serialize(r, withClean) click to toggle source

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

# File lib/saklient/cloud/resources/archive.rb, line 282
def _on_after_api_serialize(r, withClean)
  Saklient::Util::validate_type(withClean, 'bool')
  return nil if (r).nil?
  if !(@_source).nil?
    if @_source._class_name == 'Archive'
      s = withClean ? @_source.api_serialize(true) : { ID: @_source._id }
      r[:SourceArchive] = s
    else
      if @_source._class_name == 'Disk'
        s = withClean ? @_source.api_serialize(true) : { ID: @_source._id }
        r[:SourceDisk] = s
      else
        @_source = nil
        Saklient::Util::validate_type(@_source, 'Disk or Archive', true)
      end
    end
  end
end
_root_key() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 87
def _root_key
  return 'Archive'
end
_root_key_m() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 93
def _root_key_m
  return 'Archives'
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/archive.rb, line 718
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, 'Scope')
    @m_scope = (Saklient::Util::get_by_path(r, 'Scope')).nil? ? nil : Saklient::Util::get_by_path(r, 'Scope').to_s
  else
    @m_scope = nil
    @is_incomplete = true
  end
  @n_scope = 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, 'Tags')
    if (Saklient::Util::get_by_path(r, 'Tags')).nil?
      @m_tags = []
    else
      @m_tags = []
      for t in Saklient::Util::get_by_path(r, 'Tags')
        v1 = nil
        v1 = (t).nil? ? nil : t.to_s
        @m_tags << v1
      end
    end
  else
    @m_tags = nil
    @is_incomplete = true
  end
  @n_tags = false
  if Saklient::Util::exists_path(r, 'Icon')
    @m_icon = (Saklient::Util::get_by_path(r, 'Icon')).nil? ? nil : Saklient::Cloud::Resources::Icon.new(@_client, Saklient::Util::get_by_path(r, 'Icon'))
  else
    @m_icon = nil
    @is_incomplete = true
  end
  @n_icon = false
  if Saklient::Util::exists_path(r, 'DisplayOrder')
    @m_display_order = (Saklient::Util::get_by_path(r, 'DisplayOrder')).nil? ? nil : (Saklient::Util::get_by_path(r, 'DisplayOrder').to_s).to_s().to_i(10)
  else
    @m_display_order = nil
    @is_incomplete = true
  end
  @n_display_order = false
  if Saklient::Util::exists_path(r, 'SizeMB')
    @m_size_mib = (Saklient::Util::get_by_path(r, 'SizeMB')).nil? ? nil : (Saklient::Util::get_by_path(r, 'SizeMB').to_s).to_s().to_i(10)
  else
    @m_size_mib = nil
    @is_incomplete = true
  end
  @n_size_mib = false
  if Saklient::Util::exists_path(r, 'ServiceClass')
    @m_service_class = (Saklient::Util::get_by_path(r, 'ServiceClass')).nil? ? nil : Saklient::Util::get_by_path(r, 'ServiceClass').to_s
  else
    @m_service_class = nil
    @is_incomplete = true
  end
  @n_service_class = false
  if Saklient::Util::exists_path(r, 'Plan')
    @m_plan = (Saklient::Util::get_by_path(r, 'Plan')).nil? ? nil : Saklient::Cloud::Resources::DiskPlan.new(@_client, Saklient::Util::get_by_path(r, 'Plan'))
  else
    @m_plan = nil
    @is_incomplete = true
  end
  @n_plan = false
  if Saklient::Util::exists_path(r, 'Availability')
    @m_availability = (Saklient::Util::get_by_path(r, 'Availability')).nil? ? nil : Saklient::Util::get_by_path(r, 'Availability').to_s
  else
    @m_availability = nil
    @is_incomplete = true
  end
  @n_availability = false
end
api_serialize_impl(withClean = false) click to toggle source

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

# File lib/saklient/cloud/resources/archive.rb, line 813
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
  Saklient::Util::set_by_path(ret, 'Scope', @m_scope) if withClean || @n_scope
  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_tags
    Saklient::Util::set_by_path(ret, 'Tags', [])
    for r1 in @m_tags
      v = nil
      v = r1
      ret[:Tags] << v
    end
  end
  Saklient::Util::set_by_path(ret, 'Icon', withClean ? ((@m_icon).nil? ? nil : @m_icon.api_serialize(withClean)) : ((@m_icon).nil? ? { ID: '0' } : @m_icon.api_serialize_id)) if withClean || @n_icon
  Saklient::Util::set_by_path(ret, 'DisplayOrder', @m_display_order) if withClean || @n_display_order
  Saklient::Util::set_by_path(ret, 'SizeMB', @m_size_mib) if withClean || @n_size_mib
  Saklient::Util::set_by_path(ret, 'ServiceClass', @m_service_class) if withClean || @n_service_class
  Saklient::Util::set_by_path(ret, 'Plan', withClean ? ((@m_plan).nil? ? nil : @m_plan.api_serialize(withClean)) : ((@m_plan).nil? ? { ID: '0' } : @m_plan.api_serialize_id)) if withClean || @n_plan
  Saklient::Util::set_by_path(ret, 'Availability', @m_availability) if withClean || @n_availability
  raise Saklient::Errors::SaklientException.new('required_field', 'Required fields must be set before the Archive creation: ' + missing.join(', ')) if missing.length > 0
  return ret
end
get_availability() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 698
def get_availability
  return @m_availability
end
get_description() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 448
def get_description
  return @m_description
end
get_display_order() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Fixnum]

# File lib/saklient/cloud/resources/archive.rb, line 569
def get_display_order
  return @m_display_order
end
get_icon() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Icon]

# File lib/saklient/cloud/resources/archive.rb, line 529
def get_icon
  return @m_icon
end
get_id() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 360
def get_id
  return @m_id
end
get_is_available() click to toggle source

@private @return [bool]

# File lib/saklient/cloud/resources/archive.rb, line 140
def get_is_available
  return get_availability == Saklient::Cloud::Enums::EAvailability::available
end
get_name() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 408
def get_name
  return @m_name
end
get_plan() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [DiskPlan]

# File lib/saklient/cloud/resources/archive.rb, line 674
def get_plan
  return @m_plan
end
get_scope() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 384
def get_scope
  return @m_scope
end
get_service_class() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/archive.rb, line 650
def get_service_class
  return @m_service_class
end
get_size_gib() click to toggle source

@private @return [Fixnum]

# File lib/saklient/cloud/resources/archive.rb, line 159
def get_size_gib
  sizeMib = get_size_mib
  return (sizeMib).nil? ? nil : sizeMib >> 10
end
get_size_mib() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Fixnum]

# File lib/saklient/cloud/resources/archive.rb, line 609
def get_size_mib
  return @m_size_mib
end
get_tags() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Array<String>]

# File lib/saklient/cloud/resources/archive.rb, line 488
def get_tags
  @n_tags = true
  return @m_tags
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/archive.rb, line 457
def set_description(v)
  Saklient::Util::validate_type(v, 'String')
  @m_description = v
  @n_description = true
  return @m_description
end
set_display_order(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

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

# File lib/saklient/cloud/resources/archive.rb, line 578
def set_display_order(v)
  Saklient::Util::validate_type(v, 'Fixnum')
  @m_display_order = v
  @n_display_order = true
  return @m_display_order
end
set_icon(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [Icon] v @return [Icon]

# File lib/saklient/cloud/resources/archive.rb, line 538
def set_icon(v)
  Saklient::Util::validate_type(v, 'Saklient::Cloud::Resources::Icon')
  @m_icon = v
  @n_icon = true
  return @m_icon
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/archive.rb, line 417
def set_name(v)
  Saklient::Util::validate_type(v, 'String')
  @m_name = v
  @n_name = true
  return @m_name
end
set_size_gib(sizeGib) click to toggle source

@private @param [Fixnum] sizeGib @return [Fixnum]

# File lib/saklient/cloud/resources/archive.rb, line 167
def set_size_gib(sizeGib)
  Saklient::Util::validate_type(sizeGib, 'Fixnum')
  set_size_mib((sizeGib).nil? ? nil : sizeGib * 1024)
  return sizeGib
end
set_size_mib(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

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

# File lib/saklient/cloud/resources/archive.rb, line 618
def set_size_mib(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::Archive#size_mib') if !@is_new
  @m_size_mib = v
  @n_size_mib = true
  return @m_size_mib
end
set_tags(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [Array<String>] v @return [Array<String>]

# File lib/saklient/cloud/resources/archive.rb, line 498
def set_tags(v)
  Saklient::Util::validate_type(v, 'Array')
  @m_tags = v
  @n_tags = true
  return @m_tags
end