saklient 0.0.1.1 → 0.0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0126534b4a62bcf833c8479800e27011c71204e
4
- data.tar.gz: dbac41ad2d602d535e3ae05b43f4fffc1cf158e7
3
+ metadata.gz: 748198f5c71149eaa9d33f85f745c8449ae74680
4
+ data.tar.gz: 5a66f4f992fff57b4ba0ccefb0b4dddbbb22bfb1
5
5
  SHA512:
6
- metadata.gz: ec870815bfb4be70fd55d446c8f408338f8fdfc87b15fb0133fd65e674a6d7de6de307a97eea3a80282f192f7402b143729a06a1d0732eb67439d34ec30220dd
7
- data.tar.gz: 39e1e7dc632e20389343d65032ac3981c60d5d44a2f66e031732941d51ae078ee2365e127966e9ee030e4a6b874ef590115d450aaa36f765b5c35abe1d2ff425
6
+ metadata.gz: 79c177e6f7d0c678a39bbe4bb0f7b0364b6d519f442ba902140a8a7da25e7c9c9844dceb0a38d498530115acb6b3919bb1cdd38ddc4dfe5c46716270596ec69c
7
+ data.tar.gz: 096eb145cc4318322f8ecd38ea826987ec4518f2757861e3269670dd0a5b5dbd2c7ceed39e2fcd78198156b5a3ac760cf1959561d432693871c382d26929d355
@@ -56,7 +56,7 @@ module Saklient
56
56
  url = url_root + 'api/cloud/1.1' + path
57
57
  end
58
58
 
59
- url += '?' + URI.escape(json) if method == 'GET' and !params.empty?
59
+ url += '?' + URI.escape(json) if method == 'GET' and !params.nil?
60
60
 
61
61
  #println '// APIリクエスト中: #{method} #{path}'
62
62
 
@@ -73,7 +73,7 @@ module Saklient
73
73
 
