saklient 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +43 -0
  6. data/Rakefile +1 -0
  7. data/config.sh.sample +5 -0
  8. data/example.rb +83 -0
  9. data/example.sh +6 -0
  10. data/lib/saklient/cloud/api.rb +382 -0
  11. data/lib/saklient/cloud/client.rb +111 -0
  12. data/lib/saklient/cloud/enums/eappliance_class.rb +39 -0
  13. data/lib/saklient/cloud/enums/eavailability.rb +79 -0
  14. data/lib/saklient/cloud/enums/edisk_connection.rb +39 -0
  15. data/lib/saklient/cloud/enums/escope.rb +39 -0
  16. data/lib/saklient/cloud/enums/escript_class.rb +39 -0
  17. data/lib/saklient/cloud/enums/eserver_instance_status.rb +44 -0
  18. data/lib/saklient/cloud/enums/estorage_class.rb +34 -0
  19. data/lib/saklient/cloud/errors/access_api_key_disabled_exception.rb +23 -0
  20. data/lib/saklient/cloud/errors/access_sakura_exception.rb +23 -0
  21. data/lib/saklient/cloud/errors/access_staff_exception.rb +23 -0
  22. data/lib/saklient/cloud/errors/access_token_exception.rb +23 -0
  23. data/lib/saklient/cloud/errors/access_xhr_or_api_key_exception.rb +23 -0
  24. data/lib/saklient/cloud/errors/account_not_found_exception.rb +23 -0
  25. data/lib/saklient/cloud/errors/account_not_specified_exception.rb +23 -0
  26. data/lib/saklient/cloud/errors/ambiguous_identifier_exception.rb +23 -0
  27. data/lib/saklient/cloud/errors/ambiguous_zone_exception.rb +23 -0
  28. data/lib/saklient/cloud/errors/api_proxy_timeout_exception.rb +23 -0
  29. data/lib/saklient/cloud/errors/api_proxy_timeout_non_get_exception.rb +23 -0
  30. data/lib/saklient/cloud/errors/archive_is_incomplete_exception.rb +23 -0
  31. data/lib/saklient/cloud/errors/boot_failure_by_lock_exception.rb +23 -0
  32. data/lib/saklient/cloud/errors/boot_failure_in_group_exception.rb +23 -0
  33. data/lib/saklient/cloud/errors/busy_exception.rb +23 -0
  34. data/lib/saklient/cloud/errors/cant_resize_smaller_exception.rb +23 -0
  35. data/lib/saklient/cloud/errors/cdrom_device_locked_exception.rb +23 -0
  36. data/lib/saklient/cloud/errors/cdrom_disabled_exception.rb +23 -0
  37. data/lib/saklient/cloud/errors/cdrom_in_use_exception.rb +23 -0
  38. data/lib/saklient/cloud/errors/cdrom_is_incomplete_exception.rb +23 -0
  39. data/lib/saklient/cloud/errors/connect_to_same_switch_exception.rb +23 -0
  40. data/lib/saklient/cloud/errors/contract_creation_exception.rb +23 -0
  41. data/lib/saklient/cloud/errors/copy_to_itself_exception.rb +23 -0
  42. data/lib/saklient/cloud/errors/delete_disk_b4_template_exception.rb +23 -0
  43. data/lib/saklient/cloud/errors/delete_ip_v6_nets_first_exception.rb +23 -0
  44. data/lib/saklient/cloud/errors/delete_res_b4_account_exception.rb +23 -0
  45. data/lib/saklient/cloud/errors/delete_router_b4_switch_exception.rb +23 -0
  46. data/lib/saklient/cloud/errors/delete_static_route_first_exception.rb +23 -0
  47. data/lib/saklient/cloud/errors/disabled_in_sandbox_exception.rb +23 -0
  48. data/lib/saklient/cloud/errors/disconnect_b4_delete_exception.rb +23 -0
  49. data/lib/saklient/cloud/errors/disconnect_b4_update_exception.rb +23 -0
  50. data/lib/saklient/cloud/errors/disk_connection_limit_exception.rb +23 -0
  51. data/lib/saklient/cloud/errors/disk_is_copying_exception.rb +23 -0
  52. data/lib/saklient/cloud/errors/disk_is_not_available_exception.rb +23 -0
  53. data/lib/saklient/cloud/errors/disk_license_mismatch_exception.rb +23 -0
  54. data/lib/saklient/cloud/errors/disk_or_ss_in_migration_exception.rb +23 -0
  55. data/lib/saklient/cloud/errors/disk_stock_run_out_exception.rb +23 -0
  56. data/lib/saklient/cloud/errors/dns_aaaa_record_not_found_exception.rb +23 -0
  57. data/lib/saklient/cloud/errors/dns_arecord_not_found_exception.rb +23 -0
  58. data/lib/saklient/cloud/errors/dns_ptr_update_failure_exception.rb +23 -0
  59. data/lib/saklient/cloud/errors/dont_create_in_sandbox_exception.rb +23 -0
  60. data/lib/saklient/cloud/errors/duplicate_account_code_exception.rb +23 -0
  61. data/lib/saklient/cloud/errors/duplicate_entry_exception.rb +23 -0
  62. data/lib/saklient/cloud/errors/duplicate_user_code_exception.rb +23 -0
  63. data/lib/saklient/cloud/errors/file_not_uploaded_exception.rb +23 -0
  64. data/lib/saklient/cloud/errors/filter_array_comparison_exception.rb +23 -0
  65. data/lib/saklient/cloud/errors/filter_bad_operator_exception.rb +23 -0
  66. data/lib/saklient/cloud/errors/filter_null_comparison_exception.rb +23 -0
  67. data/lib/saklient/cloud/errors/filter_unknown_operator_exception.rb +23 -0
  68. data/lib/saklient/cloud/errors/ftp_cannot_close_exception.rb +23 -0
  69. data/lib/saklient/cloud/errors/ftp_is_already_close_exception.rb +23 -0
  70. data/lib/saklient/cloud/errors/ftp_is_already_open_exception.rb +23 -0
  71. data/lib/saklient/cloud/errors/ftp_must_be_closed_exception.rb +23 -0
  72. data/lib/saklient/cloud/errors/host_operation_failure_exception.rb +23 -0
  73. data/lib/saklient/cloud/errors/illegal_das_usage_exception.rb +23 -0
  74. data/lib/saklient/cloud/errors/in_migration_exception.rb +23 -0
  75. data/lib/saklient/cloud/errors/invalid_format_exception.rb +23 -0
  76. data/lib/saklient/cloud/errors/invalid_param_comb_exception.rb +23 -0
  77. data/lib/saklient/cloud/errors/invalid_range_exception.rb +23 -0
  78. data/lib/saklient/cloud/errors/invalid_uri_argument_exception.rb +23 -0
  79. data/lib/saklient/cloud/errors/ip_v6_net_already_attached_exception.rb +23 -0
  80. data/lib/saklient/cloud/errors/limit_count_in_account_exception.rb +23 -0
  81. data/lib/saklient/cloud/errors/limit_count_in_member_exception.rb +23 -0
  82. data/lib/saklient/cloud/errors/limit_count_in_network_exception.rb +23 -0
  83. data/lib/saklient/cloud/errors/limit_count_in_router_exception.rb +23 -0
  84. data/lib/saklient/cloud/errors/limit_count_in_zone_exception.rb +23 -0
  85. data/lib/saklient/cloud/errors/limit_memory_in_account_exception.rb +23 -0
  86. data/lib/saklient/cloud/errors/limit_size_in_account_exception.rb +23 -0
  87. data/lib/saklient/cloud/errors/missing_iso_image_exception.rb +23 -0
  88. data/lib/saklient/cloud/errors/missing_param_exception.rb +23 -0
  89. data/lib/saklient/cloud/errors/must_be_of_same_zone_exception.rb +23 -0
  90. data/lib/saklient/cloud/errors/no_display_response_exception.rb +23 -0
  91. data/lib/saklient/cloud/errors/not_for_router_exception.rb +23 -0
  92. data/lib/saklient/cloud/errors/not_replicating_exception.rb +23 -0
  93. data/lib/saklient/cloud/errors/not_with_hybridconn_exception.rb +23 -0
  94. data/lib/saklient/cloud/errors/old_storage_plan_exception.rb +23 -0
  95. data/lib/saklient/cloud/errors/operation_failure_exception.rb +23 -0
  96. data/lib/saklient/cloud/errors/operation_timeout_exception.rb +23 -0
  97. data/lib/saklient/cloud/errors/original_hash_mismatch_exception.rb +23 -0
  98. data/lib/saklient/cloud/errors/packet_filter_applying_exception.rb +23 -0
  99. data/lib/saklient/cloud/errors/packet_filter_version_mismatch_exception.rb +23 -0
  100. data/lib/saklient/cloud/errors/param_ip_not_found_exception.rb +23 -0
  101. data/lib/saklient/cloud/errors/param_res_not_found_exception.rb +23 -0
  102. data/lib/saklient/cloud/errors/payment_credit_card_exception.rb +23 -0
  103. data/lib/saklient/cloud/errors/payment_payment_exception.rb +23 -0
  104. data/lib/saklient/cloud/errors/payment_registration_exception.rb +23 -0
  105. data/lib/saklient/cloud/errors/payment_tel_certification_exception.rb +23 -0
  106. data/lib/saklient/cloud/errors/payment_unpayable_exception.rb +23 -0
  107. data/lib/saklient/cloud/errors/penalty_operation_exception.rb +23 -0
  108. data/lib/saklient/cloud/errors/replica_already_exists_exception.rb +23 -0
  109. data/lib/saklient/cloud/errors/replica_not_found_exception.rb +23 -0
  110. data/lib/saklient/cloud/errors/res_already_connected_exception.rb +23 -0
  111. data/lib/saklient/cloud/errors/res_already_disconnected_exception.rb +23 -0
  112. data/lib/saklient/cloud/errors/res_already_exists_exception.rb +23 -0
  113. data/lib/saklient/cloud/errors/res_used_in_zone_exception.rb +23 -0
  114. data/lib/saklient/cloud/errors/resource_path_not_found_exception.rb +23 -0
  115. data/lib/saklient/cloud/errors/run_out_of_ip_address_exception.rb +23 -0
  116. data/lib/saklient/cloud/errors/same_license_required_exception.rb +23 -0
  117. data/lib/saklient/cloud/errors/server_could_not_stop_exception.rb +23 -0
  118. data/lib/saklient/cloud/errors/server_is_cleaning_exception.rb +23 -0
  119. data/lib/saklient/cloud/errors/server_operation_failure_exception.rb +23 -0
  120. data/lib/saklient/cloud/errors/server_power_must_be_down_exception.rb +23 -0
  121. data/lib/saklient/cloud/errors/server_power_must_be_up_exception.rb +23 -0
  122. data/lib/saklient/cloud/errors/service_temporarily_unavailable_exception.rb +23 -0
  123. data/lib/saklient/cloud/errors/size_mismatch_exception.rb +23 -0
  124. data/lib/saklient/cloud/errors/snapshot_in_migration_exception.rb +23 -0
  125. data/lib/saklient/cloud/errors/still_creating_exception.rb +23 -0
  126. data/lib/saklient/cloud/errors/storage_abnormal_exception.rb +23 -0
  127. data/lib/saklient/cloud/errors/storage_operation_failure_exception.rb +23 -0
  128. data/lib/saklient/cloud/errors/switch_hybrid_connected_exception.rb +23 -0
  129. data/lib/saklient/cloud/errors/template_ftp_is_open_exception.rb +23 -0
  130. data/lib/saklient/cloud/errors/template_is_incomplete_exception.rb +23 -0
  131. data/lib/saklient/cloud/errors/too_many_request_exception.rb +23 -0
  132. data/lib/saklient/cloud/errors/unknown_exception.rb +23 -0
  133. data/lib/saklient/cloud/errors/unknown_os_type_exception.rb +23 -0
  134. data/lib/saklient/cloud/errors/unsupported_res_class_exception.rb +23 -0
  135. data/lib/saklient/cloud/errors/user_not_specified_exception.rb +23 -0
  136. data/lib/saklient/cloud/errors/vnc_proxy_request_failure_exception.rb +23 -0
  137. data/lib/saklient/cloud/models/model.rb +348 -0
  138. data/lib/saklient/cloud/models/model_appliance.rb +161 -0
  139. data/lib/saklient/cloud/models/model_archive.rb +207 -0
  140. data/lib/saklient/cloud/models/model_disk.rb +200 -0
  141. data/lib/saklient/cloud/models/model_disk_plan.rb +156 -0
  142. data/lib/saklient/cloud/models/model_icon.rb +178 -0
  143. data/lib/saklient/cloud/models/model_iface.rb +115 -0
  144. data/lib/saklient/cloud/models/model_ipv6_net.rb +106 -0
  145. data/lib/saklient/cloud/models/model_iso_image.rb +207 -0
  146. data/lib/saklient/cloud/models/model_router.rb +148 -0
  147. data/lib/saklient/cloud/models/model_router_plan.rb +106 -0
  148. data/lib/saklient/cloud/models/model_script.rb +178 -0
  149. data/lib/saklient/cloud/models/model_server.rb +237 -0
  150. data/lib/saklient/cloud/models/model_server_plan.rb +119 -0
  151. data/lib/saklient/cloud/models/model_swytch.rb +138 -0
  152. data/lib/saklient/cloud/models/query_params.rb +44 -0
  153. data/lib/saklient/cloud/product.rb +95 -0
  154. data/lib/saklient/cloud/resources/appliance.rb +551 -0
  155. data/lib/saklient/cloud/resources/archive.rb +861 -0
  156. data/lib/saklient/cloud/resources/disk.rb +802 -0
  157. data/lib/saklient/cloud/resources/disk_config.rb +353 -0
  158. data/lib/saklient/cloud/resources/disk_plan.rb +194 -0
  159. data/lib/saklient/cloud/resources/ftp_info.rb +93 -0
  160. data/lib/saklient/cloud/resources/icon.rb +268 -0
  161. data/lib/saklient/cloud/resources/iface.rb +329 -0
  162. data/lib/saklient/cloud/resources/ipv4_net.rb +275 -0
  163. data/lib/saklient/cloud/resources/ipv6_net.rb +238 -0
  164. data/lib/saklient/cloud/resources/iso_image.rb +666 -0
  165. data/lib/saklient/cloud/resources/resource.rb +287 -0
  166. data/lib/saklient/cloud/resources/router.rb +508 -0
  167. data/lib/saklient/cloud/resources/router_plan.rb +230 -0
  168. data/lib/saklient/cloud/resources/script.rb +554 -0
  169. data/lib/saklient/cloud/resources/server.rb +730 -0
  170. data/lib/saklient/cloud/resources/server_instance.rb +217 -0
  171. data/lib/saklient/cloud/resources/server_plan.rb +285 -0
  172. data/lib/saklient/cloud/resources/swytch.rb +521 -0
  173. data/lib/saklient/errors/exception_factory.rb +532 -0
  174. data/lib/saklient/errors/http_bad_gateway_exception.rb +21 -0
  175. data/lib/saklient/errors/http_bad_request_exception.rb +21 -0
  176. data/lib/saklient/errors/http_conflict_exception.rb +21 -0
  177. data/lib/saklient/errors/http_exception.rb +27 -0
  178. data/lib/saklient/errors/http_expectation_failed_exception.rb +21 -0
  179. data/lib/saklient/errors/http_failed_dependency_exception.rb +21 -0
  180. data/lib/saklient/errors/http_forbidden_exception.rb +21 -0
  181. data/lib/saklient/errors/http_gateway_timeout_exception.rb +21 -0
  182. data/lib/saklient/errors/http_gone_exception.rb +21 -0
  183. data/lib/saklient/errors/http_http_version_not_supported_exception.rb +21 -0
  184. data/lib/saklient/errors/http_insufficient_storage_exception.rb +21 -0
  185. data/lib/saklient/errors/http_internal_server_error_exception.rb +21 -0
  186. data/lib/saklient/errors/http_length_required_exception.rb +21 -0
  187. data/lib/saklient/errors/http_locked_exception.rb +21 -0
  188. data/lib/saklient/errors/http_method_not_allowed_exception.rb +21 -0
  189. data/lib/saklient/errors/http_not_acceptable_exception.rb +21 -0
  190. data/lib/saklient/errors/http_not_extended_exception.rb +21 -0
  191. data/lib/saklient/errors/http_not_found_exception.rb +21 -0
  192. data/lib/saklient/errors/http_not_implemented_exception.rb +21 -0
  193. data/lib/saklient/errors/http_payment_required_exception.rb +21 -0
  194. data/lib/saklient/errors/http_precondition_failed_exception.rb +21 -0
  195. data/lib/saklient/errors/http_proxy_authentication_required_exception.rb +21 -0
  196. data/lib/saklient/errors/http_request_entity_too_large_exception.rb +21 -0
  197. data/lib/saklient/errors/http_request_timeout_exception.rb +21 -0
  198. data/lib/saklient/errors/http_request_uri_too_long_exception.rb +21 -0
  199. data/lib/saklient/errors/http_requested_range_not_satisfiable_exception.rb +21 -0
  200. data/lib/saklient/errors/http_service_unavailable_exception.rb +21 -0
  201. data/lib/saklient/errors/http_unauthorized_exception.rb +21 -0
  202. data/lib/saklient/errors/http_unprocessable_entity_exception.rb +21 -0
  203. data/lib/saklient/errors/http_unsupported_media_type_exception.rb +21 -0
  204. data/lib/saklient/errors/http_upgrade_required_exception.rb +21 -0
  205. data/lib/saklient/errors/http_variant_also_negotiates_exception.rb +21 -0
  206. data/lib/saklient/errors/saklient_exception.rb +22 -0
  207. data/lib/saklient/util.rb +121 -0
  208. data/lib/saklient/version.rb +5 -0
  209. data/saklient.gemspec +24 -0
  210. data/spec/archive_spec.rb +141 -0
  211. data/spec/enum_spec.rb +24 -0
  212. data/spec/exception_spec.rb +25 -0
  213. data/spec/iso_image_spec.rb +172 -0
  214. data/spec/router_spec.rb +124 -0
  215. data/spec/server_spec.rb +261 -0
  216. data/spec/util_spec.rb +72 -0
  217. data/test-sshkey.txt +27 -0
  218. metadata +281 -0
