softlayer 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c19f44cbeeb5b86cbc8d04c6fd980cd6699d1f9
4
- data.tar.gz: 727f1a5cb636c9eb5df3ce71319b305df1490e0a
3
+ metadata.gz: 3a852ac905950499ded0c1ee0b252675117d037c
4
+ data.tar.gz: 564f43344c81ac8ff120dd4253ebd5714dca68b0
5
5
  SHA512:
6
- metadata.gz: e0da27455c1c3abf6dca3a973904e1f1683c1efe6c148b2772856d9c136ea434afb7d6363e5d684225f615b78d676710afa876e2eb6df189fd47b41cda52dc4d
7
- data.tar.gz: 177efb83838ce36bab4c24e93547bcfadc65b16af9c91272a323b24e62bca86da1cead87c3cb1290bb2e2cfe83b79e8630185b465e126d572cdd2de6b5665fa5
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
- * Improve support for masks and filters (parse a better format instead of using ruby hash)
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
 
@@ -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
  {
@@ -1,3 +1,3 @@
1
1
  module Softlayer
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
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.6
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-29 00:00:00.000000000 Z
11
+ date: 2016-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon