softlayer 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -3
- data/lib/softlayer/model.rb +4 -0
- data/lib/softlayer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a852ac905950499ded0c1ee0b252675117d037c
|
4
|
+
data.tar.gz: 564f43344c81ac8ff120dd4253ebd5714dca68b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e87fe136b2d4e82068c37d58b13403b91289b67760b160c3f08613c638d4faacd3a53d011ad139b8de323df7cf032250ec3dbe62d197582a1aebebb6d3d98779
|
7
|
+
data.tar.gz: 017e5036081f15a89e092dab2006970b0c70eecb3410f29be22bfb98689e030a0eb3f4a9c2375d2894046308bc44697ca600e2bbbe7ad60f06c199468742346d
|
data/README.md
CHANGED
@@ -39,13 +39,98 @@ Softlayer::Account.get_master_user
|
|
39
39
|
Softlayer::Account.get_virtual_guests
|
40
40
|
```
|
41
41
|
|
42
|
+
### Masks
|
43
|
+
|
44
|
+
If you'd like to get relational properties, you can use masks to get more information in a single request, lets consider the example below
|
45
|
+
|
46
|
+
Consider an example where we want to get datacenters, but not only their `id`, `longName`, `name` and `statusId` (default returned information), we want to get their groups too, instead of make one request per datacenter, we can get all the information with just one request
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
location_object_mask = "mask[groups]"
|
50
|
+
Softlayer::Location::Datacenter.mask(location_object_mask).get_datacenters
|
51
|
+
```
|
52
|
+
|
53
|
+
And _voilá_, we have all datacenters and its groups, pretty neat and cool, no?
|
54
|
+
|
55
|
+
Check the [Object Mask Article](https://sldn.softlayer.com/article/object-masks) on SoftLayer for more information.
|
56
|
+
|
57
|
+
### Filters
|
58
|
+
|
59
|
+
Lets consider an example where we want to find a datacenter based on its name, we can create a filter and do the request as following:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
location_object_filter = {
|
63
|
+
'name': {'operation': 'wdc01'}
|
64
|
+
}
|
65
|
+
Softlayer::Location::Datacenter.filter(location_object_filter)
|
66
|
+
```
|
67
|
+
|
68
|
+
For an `in` operation you must add the array inside an array because the client known issue, let's search for wdc01 and wdc04
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
location_object_filter = {
|
72
|
+
'name': {
|
73
|
+
'operation': "in",
|
74
|
+
"options": [[
|
75
|
+
{
|
76
|
+
"name": "data",
|
77
|
+
"value": [['wdc01', 'wdc04']]
|
78
|
+
}
|
79
|
+
]]
|
80
|
+
}
|
81
|
+
}
|
82
|
+
Softlayer::Location::Datacenter.filter(location_object_filter).get_datacenters
|
83
|
+
```
|
84
|
+
|
85
|
+
Check the [Object Filter Article](https://sldn.softlayer.com/article/object-filters) on SoftLayer for more information and operations.
|
86
|
+
|
87
|
+
### Limits
|
88
|
+
|
89
|
+
To use limits, let's search for groups of a datacenter, first we get a specific one
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
location_object_filter = {
|
93
|
+
'name': {'operation': 'sao01'}
|
94
|
+
}
|
95
|
+
sao01 = Softlayer::Location::Datacenter.filter(location_object_filter).get_datacenters.first
|
96
|
+
```
|
97
|
+
|
98
|
+
Then we can call the limits passing first the quantity, then the offset
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
sao01.limit(2, 0).get_groups # 2 elements, offset 0 (page 1)
|
102
|
+
sao01.limit(2, 2).get_groups # 2 elements, offset 2 (page 2)
|
103
|
+
sao01.limit(2, 4).get_groups # 2 elements, offset 4 (page 3)
|
104
|
+
```
|
105
|
+
|
106
|
+
### Complex Operations
|
107
|
+
|
108
|
+
What if you want to use a mask, filtering just what you want and limiting the request, can we do this? Sure!
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
location_object_filter = {
|
112
|
+
'name': {
|
113
|
+
'operation': "in",
|
114
|
+
"options": [[
|
115
|
+
{
|
116
|
+
"name": "data",
|
117
|
+
"value": [['wdc01', 'wdc04']]
|
118
|
+
}
|
119
|
+
]]
|
120
|
+
}
|
121
|
+
}
|
122
|
+
location_object_mask = "mask[groups]"
|
123
|
+
Softlayer::Location::Datacenter.filter(location_object_filter).mask(location_object_mask).limit(1, 0).get_datacenters
|
124
|
+
```
|
125
|
+
|
126
|
+
ps: `getDatacenters` message does not accept a `resultLimit` header, just using on the call above as an example, to check if the message accepts a `resultLimit` or not you need to check the WSDL file for the service.
|
127
|
+
|
42
128
|
## README Driven Development
|
43
129
|
|
44
|
-
*
|
130
|
+
* No feature on roadmap
|
45
131
|
|
46
132
|
## Known Issues
|
47
133
|
|
48
|
-
* Mask and Filter not working correctly with `SoftLayer_Account` calls
|
49
134
|
* Using Savon master until a version is released containing the commit to support rpc/encoded XML
|
50
135
|
* Actually arrays are being wrongly mapped, so when we pass an argument containing **one** array, we need to pass inside another array, like this:
|
51
136
|
|
@@ -61,7 +146,7 @@ parameters = {
|
|
61
146
|
}
|
62
147
|
```
|
63
148
|
|
64
|
-
hope to fix this _really soon_
|
149
|
+
hope to fix this _really soon_, in the meanwhile you can check the progress of this bug on this [issue](https://github.com/savonrb/savon/issues/752)
|
65
150
|
|
66
151
|
## Development
|
67
152
|
|
data/lib/softlayer/model.rb
CHANGED
@@ -129,6 +129,10 @@ module Softlayer #:nodoc:
|
|
129
129
|
(self.class.to_s+"::Representer").constantize.new(self).to_hash
|
130
130
|
end
|
131
131
|
|
132
|
+
def service_name
|
133
|
+
self.class.service_name
|
134
|
+
end
|
135
|
+
|
132
136
|
def init_headers
|
133
137
|
raise Exception.new('You need to set the ID on object') if id.nil?
|
134
138
|
{
|
data/lib/softlayer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: softlayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Celso Fernandes
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|