@@ -0,0 +1,44 @@
1
+ # -*- encoding: UTF-8 -*-
2
+
3
+
4
+ module Saklient
5
+ module Cloud
6
+ module Models
7
+
8
+ # @private
9
+ class QueryParams
10
+
11
+ # @return [Fixnum]
12
+ attr_accessor :begin
13
+
14
+ # @return [Fixnum]
15
+ attr_accessor :count
16
+
17
+ # @return [any]
18
+ attr_accessor :filter
19
+
20
+ # @return [Array<String>]
21
+ attr_accessor :sort
22
+
23
+ def initialize
24
+ @begin = 0
25
+ @count = 0
26
+ @filter = {}
27
+ @sort = []
28
+ end
29
+
30
+ # @return [any]
31
+ def build
32
+ return {
33
+ From: @begin,
34
+ Count: @count,
35
+ Filter: @filter,
36
+ Sort: @sort
37
+ }
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,95 @@
1
+ # -*- encoding: UTF-8 -*-
2
+
3
+ require_relative 'models/model_server_plan'
4
+ require_relative 'models/model_disk_plan'
5
+ require_relative 'models/model_router_plan'
6
+ require_relative 'client'
7
+
8
+ module Saklient
9
+ module Cloud
10
+
11
+ # 商品情報にアクセスするためのモデルを集めたクラス.
12
+ class Product
13
+
14
+ protected
15
+
16
+ # @private
17
+ # @return [Saklient::Cloud::Models::Model_ServerPlan]
18
+ attr_accessor :_server
19
+
20
+ # @private
21
+ # @return [Saklient::Cloud::Models::Model_ServerPlan]
22
+ def get_server
23
+ return @_server
24
+ end
25
+
26
+ public
27
+
28
+ # サーバプラン情報.
29
+ #
30
+ # @return [Saklient::Cloud::Models::Model_ServerPlan]
31
+ attr_reader :server
32
+
33
+ def server
34
+ get_server
35
+ end
36
+
37
+ protected
38
+
39
+ # @private
40
+ # @return [Saklient::Cloud::Models::Model_DiskPlan]
41
+ attr_accessor :_disk
42
+
43
+ # @private
44
+ # @return [Saklient::Cloud::Models::Model_DiskPlan]
45
+ def get_disk
46
+ return @_disk
47
+ end
48
+
49
+ public
50
+
51
+ # ディスクプラン情報.
52
+ #
53
+ # @return [Saklient::Cloud::Models::Model_DiskPlan]
54
+ attr_reader :disk
55
+
56
+ def disk
57
+ get_disk
58
+ end
59
+
60
+ protected
61
+
62
+ # @private
63
+ # @return [Saklient::Cloud::Models::Model_RouterPlan]
64
+ attr_accessor :_router
65
+
66
+ # @private
67
+ # @return [Saklient::Cloud::Models::Model_RouterPlan]
68
+ def get_router
69
+ return @_router
70
+ end
71
+
72
+ public
73
+
74
+ # ルータ帯域プラン情報.
75
+ #
76
+ # @return [Saklient::Cloud::Models::Model_RouterPlan]
77
+ attr_reader :router
78
+
79
+ def router
80
+ get_router
81
+ end
82
+
83
+ # @private
84
+ # @param [Client] client
85
+ def initialize(client)
86
+ Saklient::Util::validate_type(client, 'Saklient::Cloud::Client')
87
+ @_server = Saklient::Cloud::Models::Model_ServerPlan.new(client)
88
+ @_disk = Saklient::Cloud::Models::Model_DiskPlan.new(client)
89
+ @_router = Saklient::Cloud::Models::Model_RouterPlan.new(client)
90
+ end
91
+
92
+ end
93
+
94
+ end
95
+ end
@@ -0,0 +1,551 @@
1
+ # -*- encoding: UTF-8 -*-
2
+
3
+ require_relative '../../errors/saklient_exception'
4
+ require_relative '../client'
5
+ require_relative 'resource'
6
+ require_relative 'icon'
7
+ require_relative 'iface'
8
+ require_relative '../enums/eappliance_class'
9
+
10
+ module Saklient
11
+ module Cloud
12
+ module Resources
13
+
14
+ # アプライアンスの実体1つに対応し, 属性の取得や操作を行うためのクラス.
15
+ class Appliance < Saklient::Cloud::Resources::Resource
16
+
17
+ protected
18
+
19
+ # ID
20
+ #
21
+ # @return [String]
22
+ attr_accessor :m_id
23
+
24
+ # クラス {Saklient::Cloud::Enums::EApplianceClass}
25
+ #
26
+ # @return [String]
27
+ attr_accessor :m_clazz
28
+
29
+ # 名前
30
+ #
31
+ # @return [String]
32
+ attr_accessor :m_name
33
+
34
+ # 説明
35
+ #
36
+ # @return [String]
37
+ attr_accessor :m_description
38
+
39
+ # タグ
40
+ #
41
+ # @return [Array<String>]
42
+ attr_accessor :m_tags
43
+
44
+ # アイコン
45
+ #
46
+ # @return [Icon]
47
+ attr_accessor :m_icon
48
+
49
+ # プラン
50
+ #
51
+ # @return [Array<Iface>]
52
+ attr_accessor :m_ifaces
53
+
54
+ # サービスクラス
55
+ #
56
+ # @return [String]
57
+ attr_accessor :m_service_class
58
+
59
+ # @private
60
+ # @return [String]
61
+ def _api_path
62
+ return '/appliance'
63
+ end
64
+
65
+ # @private
66
+ # @return [String]
67
+ def _root_key
68
+ return 'Appliance'
69
+ end
70
+
71
+ # @private
72
+ # @return [String]
73
+ def _root_key_m
74
+ return 'Appliances'
75
+ end
76
+
77
+ public
78
+
79
+ # @private
80
+ # @return [String]
81
+ def _class_name
82
+ return 'Appliance'
83
+ end
84
+
85
+ # @private
86
+ # @return [String]
87
+ def _id
88
+ return get_id
89
+ end
90
+
91
+ # このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
92
+ #
93
+ # @return [Appliance] this
94
+ def save
95
+ return _save
96
+ end
97
+
98
+ # 最新のリソース情報を再取得します.
99
+ #
100
+ # @return [Appliance] this
101
+ def reload
102
+ return _reload
103
+ end
104
+
105
+ # @private
106
+ # @param [Saklient::Cloud::Client] client
107
+ # @param [any] obj
108
+ # @param [bool] wrapped
109
+ def initialize(client, obj, wrapped = false)
110
+ super(client)
111
+ Saklient::Util::validate_type(client, 'Saklient::Cloud::Client')
112
+ Saklient::Util::validate_type(wrapped, 'bool')
113
+ api_deserialize(obj, wrapped)
114
+ end
115
+
116
+ # アプライアンスを起動します.
117
+ #
118
+ # @return [Appliance] this
119
+ def boot
120
+ @_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power')
121
+ return self
122
+ end
123
+
124
+ # アプライアンスをシャットダウンします.
125
+ #
126
+ # @return [Appliance] this
127
+ def shutdown
128
+ @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power')
129
+ return self
130
+ end
131
+
132
+ # アプライアンスを強制停止します.
133
+ #
134
+ # @return [Appliance] this
135
+ def stop
136
+ @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power', { Force: true })
137
+ return self
138
+ end
139
+
140
+ # アプライアンスを強制再起動します.
141
+ #
142
+ # @return [Appliance] this
143
+ def reboot
144
+ @_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/reset')
145
+ return self
146
+ end
147
+
148
+ protected
149
+
150
+ # @return [bool]
151
+ attr_accessor :n_id
152
+
153
+ # (This method is generated in Translator_default#buildImpl)
154
+ #
155
+ # @private
156
+ # @return [String]
157
+ def get_id
158
+ return @m_id
159
+ end
160
+
161
+ public
162
+
163
+ # ID
164
+ #
165
+ # @return [String]
166
+ attr_reader :id
167
+
168
+ def id
169
+ get_id
170
+ end
171
+
172
+ protected
173
+
174
+ # @return [bool]
175
+ attr_accessor :n_clazz
176
+
177
+ # (This method is generated in Translator_default#buildImpl)
178
+ #
179
+ # @private
180
+ # @return [String]
181
+ def get_clazz
182
+ return @m_clazz
183
+ end
184
+
185
+ # (This method is generated in Translator_default#buildImpl)
186
+ #
187
+ # @private
188
+ # @param [String] v
189
+ # @return [String]
190
+ def set_clazz(v)
191
+ Saklient::Util::validate_type(v, 'String')
192
+ raise Saklient::Errors::SaklientException.new('immutable_field', 'Immutable fields cannot be modified after the resource creation: ' + 'Saklient::Cloud::Resources::Appliance#clazz') if !@is_new
193
+ @m_clazz = v
194
+ @n_clazz = true
195
+ return @m_clazz
196
+ end
197
+
198
+ public
199
+
200
+ # クラス {Saklient::Cloud::Enums::EApplianceClass}
201
+ #
202
+ # @return [String]
203
+ attr_accessor :clazz
204
+
205
+ def clazz
206
+ get_clazz
207
+ end
208
+
209
+ def clazz=(v)
210
+ set_clazz(v)
211
+ end
212
+
213
+ protected
214
+
215
+ # @return [bool]
216
+ attr_accessor :n_name
217
+
218
+ # (This method is generated in Translator_default#buildImpl)
219
+ #
220
+ # @private
221
+ # @return [String]
222
+ def get_name
223
+ return @m_name
224
+ end
225
+
226
+ # (This method is generated in Translator_default#buildImpl)
227
+ #
228
+ # @private
229
+ # @param [String] v
230
+ # @return [String]
231
+ def set_name(v)
232
+ Saklient::Util::validate_type(v, 'String')
233
+ @m_name = v
234
+ @n_name = true
235
+ return @m_name
236
+ end
237
+
238
+ public
239
+
240
+ # 名前
241
+ #
242
+ # @return [String]
243
+ attr_accessor :name
244
+
245
+ def name
246
+ get_name
247
+ end
248
+
249
+ def name=(v)
250
+ set_name(v)
251
+ end
252
+
253
+ protected
254
+
255
+ # @return [bool]
256
+ attr_accessor :n_description
257
+
258
+ # (This method is generated in Translator_default#buildImpl)
259
+ #
260
+ # @private
261
+ # @return [String]
262
+ def get_description
263
+ return @m_description
264
+ end
265
+
266
+ # (This method is generated in Translator_default#buildImpl)
267
+ #
268
+ # @private
269
+ # @param [String] v
270
+ # @return [String]
271
+ def set_description(v)
272
+ Saklient::Util::validate_type(v, 'String')
273
+ @m_description = v
274
+ @n_description = true
275
+ return @m_description
276
+ end
277
+
278
+ public
279
+
280
+ # 説明
281
+ #
282
+ # @return [String]
283
+ attr_accessor :description
284
+
285
+ def description
286
+ get_description
287
+ end
288
+
289
+ def description=(v)
290
+ set_description(v)
291
+ end
292
+
293
+ protected
294
+
295
+ # @return [bool]
296
+ attr_accessor :n_tags
297
+
298
+ # (This method is generated in Translator_default#buildImpl)
299
+ #
300
+ # @private
301
+ # @return [Array<String>]
302
+ def get_tags
303
+ return @m_tags
304
+ end
305
+
306
+ # (This method is generated in Translator_default#buildImpl)
307
+ #
308
+ # @private
309
+ # @param [Array<String>] v
310
+ # @return [Array<String>]
311
+ def set_tags(v)
312
+ Saklient::Util::validate_type(v, 'Array')
313
+ @m_tags = v
314
+ @n_tags = true
315
+ return @m_tags
316
+ end
317
+
318
+ public
319
+
320
+ # タグ
321
+ #
322
+ # @return [Array<String>]
323
+ attr_accessor :tags
324
+
325
+ def tags
326
+ get_tags
327
+ end
328
+
329
+ def tags=(v)
330
+ set_tags(v)
331
+ end
332
+
333
+ protected
334
+
335
+ # @return [bool]
336
+ attr_accessor :n_icon
337
+
338
+ # (This method is generated in Translator_default#buildImpl)
339
+ #
340
+ # @private
341
+ # @return [Icon]
342
+ def get_icon
343
+ return @m_icon
344
+ end
345
+
346
+ # (This method is generated in Translator_default#buildImpl)
347
+ #
348
+ # @private
349
+ # @param [Icon] v
350
+ # @return [Icon]
351
+ def set_icon(v)
352
+ Saklient::Util::validate_type(v, 'Saklient::Cloud::Resources::Icon')
353
+ @m_icon = v
354
+ @n_icon = true
355
+ return @m_icon
356
+ end
357
+
358
+ public
359
+
360
+ # アイコン
361
+ #
362
+ # @return [Icon]
363
+ attr_accessor :icon
364
+
365
+ def icon
366
+ get_icon
367
+ end
368
+
369
+ def icon=(v)
370
+ set_icon(v)
371
+ end
372
+
373
+ protected
374
+
375
+ # @return [bool]
376
+ attr_accessor :n_ifaces
377
+
378
+ # (This method is generated in Translator_default#buildImpl)
379
+ #
380
+ # @private
381
+ # @return [Array<Iface>]
382
+ def get_ifaces
383
+ return @m_ifaces
384
+ end
385
+
386
+ public
387
+
388
+ # プラン
389
+ #
390
+ # @return [Array<Iface>]
391
+ attr_reader :ifaces
392
+
393
+ def ifaces
394
+ get_ifaces
395
+ end
396
+
397
+ protected
398
+
399
+ # @return [bool]
400
+ attr_accessor :n_service_class
401
+
402
+ # (This method is generated in Translator_default#buildImpl)
403
+ #
404
+ # @private
405
+ # @return [String]
406
+ def get_service_class
407
+ return @m_service_class
408
+ end
409
+
410
+ public
411
+
412
+ # サービスクラス
413
+ #
414
+ # @return [String]
415
+ attr_reader :service_class
416
+
417
+ def service_class
418
+ get_service_class
419
+ end
420
+
421
+ protected
422
+
423
+ # (This method is generated in Translator_default#buildImpl)
424
+ #
425
+ # @param [any] r
426
+ def api_deserialize_impl(r)
427
+ @is_new = (r).nil?
428
+ r = {} if @is_new
429
+ @is_incomplete = false
430
+ if Saklient::Util::exists_path(r, 'ID')
431
+ @m_id = (Saklient::Util::get_by_path(r, 'ID')).nil? ? nil : Saklient::Util::get_by_path(r, 'ID').to_s
432
+ else
433
+ @m_id = nil
434
+ @is_incomplete = true
435
+ end
436
+ @n_id = false
437
+ if Saklient::Util::exists_path(r, 'Class')
438
+ @m_clazz = (Saklient::Util::get_by_path(r, 'Class')).nil? ? nil : Saklient::Util::get_by_path(r, 'Class').to_s
439
+ else
440
+ @m_clazz = nil
441
+ @is_incomplete = true
442
+ end
443
+ @n_clazz = false
444
+ if Saklient::Util::exists_path(r, 'Name')
445
+ @m_name = (Saklient::Util::get_by_path(r, 'Name')).nil? ? nil : Saklient::Util::get_by_path(r, 'Name').to_s
446
+ else
447
+ @m_name = nil
448
+ @is_incomplete = true
449
+ end
450
+ @n_name = false
451
+ if Saklient::Util::exists_path(r, 'Description')
452
+ @m_description = (Saklient::Util::get_by_path(r, 'Description')).nil? ? nil : Saklient::Util::get_by_path(r, 'Description').to_s
453
+ else
454
+ @m_description = nil
455
+ @is_incomplete = true
456
+ end
457
+ @n_description = false
458
+ if Saklient::Util::exists_path(r, 'Tags')
459
+ if (Saklient::Util::get_by_path(r, 'Tags')).nil?
460
+ @m_tags = []
461
+ else
462
+ @m_tags = []
463
+ for t in Saklient::Util::get_by_path(r, 'Tags')
464
+ v1 = nil
465
+ v1 = (t).nil? ? nil : t.to_s
466
+ @m_tags << v1
467
+ end
468
+ end
469
+ else
470
+ @m_tags = nil
471
+ @is_incomplete = true
472
+ end
473
+ @n_tags = false
474
+ if Saklient::Util::exists_path(r, 'Icon')
475
+ @m_icon = (Saklient::Util::get_by_path(r, 'Icon')).nil? ? nil : Saklient::Cloud::Resources::Icon.new(@_client, Saklient::Util::get_by_path(r, 'Icon'))
476
+ else
477
+ @m_icon = nil
478
+ @is_incomplete = true
479
+ end
480
+ @n_icon = false
481
+ if Saklient::Util::exists_path(r, 'Interfaces')
482
+ if (Saklient::Util::get_by_path(r, 'Interfaces')).nil?
483
+ @m_ifaces = []
484
+ else
485
+ @m_ifaces = []
486
+ for t in Saklient::Util::get_by_path(r, 'Interfaces')
487
+ v2 = nil
488
+ v2 = (t).nil? ? nil : Saklient::Cloud::Resources::Iface.new(@_client, t)
489
+ @m_ifaces << v2
490
+ end
491
+ end
492
+ else
493
+ @m_ifaces = nil
494
+ @is_incomplete = true
495
+ end
496
+ @n_ifaces = false
497
+ if Saklient::Util::exists_path(r, 'ServiceClass')
498
+ @m_service_class = (Saklient::Util::get_by_path(r, 'ServiceClass')).nil? ? nil : Saklient::Util::get_by_path(r, 'ServiceClass').to_s
499
+ else
500
+ @m_service_class = nil
501
+ @is_incomplete = true
502
+ end
503
+ @n_service_class = false
504
+ end
505
+
506
+ # @private
507
+ # @param [bool] withClean
508
+ # @return [any]
509
+ def api_serialize_impl(withClean = false)
510
+ Saklient::Util::validate_type(withClean, 'bool')
511
+ missing = []
512
+ ret = {}
513
+ Saklient::Util::set_by_path(ret, 'ID', @m_id) if withClean || @n_id
514
+ if withClean || @n_clazz
515
+ Saklient::Util::set_by_path(ret, 'Class', @m_clazz)
516
+ else
517
+ missing << 'clazz' if @is_new
518
+ end
519
+ if withClean || @n_name
520
+ Saklient::Util::set_by_path(ret, 'Name', @m_name)
521
+ else
522
+ missing << 'name' if @is_new
523
+ end
524
+ Saklient::Util::set_by_path(ret, 'Description', @m_description) if withClean || @n_description
525
+ if withClean || @n_tags
526
+ Saklient::Util::set_by_path(ret, 'Tags', [])
527
+ for r1 in @m_tags
528
+ v = nil
529
+ v = r1
530
+ ret[:Tags] << v
531
+ end
532
+ end
533
+ 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
534
+ if withClean || @n_ifaces
535
+ Saklient::Util::set_by_path(ret, 'Interfaces', [])
536
+ for r2 in @m_ifaces
537
+ v = nil
538
+ v = withClean ? ((r2).nil? ? nil : r2.api_serialize(withClean)) : ((r2).nil? ? { ID: '0' } : r2.api_serialize_id)
539
+ ret[:Interfaces] << v
540
+ end
541
+ end
542
+ Saklient::Util::set_by_path(ret, 'ServiceClass', @m_service_class) if withClean || @n_service_class
543
+ raise Saklient::Errors::SaklientException.new('required_field', 'Required fields must be set before the Appliance creation: ' + missing.join(', ')) if missing.length > 0
544
+ return ret
545
+ end
546
+
547
+ end
548
+
549
+ end
550
+ end
551
+ end