softlayer_api 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.textile +16 -6
- data/README.textile +1 -1
- data/examples/accountInformation.rb +18 -22
- data/examples/createTicket.rb +18 -22
- data/examples/openTickets.rb +18 -22
- data/examples/ticket_info.rb +18 -22
- data/lib/softlayer/base.rb +19 -47
- data/lib/softlayer/object_mask_helpers.rb +18 -22
- data/lib/softlayer/service.rb +31 -26
- data/lib/softlayer_api.rb +18 -22
- metadata +38 -23
- data/test/SoftLayer_APIParameterFilter.rb +0 -81
- data/test/SoftLayer_Service.rb +0 -361
- data/test/SoftLayer_ToObjectMask.rb +0 -92
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f7f6dacd2a3f7e2589109a815000ed208497963e
|
4
|
+
data.tar.gz: b8b38d3cdaa828b98508ba13e494d0b771257c70
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b80012657f2387a7ef60bfb284a64e2fa65ff6f8095a8b074d6992504f461b4547215607c583943ce13d86e9790fb7eddf8e5a3af90ca89eabb24293a3c7d5bf
|
7
|
+
data.tar.gz: aa3cc1087a9449539d69c29277a73b4a436afe61ce5ec1b25a9235e0bb4aa7dbc5af747e1fe60dc3eff5de63f5a4d224490977832742b87f59f6b8c28569ec25
|
data/LICENSE.textile
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
-
Copyright (c) 2010
|
1
|
+
Copyright (c) 2010-2014 "SoftLayer Technologies, Inc.":http://www.softlayer.com/ All rights reserved.
|
2
2
|
|
3
|
-
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
* Neither SoftLayer Technologies, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
8
12
|
|
9
|
-
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.textile
CHANGED
@@ -248,4 +248,4 @@ This software is written by the SoftLayer Development Team <"sldn@softlayer.com"
|
|
248
248
|
|
249
249
|
h2. Copyright
|
250
250
|
|
251
|
-
This software is Copyright (c) 2010 "SoftLayer Technologies, Inc":http://www.softlayer.com/. See the bundled LICENSE.textile file for more information.
|
251
|
+
This software is Copyright (c) 2010-2014 "SoftLayer Technologies, Inc":http://www.softlayer.com/. See the bundled LICENSE.textile file for more information.
|
@@ -1,28 +1,24 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
1
|
#
|
3
|
-
#
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
2
|
+
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
5
3
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
14
21
|
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
22
|
|
27
23
|
require 'rubygems'
|
28
24
|
require 'softlayer_api'
|
data/examples/createTicket.rb
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
1
|
#
|
3
|
-
#
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
2
|
+
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
5
3
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
14
21
|
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
22
|
|
27
23
|
require 'rubygems'
|
28
24
|
require 'softlayer_api'
|
data/examples/openTickets.rb
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
1
|
#
|
3
|
-
#
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
2
|
+
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
5
3
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
14
21
|
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
22
|
|
27
23
|
require 'rubygems'
|
28
24
|
require 'softlayer_api'
|
data/examples/ticket_info.rb
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
1
|
#
|
3
|
-
#
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
2
|
+
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
5
3
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
14
21
|
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
22
|
|
27
23
|
require 'rubygems'
|
28
24
|
require 'softlayer_api'
|
data/lib/softlayer/base.rb
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
1
|
#
|
3
|
-
#
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
2
|
+
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
5
3
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
14
21
|
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
22
|
|
27
23
|
# The SoftLayer Module
|
28
24
|
#
|
@@ -36,7 +32,7 @@
|
|
36
32
|
#
|
37
33
|
|
38
34
|
module SoftLayer
|
39
|
-
VERSION = "1.0.
|
35
|
+
VERSION = "1.0.8" # version history at the bottom of the file.
|
40
36
|
|
41
37
|
# The base URL of the SoftLayer API's REST-like endpoints available to the public internet.
|
42
38
|
API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/rest/v3/'
|
@@ -60,27 +56,3 @@ module SoftLayer
|
|
60
56
|
# The base URL used for the SoftLayer API's
|
61
57
|
$SL_API_BASE_URL = SoftLayer::API_PUBLIC_ENDPOINT
|
62
58
|
end # module SoftLayer
|
63
|
-
|
64
|
-
#
|
65
|
-
# History:
|
66
|
-
#
|
67
|
-
# 1.0 - 1.0.1 - Initial release. There was some confusion over getting the gem
|
68
|
-
# posted up to rubygems.org and the 1.0.1 release came about because of that
|
69
|
-
# confusion. There should be no real functionality differences there.
|
70
|
-
#
|
71
|
-
# 1.0.2 - We have some API routines that start with 'get' but expect arguments
|
72
|
-
# anyway. The code now uses HTTP POST to send requests for which the user
|
73
|
-
# has provided arguments regardless of the name of the routine.
|
74
|
-
#
|
75
|
-
# 1.0.3 - Added a request filter to add result limits to request. Submitted by
|
76
|
-
# JN. Thanks!
|
77
|
-
#
|
78
|
-
# 1.0.4 - Fixed a bug where the result_limit and result_offset object filters were just not working.
|
79
|
-
#
|
80
|
-
# 1.0.5 - Fixed a bug where empty hashes and empty arrays would not generate meaningful object masks
|
81
|
-
#
|
82
|
-
# 1.0.6 - Make all API calls with either a GET or a POST as the HTTP verb.
|
83
|
-
#
|
84
|
-
# 1.0.7 - Calls to the "getObject" method of any service should not take parameters. The gem now
|
85
|
-
# warns if you make this type of call and ignores the parameters. This prevents
|
86
|
-
# SoftLayer_Virtual_Guest::getObject from accidentally creating (billable) CCI instances.
|
@@ -1,28 +1,24 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
1
|
#
|
3
|
-
#
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
2
|
+
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
5
3
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
14
21
|
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
22
|
|
27
23
|
class Hash
|
28
24
|
def to_sl_object_mask(base = "")
|
data/lib/softlayer/service.rb
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
1
|
#
|
3
|
-
#
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
2
|
+
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
5
3
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
14
21
|
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
22
|
|
27
23
|
require 'rubygems'
|
28
24
|
require 'net/https'
|
@@ -102,7 +98,6 @@ module SoftLayer
|
|
102
98
|
self.parameters[:result_offset]
|
103
99
|
end
|
104
100
|
|
105
|
-
|
106
101
|
def method_missing(method_name, *args, &block)
|
107
102
|
return @target.call_softlayer_api_with_params(method_name, self, args, &block)
|
108
103
|
end
|
@@ -138,6 +133,9 @@ module SoftLayer
|
|
138
133
|
# The base URL for requests that are passed to the server. Cannot be emtpy or nil.
|
139
134
|
attr_accessor :endpoint_url
|
140
135
|
|
136
|
+
# The User-Agent header sent to SoftLayer API.
|
137
|
+
attr_accessor :user_agent
|
138
|
+
|
141
139
|
# Initialize an instance of the Client class. You pass in the service name
|
142
140
|
# and optionally hash arguments specifying how the client should access the
|
143
141
|
# SoftLayer API.
|
@@ -167,11 +165,17 @@ module SoftLayer
|
|
167
165
|
# public endpoint
|
168
166
|
self.endpoint_url = options[:endpoint_url] || $SL_API_BASE_URL || API_PUBLIC_ENDPOINT
|
169
167
|
|
168
|
+
@user_agent = {"User-Agent" => options[:user_agent] || "SoftLayer API Ruby Client #{SoftLayer::VERSION}"}
|
169
|
+
|
170
170
|
if($DEBUG)
|
171
171
|
@method_missing_call_depth = 0
|
172
172
|
end
|
173
173
|
end #initalize
|
174
174
|
|
175
|
+
# Use this to set the user agent string for this API client.
|
176
|
+
def user_agent=(set)
|
177
|
+
self.user_agent['User-Agent'] = set
|
178
|
+
end
|
175
179
|
|
176
180
|
# Use this as part of a method call chain to identify a particular
|
177
181
|
# object as the target of the request. The parameter is the SoftLayer
|
@@ -331,9 +335,9 @@ module SoftLayer
|
|
331
335
|
end
|
332
336
|
|
333
337
|
if request_body && !request_body.empty?
|
334
|
-
url_request = Net::HTTP::Post.new(method_url.request_uri(), content_type_header)
|
338
|
+
url_request = Net::HTTP::Post.new(method_url.request_uri(), content_type_header.merge(self.user_agent))
|
335
339
|
else
|
336
|
-
url_request = Net::HTTP::Get.new(method_url.request_uri())
|
340
|
+
url_request = Net::HTTP::Get.new(method_url.request_uri(), self.user_agent)
|
337
341
|
end
|
338
342
|
|
339
343
|
# This warning should be obsolete as we should be using POST if the user
|
@@ -459,4 +463,5 @@ module SoftLayer
|
|
459
463
|
@endpoint_url = new_url.strip
|
460
464
|
end
|
461
465
|
end # class Service
|
462
|
-
end # module SoftLayer
|
466
|
+
end # module SoftLayer
|
467
|
+
|
data/lib/softlayer_api.rb
CHANGED
@@ -1,28 +1,24 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
1
|
#
|
3
|
-
#
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
2
|
+
# Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
|
5
3
|
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
14
21
|
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
22
|
|
27
23
|
require 'softlayer/base'
|
28
24
|
require 'softlayer/object_mask_helpers'
|
metadata
CHANGED
@@ -1,30 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: softlayer_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- SoftLayer Development Team
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '1.8'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.8.1
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.8'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.8.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
28
45
|
- !ruby/object:Gem::Version
|
29
46
|
version: '0'
|
30
47
|
description: The softlayer_api gem offers a convenient mechanism for invoking the
|
@@ -34,41 +51,39 @@ executables: []
|
|
34
51
|
extensions: []
|
35
52
|
extra_rdoc_files: []
|
36
53
|
files:
|
37
|
-
- README.textile
|
38
54
|
- LICENSE.textile
|
39
|
-
-
|
40
|
-
- lib/softlayer/object_mask_helpers.rb
|
41
|
-
- lib/softlayer/service.rb
|
42
|
-
- lib/softlayer_api.rb
|
43
|
-
- test/SoftLayer_APIParameterFilter.rb
|
44
|
-
- test/SoftLayer_Service.rb
|
45
|
-
- test/SoftLayer_ToObjectMask.rb
|
55
|
+
- README.textile
|
46
56
|
- examples/accountInformation.rb
|
47
57
|
- examples/createTicket.rb
|
48
58
|
- examples/openTickets.rb
|
49
59
|
- examples/ticket_info.rb
|
60
|
+
- lib/softlayer/base.rb
|
61
|
+
- lib/softlayer/object_mask_helpers.rb
|
62
|
+
- lib/softlayer/service.rb
|
63
|
+
- lib/softlayer_api.rb
|
50
64
|
homepage: http://sldn.softlayer.com/
|
51
|
-
licenses:
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
52
68
|
post_install_message:
|
53
69
|
rdoc_options: []
|
54
70
|
require_paths:
|
55
71
|
- lib
|
56
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
73
|
requirements:
|
59
|
-
- -
|
74
|
+
- - ">="
|
60
75
|
- !ruby/object:Gem::Version
|
61
76
|
version: '0'
|
62
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
78
|
requirements:
|
65
|
-
- -
|
79
|
+
- - ">="
|
66
80
|
- !ruby/object:Gem::Version
|
67
81
|
version: '0'
|
68
82
|
requirements: []
|
69
83
|
rubyforge_project:
|
70
|
-
rubygems_version:
|
84
|
+
rubygems_version: 2.2.2
|
71
85
|
signing_key:
|
72
|
-
specification_version:
|
86
|
+
specification_version: 4
|
73
87
|
summary: Library for accessing the SoftLayer portal API
|
74
88
|
test_files: []
|
89
|
+
has_rdoc: true
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Redistribution and use in source and binary forms, with or without
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
5
|
-
#
|
6
|
-
# * Redistributions of source code must retain the above copyright notice,
|
7
|
-
# this list of conditions and the following disclaimer.
|
8
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
9
|
-
# this list of conditions and the following disclaimer in the documentation
|
10
|
-
# and/or other materials provided with the distribution.
|
11
|
-
# * Neither SoftLayer Technologies, Inc. nor the names of its contributors may
|
12
|
-
# be used to endorse or promote products derived from this software without
|
13
|
-
# specific prior written permission.
|
14
|
-
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
|
-
|
27
|
-
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
28
|
-
|
29
|
-
require 'rubygems'
|
30
|
-
require 'softlayer_api'
|
31
|
-
require 'rspec'
|
32
|
-
|
33
|
-
describe SoftLayer::APIParameterFilter, "#object_with_id" do
|
34
|
-
it "should intitialize with empty parameter values" do
|
35
|
-
filter = SoftLayer::APIParameterFilter.new
|
36
|
-
filter.server_object_id.should be_nil
|
37
|
-
filter.server_object_mask.should be_nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should store its value in server_object_id when called " do
|
41
|
-
filter = SoftLayer::APIParameterFilter.new
|
42
|
-
result = filter.object_with_id(12345)
|
43
|
-
result.server_object_id.should eql(12345)
|
44
|
-
result.parameters.should eql({:server_object_id => 12345})
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should allow call chaining with object_mask " do
|
48
|
-
filter = SoftLayer::APIParameterFilter.new
|
49
|
-
result = filter.object_with_id(12345).object_mask("fish", "cow", "duck")
|
50
|
-
result.server_object_id.should == 12345
|
51
|
-
result.server_object_mask.should == ["fish", "cow", "duck"]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe SoftLayer::APIParameterFilter, "#object_mask" do
|
56
|
-
it "should store its value in server_object_mask when called" do
|
57
|
-
filter = SoftLayer::APIParameterFilter.new
|
58
|
-
result = filter.object_mask("fish", "cow", "duck")
|
59
|
-
result.server_object_mask.should == ["fish", "cow", "duck"]
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should allow call chaining with object_with_id" do
|
63
|
-
filter = SoftLayer::APIParameterFilter.new
|
64
|
-
result = filter.object_mask("fish", "cow", "duck").object_with_id(12345)
|
65
|
-
result.server_object_id.should == 12345
|
66
|
-
result.server_object_mask.should == ["fish", "cow", "duck"]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe SoftLayer::APIParameterFilter, "#method_missing" do
|
71
|
-
it "should invoke call_softlayer_api_with_params(method_name, self, args, &block) on it's target with itself and the method_missing parameters" do
|
72
|
-
filter = SoftLayer::APIParameterFilter.new.object_mask("fish", "cow", "duck").object_with_id(12345)
|
73
|
-
|
74
|
-
target = mock("method_missing_target")
|
75
|
-
target.should_receive(:call_softlayer_api_with_params).with(:getObject, filter, ["marshmallow"])
|
76
|
-
|
77
|
-
filter.target = target
|
78
|
-
|
79
|
-
filter.getObject("marshmallow")
|
80
|
-
end
|
81
|
-
end
|
data/test/SoftLayer_Service.rb
DELETED
@@ -1,361 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Redistribution and use in source and binary forms, with or without
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
5
|
-
#
|
6
|
-
# * Redistributions of source code must retain the above copyright notice,
|
7
|
-
# this list of conditions and the following disclaimer.
|
8
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
9
|
-
# this list of conditions and the following disclaimer in the documentation
|
10
|
-
# and/or other materials provided with the distribution.
|
11
|
-
# * Neither SoftLayer Technologies, Inc. nor the names of its contributors may
|
12
|
-
# be used to endorse or promote products derived from this software without
|
13
|
-
# specific prior written permission.
|
14
|
-
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
|
-
|
27
|
-
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
28
|
-
|
29
|
-
require 'rubygems'
|
30
|
-
require 'softlayer_api'
|
31
|
-
require 'rspec'
|
32
|
-
require 'rspec/autorun'
|
33
|
-
|
34
|
-
describe SoftLayer::Service, "#new" do
|
35
|
-
before(:each) do
|
36
|
-
$SL_API_USERNAME = "some_default_username"
|
37
|
-
$SL_API_KEY = "some_default_api_key"
|
38
|
-
$SL_API_BASE_URL = SoftLayer::API_PUBLIC_ENDPOINT
|
39
|
-
end
|
40
|
-
|
41
|
-
after(:each) do
|
42
|
-
$SL_API_USERNAME = nil
|
43
|
-
$SL_API_KEY = nil
|
44
|
-
$SL_API_BASE_URL = SoftLayer::API_PUBLIC_ENDPOINT
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should reject a nil or empty service name" do
|
48
|
-
lambda() {service = SoftLayer::Service.new(nil)}.should raise_error
|
49
|
-
lambda() {service = SoftLayer::Service.new("")}.should raise_error
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should remember service name passed in" do
|
53
|
-
service = SoftLayer::Service.new("SoftLayer_Account")
|
54
|
-
service.service_name.should == "SoftLayer_Account"
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should pickup default username" do
|
58
|
-
$SL_API_USERNAME = "sample"
|
59
|
-
service = SoftLayer::Service.new("SoftLayer_Account")
|
60
|
-
service.username.should == "sample"
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should accept a username in options" do
|
64
|
-
$SL_API_USERNAME = "sample"
|
65
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => 'fred')
|
66
|
-
service.username.should == "fred"
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should pickup default api key" do
|
70
|
-
$SL_API_KEY = "sample"
|
71
|
-
service = SoftLayer::Service.new("SoftLayer_Account")
|
72
|
-
service.api_key.should == "sample"
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should accept an api key in options" do
|
76
|
-
$SL_API_KEY = "sample"
|
77
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :api_key => 'fred')
|
78
|
-
service.api_key.should == "fred"
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should fail if username is empty" do
|
82
|
-
lambda() do
|
83
|
-
$SL_API_USERNAME = ""
|
84
|
-
$SL_API_KEY = "sample"
|
85
|
-
|
86
|
-
service = SoftLayer::Service.new("SoftLayer_Account")
|
87
|
-
end.should raise_error
|
88
|
-
|
89
|
-
lambda() do
|
90
|
-
$SL_API_USERNAME = "good_username"
|
91
|
-
$SL_API_KEY = "sample"
|
92
|
-
|
93
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "")
|
94
|
-
end.should raise_error
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should fail if username is nil" do
|
98
|
-
lambda() do
|
99
|
-
$SL_API_USERNAME = nil
|
100
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :api_key => "sample")
|
101
|
-
end.should raise_error
|
102
|
-
|
103
|
-
lambda() do
|
104
|
-
$SL_API_KEY = "sample"
|
105
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => nil, :api_key => "sample")
|
106
|
-
end.should raise_error
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should fail if api_key is empty" do
|
110
|
-
lambda() do
|
111
|
-
$SL_API_USERNAME = "good_username"
|
112
|
-
$SL_API_KEY = ""
|
113
|
-
|
114
|
-
service = SoftLayer::Service.new("SoftLayer_Account")
|
115
|
-
end.should raise_error
|
116
|
-
|
117
|
-
lambda() do
|
118
|
-
$SL_API_USERNAME = "good_username"
|
119
|
-
$SL_API_KEY = "good_api_key"
|
120
|
-
|
121
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample", :api_key => "")
|
122
|
-
end.should raise_error
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should fail if api_key is nil" do
|
126
|
-
lambda() do
|
127
|
-
$SL_API_KEY = nil
|
128
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample")
|
129
|
-
end.should raise_error
|
130
|
-
|
131
|
-
lambda() do
|
132
|
-
$SL_API_KEY = nil
|
133
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample", :api_key => nil)
|
134
|
-
end.should raise_error
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should pickup default base url" do
|
138
|
-
$SL_API_BASE_URL = nil
|
139
|
-
service = SoftLayer::Service.new("SoftLayer_Account")
|
140
|
-
service.endpoint_url.should == SoftLayer::API_PUBLIC_ENDPOINT
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should get base URL from globals" do
|
144
|
-
$SL_API_BASE_URL = "http://someendpoint.softlayer.com/from/globals"
|
145
|
-
service = SoftLayer::Service.new("SoftLayer_Account")
|
146
|
-
service.endpoint_url.should == "http://someendpoint.softlayer.com/from/globals"
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should accept a base url through options" do
|
150
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :endpoint_url => "http://someendpoint.softlayer.com")
|
151
|
-
service.endpoint_url.should == "http://someendpoint.softlayer.com"
|
152
|
-
end
|
153
|
-
end #describe SoftLayer#new
|
154
|
-
|
155
|
-
describe SoftLayer::Service, "#username=" do
|
156
|
-
it "should not allow you to set a nil or empty username" do
|
157
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample", :api_key => "sample")
|
158
|
-
lambda() {service.username = ""}.should raise_error
|
159
|
-
lambda() {service.username = nil}.should raise_error
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should strip whitespace" do
|
163
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample", :api_key => "sample")
|
164
|
-
service.username = " whitespace "
|
165
|
-
service.username.should == "whitespace"
|
166
|
-
end
|
167
|
-
end #describe SoftLayer#username=
|
168
|
-
|
169
|
-
describe SoftLayer::Service, "#api_key=" do
|
170
|
-
it "should not allow you to set a nil or empty api_key" do
|
171
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample", :api_key => "sample")
|
172
|
-
lambda() {service.api_key = ""}.should raise_error
|
173
|
-
lambda() {service.api_key = nil}.should raise_error
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should strip whitespace" do
|
177
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample", :api_key => "sample")
|
178
|
-
service.api_key = " fred "
|
179
|
-
service.api_key.should == "fred"
|
180
|
-
end
|
181
|
-
end #describe SoftLayer#api_key=
|
182
|
-
|
183
|
-
describe SoftLayer::Service, "#endpoint_url=" do
|
184
|
-
it "should not allow you to set a nil or empty endpoint_url" do
|
185
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample", :api_key => "sample", :endpoint_url => "http://someendpoint.softlayer.com")
|
186
|
-
lambda() {service.endpoint_url = ""}.should raise_error
|
187
|
-
lambda() {service.endpoint_url = nil}.should raise_error
|
188
|
-
end
|
189
|
-
|
190
|
-
it "should strip whitespace" do
|
191
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample", :api_key => "sample", :endpoint_url => "http://someendpoint.softlayer.com")
|
192
|
-
service.endpoint_url = " http://someendpoint.softlayer.com "
|
193
|
-
service.endpoint_url.should == "http://someendpoint.softlayer.com"
|
194
|
-
end
|
195
|
-
end #describe SoftLayer#endpoint_url=
|
196
|
-
|
197
|
-
describe SoftLayer::Service, "#url_to_call_method" do
|
198
|
-
it "should concatenate the method to the base url" do
|
199
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
200
|
-
|
201
|
-
# make sure we've picked up the default API key (can be wrong if one of the other tests is misbehaving)
|
202
|
-
service.endpoint_url.should == SoftLayer::API_PUBLIC_ENDPOINT
|
203
|
-
|
204
|
-
call_url = service.url_to_call_method("getOpenTickets", nil);
|
205
|
-
call_url.scheme.should == "https"
|
206
|
-
call_url.host.should == "api.softlayer.com"
|
207
|
-
call_url.path.should == "/rest/v3/SoftLayer_Account/getOpenTickets.json"
|
208
|
-
end #describe SoftLayer#url_to_call_method=
|
209
|
-
end
|
210
|
-
|
211
|
-
describe SoftLayer::Service, "#object_with_id" do
|
212
|
-
it "should add an object to the URL for a request " do
|
213
|
-
service = SoftLayer::Service.new("SoftLayer_Ticket", :username => "sample_username", :api_key => "blah")
|
214
|
-
service.should_receive(:issue_http_request).with(URI.parse("https://api.softlayer.com/rest/v3/SoftLayer_Ticket/12345/getObject.json"), an_instance_of(Net::HTTP::Get))
|
215
|
-
service.object_with_id(12345).getObject
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe SoftLayer::Service, "#missing_method" do
|
220
|
-
it "should translate unknown method into an api call" do
|
221
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
222
|
-
service.should_receive(:call_softlayer_api_with_params).with(:getOpenTickets, nil, ["marshmallow"])
|
223
|
-
response = service.getOpenTickets("marshmallow")
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
describe SoftLayer::Service, "#http_request_for_method" do
|
228
|
-
it "should only use HTTP GET for requests to the getObject method even if paramters are provided" do
|
229
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
230
|
-
request = service.http_request_for_method(:getObject, URI.parse("https://api.softlayer.com/rest/v3/SoftLayer_Ticket/12345/getObject.json"), '{"simple" : "object"}')
|
231
|
-
request.should be_a_kind_of(Net::HTTP::Get)
|
232
|
-
request.should_not be_a_kind_of(Net::HTTP::Post)
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
describe SoftLayer::Service, "#call_softlayer_api_with_params" do
|
237
|
-
it "should issue an HTTP request for the given method" do
|
238
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
239
|
-
service.should_receive(:issue_http_request).with(any_args())
|
240
|
-
service.call_softlayer_api_with_params(:getObject, nil, []);
|
241
|
-
end
|
242
|
-
|
243
|
-
it "should include the object id in the url created" do
|
244
|
-
service = SoftLayer::Service.new("SoftLayer_Ticket", :username => "sample_username", :api_key => "blah")
|
245
|
-
service.should_receive(:issue_http_request).with(URI.parse("https://api.softlayer.com/rest/v3/SoftLayer_Ticket/12345/getObject.json"), an_instance_of(Net::HTTP::Get))
|
246
|
-
service.call_softlayer_api_with_params(:getObject, SoftLayer::APIParameterFilter.new.object_with_id(12345), []);
|
247
|
-
end
|
248
|
-
|
249
|
-
it "should include the object mask in the url created" do
|
250
|
-
expected_uri = "https://api.softlayer.com/rest/v3/SoftLayer_Account/getObject.json?objectMask=cow;duck;chicken;bull%20dog"
|
251
|
-
|
252
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
253
|
-
service.should_receive(:issue_http_request).with(URI.parse(expected_uri), an_instance_of(Net::HTTP::Get))
|
254
|
-
service.call_softlayer_api_with_params(:getObject, SoftLayer::APIParameterFilter.new.object_mask("cow ", " duck", "chicken", "bull dog"), []);
|
255
|
-
end
|
256
|
-
|
257
|
-
it "should return the parsed JSON when completing successfully" do
|
258
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
259
|
-
service.should_receive(:issue_http_request).with(any_args()).and_return('{"successful":"Yipeee!", "array":[1,2,3], "bool":true}')
|
260
|
-
result = service.getObject
|
261
|
-
result.should == {"array"=>[1, 2, 3], "successful"=>"Yipeee!", "bool"=>true}
|
262
|
-
end
|
263
|
-
|
264
|
-
it "should raise an exception when completing unsuccessfully" do
|
265
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
266
|
-
service.should_receive(:issue_http_request).with(any_args()).and_return('{"error":"Function (\"getSnargled\") is not a valid method for this service"}')
|
267
|
-
lambda{ result = service.getSnargled }.should raise_error
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
describe SoftLayer::Service, "#object_with_id" do
|
272
|
-
it "should return an APIParameterFilter with itself as the target" do
|
273
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
274
|
-
filter = service.object_with_id(12345)
|
275
|
-
|
276
|
-
filter.should_not be_nil
|
277
|
-
filter.target.should === service
|
278
|
-
filter.server_object_id.should == 12345
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
describe SoftLayer::Service, "#object_mask" do
|
283
|
-
it "should return an APIParameterFilter with itself as the target" do
|
284
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
285
|
-
filter = service.object_mask("fish", "cow", "duck")
|
286
|
-
|
287
|
-
filter.should_not be_nil
|
288
|
-
filter.target.should === service
|
289
|
-
filter.server_object_mask.should == ["fish", "cow", "duck"]
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
describe SoftLayer::Service, "#result_limit" do
|
294
|
-
it "should return an APIParameterFilter with itself as the target" do
|
295
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
296
|
-
filter = service.result_limit(10)
|
297
|
-
|
298
|
-
filter.should_not be_nil
|
299
|
-
filter.target.should === service
|
300
|
-
filter.server_result_limit.should == 10
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
describe SoftLayer::Service, "#result_offset" do
|
305
|
-
it "should return an APIParameterFilter with itself as the target" do
|
306
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
307
|
-
filter = service.result_offset(5)
|
308
|
-
|
309
|
-
filter.should_not be_nil
|
310
|
-
filter.target.should === service
|
311
|
-
filter.server_result_offset.should == 5
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
describe SoftLayer::Service, "#marshall_arguments_for_call" do
|
316
|
-
service = SoftLayer::Service.new("SoftLayer_Account", :username => "sample_username", :api_key => "blah")
|
317
|
-
request_body = service.marshall_arguments_for_call(["first", 3, {"cow" => "chicken"}])
|
318
|
-
request_body.should == '{"parameters":["first",3,{"cow":"chicken"}]}'
|
319
|
-
end
|
320
|
-
|
321
|
-
describe SoftLayer::Service, " creating option proxies" do
|
322
|
-
it "should allow me to create a proxy object with just the object_with_id option" do
|
323
|
-
service = SoftLayer::Service.new("SoftLayer_Ticket", :username => "sample_username", :api_key => "blah")
|
324
|
-
ticket_proxy = service.object_with_id(123456)
|
325
|
-
|
326
|
-
ticket_proxy.server_object_id.should eql(123456)
|
327
|
-
service.should_receive(:call_softlayer_api_with_params).with(any_args())
|
328
|
-
ticket_proxy.getObject
|
329
|
-
end
|
330
|
-
|
331
|
-
it "should allow me to create a proxy object with just the object_mask option" do
|
332
|
-
service = SoftLayer::Service.new("SoftLayer_Ticket", :username => "sample_username", :api_key => "blah")
|
333
|
-
ticket_proxy = service.object_mask("fish", "cow", "duck")
|
334
|
-
|
335
|
-
ticket_proxy.server_object_mask.should eql(["fish", "cow", "duck"])
|
336
|
-
service.should_receive(:call_softlayer_api_with_params).with(any_args())
|
337
|
-
ticket_proxy.getObject
|
338
|
-
end
|
339
|
-
|
340
|
-
it "should not modify an object_with_id proxy even if that proxy is used with a mask" do
|
341
|
-
service = SoftLayer::Service.new("SoftLayer_Ticket", :username => "sample_username", :api_key => "blah")
|
342
|
-
ticket_proxy = service.object_with_id(123456)
|
343
|
-
|
344
|
-
service.should_receive(:issue_http_request).with(URI.parse("https://api.softlayer.com/rest/v3/SoftLayer_Ticket/123456/getObject.json?objectMask=fish;cow;duck"), an_instance_of(Net::HTTP::Get))
|
345
|
-
ticket_proxy.object_mask("fish", "cow", "duck").getObject
|
346
|
-
|
347
|
-
ticket_proxy.server_object_id.should eql(123456)
|
348
|
-
ticket_proxy.server_object_mask.should be_nil
|
349
|
-
end
|
350
|
-
|
351
|
-
it "should not modify an object_mask proxy even if it is used with an object ID" do
|
352
|
-
service = SoftLayer::Service.new("SoftLayer_Ticket", :username => "sample_username", :api_key => "blah")
|
353
|
-
masked_proxy = service.object_mask("fish", "cow", "duck")
|
354
|
-
|
355
|
-
service.should_receive(:issue_http_request).with(URI.parse("https://api.softlayer.com/rest/v3/SoftLayer_Ticket/123456/getObject.json?objectMask=fish;cow;duck"), an_instance_of(Net::HTTP::Get))
|
356
|
-
masked_proxy.object_with_id(123456).getObject
|
357
|
-
|
358
|
-
masked_proxy.server_object_id.should be_nil
|
359
|
-
masked_proxy.server_object_mask.should eql(["fish", "cow", "duck"])
|
360
|
-
end
|
361
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Redistribution and use in source and binary forms, with or without
|
4
|
-
# modification, are permitted provided that the following conditions are met:
|
5
|
-
#
|
6
|
-
# * Redistributions of source code must retain the above copyright notice,
|
7
|
-
# this list of conditions and the following disclaimer.
|
8
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
9
|
-
# this list of conditions and the following disclaimer in the documentation
|
10
|
-
# and/or other materials provided with the distribution.
|
11
|
-
# * Neither SoftLayer Technologies, Inc. nor the names of its contributors may
|
12
|
-
# be used to endorse or promote products derived from this software without
|
13
|
-
# specific prior written permission.
|
14
|
-
#
|
15
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
16
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
19
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
20
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
21
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
22
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
23
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
24
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
25
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
26
|
-
|
27
|
-
$: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
28
|
-
|
29
|
-
require 'rubygems'
|
30
|
-
require 'softlayer_api'
|
31
|
-
require 'rspec'
|
32
|
-
require 'rspec/autorun'
|
33
|
-
|
34
|
-
describe String, "#to_sl_object_mask" do
|
35
|
-
it "should echo back a string with no base" do
|
36
|
-
"blah".to_sl_object_mask.should eql("blah")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should prepend the base with a dot if given" do
|
40
|
-
"blah".to_sl_object_mask("foo").should eql("foo.blah")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should return the empty string if given the empty string with no base" do
|
44
|
-
"".to_sl_object_mask.should eql("")
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should return the base with no dot if applied to the empty string" do
|
48
|
-
"".to_sl_object_mask("foo").should eql("foo")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe Array,"#to_sl_object_mask" do
|
53
|
-
it "should return and empty string if run on an empty array" do
|
54
|
-
[].to_sl_object_mask.should eql("")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should call to_sl_object_mask passing the base to all its elements" do
|
58
|
-
proxy = "Hello"
|
59
|
-
proxy.should_receive(:to_sl_object_mask).with("")
|
60
|
-
[proxy].to_sl_object_mask
|
61
|
-
|
62
|
-
proxy = "Hello"
|
63
|
-
proxy.should_receive(:to_sl_object_mask).with("foo")
|
64
|
-
[proxy].to_sl_object_mask('foo')
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should flatten any arrays inside of itself" do
|
68
|
-
["foo", ["bar", "baz"]].to_sl_object_mask("buz").should eql(["buz.foo", "buz.bar", "buz.baz"])
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe Hash, "#to_sl_object_mask" do
|
73
|
-
it "should return an empty string if run on an empty hash" do
|
74
|
-
{}.to_sl_object_mask.should eql("")
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should call to_sl_object_mask on values with the key as the base" do
|
78
|
-
proxy = "value"
|
79
|
-
proxy.should_receive(:to_sl_object_mask).with("key").and_return("key.value")
|
80
|
-
mask_elements = {"key" => proxy}.to_sl_object_mask
|
81
|
-
mask_elements.should eql(["key.value"])
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should resolve the mapped values with the base provided" do
|
85
|
-
{"top" => [ "middle1", {"middle2" => "end"}]}.to_sl_object_mask.should eql(["top.middle1", "top.middle2.end"])
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should handle a complex hash object mask with an inner empty hash" do
|
89
|
-
{ "ipAddress" => { "ipAddress" => {}}}.to_sl_object_mask.should eql(["ipAddress.ipAddress"])
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|