74
74
  extra_headers = {
75
75
  'Content-Type' => 'application/x-www-form-urlencoded',
76
- 'User-Agent' => 'sacloud-client-ruby',
76
+ 'User-Agent' => 'saklient.ruby ver-0.0.2.2 rev-0de622ef1458f0fe03cbb11b1bec990a3bfa25c4',
77
77
  'X-Requested-With' => 'XMLHttpRequest',
78
78
  'X-Sakura-HTTP-Method' => method,
79
79
  'X-Sakura-Error-Level' => 'warning',
@@ -202,19 +202,28 @@ module Saklient
202
202
  return self
203
203
  end
204
204
 
205
+ # @private
206
+ # @param [String] className
207
+ # @param [any] obj
208
+ # @param [bool] wrapped
209
+ # @return [Saklient::Cloud::Resources::Resource]
210
+ def _create_resource_with(className, obj, wrapped = false)
211
+ Saklient::Util::validate_type(className, 'String')
212
+ Saklient::Util::validate_type(wrapped, 'bool')
213
+ className = _class_name if (className).nil?
214
+ return Saklient::Cloud::Resources::Resource::create_with(className, @_client, obj, wrapped)
215
+ end
216
+
205
217
  # 新規リソース作成用のオブジェクトを用意します.
206
218
  #
207
219
  # 返り値のオブジェクトにパラメータを設定し, save() を呼ぶことで実際のリソースが作成されます.
208
220
  #
209
221
  # @private
222
+ # @param [String] className
210
223
  # @return [Saklient::Cloud::Resources::Resource] リソースオブジェクト
211
- def _create
212
- a = [
213
- @_client,
214
- nil,
215
- false
216
- ]
217
- return Saklient::Util::create_class_instance('saklient.cloud.resources.' + _class_name, a)
224
+ def _create(className = nil)
225
+ Saklient::Util::validate_type(className, 'String')
226
+ return _create_resource_with(className, nil)
218
227
  end
219
228
 
220
229
  # 指定したIDを持つ唯一のリソースを取得します.
@@ -229,12 +238,7 @@ module Saklient
229
238
  result = @_client.request('GET', _api_path + '/' + Saklient::Util::url_encode(id), query)
230
239
  @_total = 1
231
240
  @_count = 1
232
- a = [
233
- @_client,
234
- result,
235
- true
236
- ]
237
- return Saklient::Util::create_class_instance('saklient.cloud.resources.' + _class_name, a)
241
+ return _create_resource_with(nil, result, true)
238
242
  end
239
243
 
240
244
  # リソースの検索リクエストを実行し, 結果をリストで取得します.
@@ -250,13 +254,7 @@ module Saklient
250
254
  data = []
251
255
  records = result[_root_key_m.to_sym]
252
256
  for record in records
253
- a = [
254
- @_client,
255
- record,
256
- false
257
- ]
258
- i = Saklient::Util::create_class_instance('saklient.cloud.resources.' + _class_name, a)
259
- data << i
257
+ data << _create_resource_with(nil, record)
260
258
  end
261
259
  return data
262
260
  end
@@ -273,12 +271,7 @@ module Saklient
273
271
  @_count = result[:Count]
274
272
  return nil if @_total == 0
275
273
  records = result[_root_key_m.to_sym]
276
- a = [
277
- @_client,
278
- records[0],
279
- false
280
- ]
281
- return Saklient::Util::create_class_instance('saklient.cloud.resources.' + _class_name, a)
274
+ return _create_resource_with(nil, records[0])
282
275
  end
283
276
 
284
277
  # 指定した文字列を名前に含むリソースに絞り込みます.
@@ -3,6 +3,9 @@
3
3
  require_relative '../client'
4
4
  require_relative 'model'
5
5
  require_relative '../resources/appliance'
6
+ require_relative '../resources/load_balancer'
7
+ require_relative '../resources/vpc_router'
8
+ require_relative '../resources/swytch'
6
9
 
7
10
  module Saklient
8
11
  module Cloud
@@ -76,6 +79,25 @@ module Saklient
76
79
  return _reset
77
80
  end
78
81
 
82
+ # @param [Saklient::Cloud::Resources::Swytch] swytch
83
+ # @param [Fixnum] vrid
84
+ # @param [Array<String>] realIps
85
+ # @param [bool] isHighSpec
86
+ # @return [Saklient::Cloud::Resources::LoadBalancer]
87
+ def create_load_balancer(swytch, vrid, realIps, isHighSpec = false)
88
+ Saklient::Util::validate_type(swytch, 'Saklient::Cloud::Resources::Swytch')
89
+ Saklient::Util::validate_type(vrid, 'Fixnum')
90
+ Saklient::Util::validate_type(realIps, 'Array')
91
+ Saklient::Util::validate_type(isHighSpec, 'bool')
92
+ ret = _create('LoadBalancer')
93
+ return ret.set_initial_params(swytch, vrid, realIps, isHighSpec)
94
+ end
95
+
96
+ # @return [Saklient::Cloud::Resources::VpcRouter]
97
+ def create_vpc_router
98
+ return _create('VpcRouter')
99
+ end
100
+
79
101
  # 指定したIDを持つ唯一のリソースを取得します.
80
102
  #
81
103
  # @param [String] id
@@ -3,6 +3,8 @@
3
3
  require_relative '../client'
4
4
  require_relative 'model'
5
5
  require_relative '../resources/archive'
6
+ require_relative '../resources/load_balancer'
7
+ require_relative '../resources/vpc_router'
6
8
  require_relative '../enums/escope'
7
9
 
8
10
  module Saklient
@@ -114,6 +114,38 @@ module Saklient
114
114
  return _with_name_like(name)
115
115
  end
116
116
 
117
+ # 指定したタグを持つリソースに絞り込みます.
118
+ #
119
+ # 複数のタグを指定する場合は withTags() を利用してください.
120
+ #
121
+ # @todo Implement test case
122
+ # @param [String] tag
123
+ # @return [Model_Router]
124
+ def with_tag(tag)
125
+ Saklient::Util::validate_type(tag, 'String')
126
+ return _with_tag(tag)
127
+ end
128
+
129
+ # 指定したすべてのタグを持つリソースに絞り込みます.
130
+ #
131
+ # @todo Implement test case
132
+ # @param [Array<String>] tags
133
+ # @return [Model_Router]
134
+ def with_tags(tags)
135
+ Saklient::Util::validate_type(tags, 'Array')
136
+ return _with_tags(tags)
137
+ end
138
+
139
+ # 指定したDNFに合致するタグを持つリソースに絞り込みます.
140
+ #
141
+ # @todo Implement test case
142
+ # @param [Array<Array<String>>] dnf
143
+ # @return [Model_Router]
144
+ def with_tag_dnf(dnf)
145
+ Saklient::Util::validate_type(dnf, 'Array')
146
+ return _with_tag_dnf(dnf)
147
+ end
148
+
117
149
  # 名前でソートします.
118
150
  #
119
151
  # @todo Implement test case
@@ -114,6 +114,38 @@ module Saklient
114
114
  return _with_name_like(name)
115
115
  end
116
116
 
117
+ # 指定したタグを持つリソースに絞り込みます.
118
+ #
119
+ # 複数のタグを指定する場合は withTags() を利用してください.
120
+ #
121
+ # @todo Implement test case
122
+ # @param [String] tag
123
+ # @return [Model_Swytch]
124
+ def with_tag(tag)
125
+ Saklient::Util::validate_type(tag, 'String')
126
+ return _with_tag(tag)
127
+ end
128
+
129
+ # 指定したすべてのタグを持つリソースに絞り込みます.
130
+ #
131
+ # @todo Implement test case
132
+ # @param [Array<String>] tags
133
+ # @return [Model_Swytch]
134
+ def with_tags(tags)
135
+ Saklient::Util::validate_type(tags, 'Array')
136
+ return _with_tags(tags)
137
+ end
138
+
139
+ # 指定したDNFに合致するタグを持つリソースに絞り込みます.
140
+ #
141
+ # @todo Implement test case
142
+ # @param [Array<Array<String>>] dnf
143
+ # @return [Model_Swytch]
144
+ def with_tag_dnf(dnf)
145
+ Saklient::Util::validate_type(dnf, 'Array')
146
+ return _with_tag_dnf(dnf)
147
+ end
148
+
117
149
  # 名前でソートします.
118
150
  #
119
151
  # @todo Implement test case