softlayer_api 2.2.2 → 3.0.b1

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: 4936c19f8a711d7babe49535dca28e149bd7ad43
4
- data.tar.gz: 667178b6fc03102b85bb25275308720b50712af5
3
+ metadata.gz: 6f8d78ff1302ba4ee3970aa9b35ae5ad58de334a
4
+ data.tar.gz: 3a26cf514cefcf910e4edbadf810d63a1eea96fd
5
5
  SHA512:
6
- metadata.gz: 47cc499fad6bc36db67a9f1380f74119cfa9ade88f02025df3886c80d08c045c6ebf1a69944f4e63a3f6c981487b201ca8a08c217ef6273cc077805e1bb35d24
7
- data.tar.gz: 1636e72268665d211546f1e78ead56082950662d2abea19bb9de0920029da4133fd598f06984a13f842ad8d9ab3c6b3d6c44de428a70f3f8c1c182e170a0e590
6
+ metadata.gz: 8c15a6526a4447e70fcf63433c443236666bebd15dfd8f96d18ace34ae00259e55633b0c38b2938c00e066265793617b276eae6c369a36f3db1ab666e89c66d1
7
+ data.tar.gz: 75f70052f5946914de71194f7db38ee2d3b6f7ee189c2b33e1bd944d5215c6ce6890e8cb6a653a2a074ef5be76528eb5c82bfe75bd57e58841b48b4076154eed
data/CHANGELOG.textile CHANGED
@@ -1,13 +1,17 @@
1
- *2.2.2*
2
- * Fixed a bug in BareMetalServerOrder_Package.rb where the order template did not use an array for the "hardware" key. This lead to an order template that would be accepted by verifyOrder, but rejected by placeOrder. An internal issue to review verifyOrder has also been generated. (reported by Rohit Singh)
1
+ *3.0*
2
+ * Substantially rewrote the ObjectFilter class. ObjectFilters used to be hashes which made it easy to manipulate their content incorrectly. The new implementation has a strict interface that makes it harder to manipulate filters incorrectly.
3
+ * Added a model for Virtual Server Image Templates (SoftLayer::ImageTemplate) - VirtualServerOrder now requires an instance of this class rather than allowing you to provide just the global_id of an image
4
+ * Added a model for data centers (SoftLayer::Datacenter). Bare Metal, Bare Metal Package, and Virtual server orders now use an instance of Datacenter to identify where their servers will be provisioned. The routines in those classes which used to provide lists of valid data center names now return data center objects.
5
+ * Virtual Server Upgrades are now handled by the VirtualServerUpgradeOrder class and not the VirtualServer class. This change was made for several reasons. Firt and foremost, it allows multiple aspects of a virtual server to be upgraded at once without having to wait on separate transactions to complete between upgrades. Secondly it opens the door for additional upgrades (for example, to disk configuration) to be added in the future.
6
+ * Added a method to reboot servers.
7
+ * The routine to retreive the open tickets on an account has been moved from the Ticket class. The set of open tickets is now a dynamic property of an account object.
3
8
 
4
9
  *2.2*
5
- * Added the ability to set a timout for network requests. The timeout is given when a client is created by passing the :timeout hash parameter when creating a client. The value of the parameter is an integer number of seconds.
6
- * Fixed a bug in VirtualServer#capture_image
10
+ * Added the ability to set a timout for network requests. The timeout is given when a client is created by passing the :timeout hash parameter when creating a client. The value of the parameter is an integer number of seconds.
7
11
 
8
12
  *2.1.1*
9
13
  * Virtual server upgrades no longer raise exceptions
10
- * Formalized the RDoc documentation process. Added overview and welcome documentation and changed the README so it directs folks to the new documentation.
14
+ * Formalized the RDoc documentation process. Added overview and welcome documentation and changed the README so it directs folks to the new documentation.
11
15
 
12
16
  *2.1.0*
13
17
  * Began implementing a model framework that allows Ruby developers to work with elements in the SoftLayer API in a more object-oriented fashion. The first release of this framework includes the Ticket, VirtualServer, and BareMetalServer classes.
@@ -23,8 +23,8 @@
23
23
  require 'rubygems'
24
24
  require 'softlayer_api'
25
25
  require 'pp'
26
-
27
- # We can set the default client to be our client and that way
26
+
27
+ # We can set the default client to be our client and that way
28
28
  # we can avoid supplying it later
29
29
  SoftLayer::Client.default_client = SoftLayer::Client.new(
30
30
  # :username => "joecustomer" # enter your username here
@@ -35,7 +35,7 @@ begin
35
35
  account = SoftLayer::Account.account_for_client(softlayer_client)
36
36
  account_user = account.service.getCurrentUser
37
37
  my_user_id = account_user["id"]
38
-
38
+
39
39
  # We also need a subject for the ticket. Subjects are specified by id
40
40
  # This code prints out a table of all the ticket subjects with their
41
41
  # ids:
@@ -43,7 +43,7 @@ begin
43
43
  ticket_subjects.each do |subject|
44
44
  puts "#{subject['id']}\t#{subject['name']}"
45
45
  end
46
-
46
+
47
47
  # For this example we'll use 'Public Network Question' as the subject. That's id 1022
48
48
  public_network_question_id = 1022
49
49
 
@@ -58,7 +58,7 @@ begin
58
58
  )
59
59
 
60
60
  puts "Created a new ticket : #{new_ticket.id} - #{new_ticket.title}"
61
-
61
+
62
62
  # we can also add an update to the ticket:
63
63
  new_ticket.update("This is a ticket update sent from the Ruby library")
64
64
 
@@ -30,14 +30,14 @@ require 'pp'
30
30
  # $SL_API_KEY = "feeddeadbeefbadf00d..." # enter your api key here
31
31
 
32
32
  # The client constructed here must get it's credentials from somewhere
33
- # In this script you might uncomment the globals above and assign your
33
+ # In this script you might uncomment the globals above and assign your
34
34
  # credentials there
35
35
  SoftLayer::Client.default_client = SoftLayer::Client.new()
36
36
 
37
37
  # The openTickets routine will pick up the default client established above.
38
38
  open_tickets = SoftLayer::Ticket.open_tickets()
39
39
 
40
- open_tickets.sort!{ |lhs, rhs| -(lhs.lastEditDate <=> rhs.lastEditDate) }
40
+ open_tickets.sort!{ |lhs, rhs| -(lhs.lastEditDate <=> rhs.lastEditDate) }
41
41
  open_tickets.each do |ticket|
42
42
  printf "#{ticket.id} - #{ticket.title}"
43
43
 
@@ -34,13 +34,13 @@ begin
34
34
  # at information. In this case we are talking directly to the ticket
35
35
  # service
36
36
  ticket_service = softlayer_client.service_named("Ticket");
37
-
37
+
38
38
  # Retrive a particular ticket by ID (you will have to substitute an existing ticket's ID here)
39
39
  ticket_ref = ticket_service.object_with_id(12345)
40
40
 
41
41
  # Retrive very specific information about the ticket
42
42
  ticket = ticket_ref.object_mask("mask[updates[entry,createDate],assignedUserId,attachedHardware.datacenter]").getObject
43
-
43
+
44
44
  pp ticket
45
45
  rescue Exception => exception
46
46
  puts "Unable to retrieve the ticket #{exception}"
@@ -1,24 +1,10 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
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.
21
- #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
6
+
7
+
22
8
 
23
9
  module SoftLayer
24
10
  # An +APIParameterFilter+ is an intermediary object that understands how
@@ -119,7 +105,7 @@ class APIParameterFilter
119
105
  # to specify criteria which are used to filter the results returned
120
106
  # by the server.
121
107
  def object_filter(filter)
122
- raise ArgumentError, "Object mask expects mask properties" if filter.nil?
108
+ raise ArgumentError, "object_filter expects an instance of SoftLayer::ObjectFilter" if filter.nil? || !filter.kind_of?(SoftLayer::ObjectFilter)
123
109
 
124
110
  # we create a new object in case the user wants to store off the
125
111
  # filter chain and reuse it later
@@ -187,7 +173,7 @@ class APIParameterFilter
187
173
  ##
188
174
  # A utility method that returns the object filter (if any) stored with this filter.
189
175
  def server_object_filter
190
- self.parameters[:object_filter]
176
+ self.parameters[:object_filter].to_h
191
177
  end
192
178
 
193
179
  ##
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
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.
21
- #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
22
6
 
23
7
  module SoftLayer
24
8
  class Account < SoftLayer::ModelBase
@@ -113,6 +97,31 @@ module SoftLayer
113
97
  end
114
98
  end
115
99
 
100
+ sl_dynamic_attr :image_templates do |image_templates|
101
+ image_templates.should_update? do
102
+ @last_image_template_update ||= Time.at(0)
103
+ (Time.now - @last_image_template_update) > 5 * 60 # update every 5 minutes
104
+ end
105
+
106
+ image_templates.to_update do
107
+ @last_image_template_update ||= Time.now
108
+ ImageTemplate.find_private_templates(:client => self.softlayer_client)
109
+ end
110
+ end
111
+
112
+ sl_dynamic_attr :open_tickets do |open_tickets|
113
+ open_tickets.should_update? do
114
+ @last_open_tickets_update ||= Time.at(0)
115
+ (Time.now - @last_open_tickets_update) > 5 * 60 # update every 5 minutes
116
+ end
117
+
118
+ open_tickets.to_update do
119
+ @last_open_tickets_update ||= Time.now
120
+ open_tickets_data = self.service.object_mask(SoftLayer::Ticket.default_object_mask).getOpenTickets
121
+ open_tickets_data.collect { |ticket_data| SoftLayer::Ticket.new(self.softlayer_client, ticket_data) }
122
+ end
123
+ end
124
+
116
125
  def service
117
126
  softlayer_client["Account"].object_with_id(self.id)
118
127
  end
@@ -1,24 +1,10 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
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.
21
- #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
6
+
7
+
22
8
 
23
9
  module SoftLayer
24
10
  #
@@ -27,6 +13,7 @@ module SoftLayer
27
13
  # +SoftLayer_Hardware_Server+ services in the SoftLayer API
28
14
  #
29
15
  # http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware
16
+ #
30
17
  # http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware_Server
31
18
  #
32
19
  class BareMetalServer < Server
@@ -51,7 +38,7 @@ module SoftLayer
51
38
  # removed from the account).
52
39
  #
53
40
  # The +cancellation_reason+ parameter should be a key from the hash returned
54
- # by +BareMetalServer::cancellation_reasons+.
41
+ # by BareMetalServer::cancellation_reasons.
55
42
  #
56
43
  # You may add your own, more specific reasons for cancelling a server in the
57
44
  # +comments+ parameter.
@@ -178,8 +165,9 @@ module SoftLayer
178
165
 
179
166
  if(options_hash.has_key? :object_filter)
180
167
  object_filter = options_hash[:object_filter]
168
+ raise "Expected an instance of SoftLayer::ObjectFilter" unless object_filter.kind_of?(SoftLayer::ObjectFilter)
181
169
  else
182
- object_filter = {}
170
+ object_filter = ObjectFilter.new()
183
171
  end
184
172
 
185
173
  option_to_filter_path = {
@@ -197,18 +185,18 @@ module SoftLayer
197
185
  # that particular option, add a clause to the object filter that filters for the matching
198
186
  # value
199
187
  option_to_filter_path.each do |option, filter_path|
200
- object_filter.merge!(SoftLayer::ObjectFilter.build(filter_path, options_hash[option])) if options_hash.has_key?(option)
188
+ object_filter.modify { |filter| filter.accept(filter_path).when_it is(options_hash[option])} if options_hash[option]
201
189
  end
202
190
 
203
191
  # Tags get a much more complex object filter operation so we handle them separately
204
192
  if options_hash.has_key?(:tags)
205
- object_filter.merge!(SoftLayer::ObjectFilter.build("hardware.tagReferences.tag.name", {
193
+ object_filter.set_criteria_for_key_path("hardware.tagReferences.tag.name", {
206
194
  'operation' => 'in',
207
195
  'options' => [{
208
196
  'name' => 'data',
209
- 'value' => options_hash[:tags]
197
+ 'value' => options_hash[:tags].collect{ |tag_value| tag_value.to_s }
210
198
  }]
211
- } ));
199
+ } );
212
200
  end
213
201
 
214
202
  account_service = softlayer_client['Account']
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
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.
21
- #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
22
6
 
23
7
  module SoftLayer
24
8
  #
@@ -46,8 +30,7 @@ module SoftLayer
46
30
  # a Bare Metal Instance
47
31
  #++
48
32
 
49
- # String, short name of the data center that will house the new Bare Metal Instance (e.g. "dal05" or "sea01")
50
- # Corresponds to +datacenter.name+ in the documentation for +createObject+.
33
+ # An instance of SoftLayer::Datacenter. The server will be provisioned in this data center
51
34
  attr_accessor :datacenter
52
35
 
53
36
  # String, The hostname to assign to the new server
@@ -166,7 +149,7 @@ module SoftLayer
166
149
 
167
150
  template["privateNetworkOnlyFlag"] = true if @private_network_only
168
151
 
169
- template["datacenter"] = {"name" => @datacenter} if @datacenter
152
+ template["datacenter"] = {"name" => @datacenter.name} if @datacenter
170
153
  template['userData'] = [{'value' => @user_metadata}] if @user_metadata
171
154
  template['networkComponents'] = [{'maxSpeed'=> @max_port_speed}] if @max_port_speed
172
155
  template['postInstallScriptUri'] = @provision_script_URI.to_s if @provision_script_URI
@@ -198,7 +181,7 @@ module SoftLayer
198
181
  ##
199
182
  # Return a list of values that are valid for the :datacenter attribute
200
183
  def self.datacenter_options(client = nil)
201
- create_object_options(client)["datacenters"].collect { |datacenter_spec| datacenter_spec['template']['datacenter']["name"] }.uniq.sort!
184
+ create_object_options(client)["datacenters"].collect { |datacenter_spec| Datacenter.datacenter_named(datacenter_spec['template']['datacenter']['name'], client) }.uniq
202
185
  end
203
186
 
204
187
  def self.core_options(client = nil)
@@ -1,24 +1,8 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
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.
21
- #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
22
6
 
23
7
  module SoftLayer
24
8
  #
@@ -42,13 +26,14 @@ module SoftLayer
42
26
  class BareMetalServerOrder_Package < Server
43
27
  # The following properties are required in a server order.
44
28
 
45
- # The product package identifying the base configuration for the server.
46
- # a list of Bare Metal Server product packages is returned by
29
+ # The product package object (an instance of SoftLayer::ProductPackage) identifying the base
30
+ # configuration for the server. A list of Bare Metal Server product packages is returned by
47
31
  # SoftLayer::ProductPackage.bare_metal_server_packages
48
32
  attr_reader :package
49
33
 
50
- # String, short name of the data center that will house the new virtual server (e.g. "dal05" or "sea01")
51
- # A list of valid data centers can be found in ProductPackage#datacenter_options
34
+ # An instance of SoftLayer::Datacenter. The server will be provisioned in this data center.
35
+ # The set of datacenters available is determined by the package and may be obtained from
36
+ # the SoftLayer::ProductPackage object using the #datacenter_options method.
52
37
  attr_accessor :datacenter
53
38
 
54
39
  # The hostname of the server being created (i.e. 'sldn' is the hostname of sldn.softlayer.com).
@@ -133,14 +118,13 @@ module SoftLayer
133
118
  product_order = {
134
119
  'packageId' => @package.id,
135
120
  'useHourlyPricing' => false,
136
- 'hardware' => [{
121
+ 'hardware' => {
137
122
  'hostname' => @hostname,
138
123
  'domain' => @domain
139
- }]
124
+ }
140
125
  }
141
126
 
142
- product_order['location'] = @package.location_id_for_datacenter_name(@datacenter.downcase) if @datacenter
143
-
127
+ product_order['location'] = @datacenter.id if @datacenter
144
128
  product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids
145
129
  product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI
146
130
 
@@ -156,7 +140,5 @@ module SoftLayer
156
140
 
157
141
  product_order
158
142
  end
159
-
160
143
  end # BareMetalServerOrder_Package
161
-
162
144
  end # SoftLayer
@@ -1,31 +1,18 @@
1
- #
1
+ #--
2
2
  # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
3
  #
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.
21
- #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
22
6
 
23
7
  module SoftLayer
24
- # Initialize an instance of the Client class. You pass in the service name
25
- # and optionally hash arguments specifying how the client should access the
26
- # SoftLayer API.
8
+ # A client is responsible for storing authentication information for API calls and
9
+ # it serves as a centeral repository for the Service instances that call into the
10
+ # network API.
27
11
  #
28
- # The following symbols can be used as hash arguments to pass options to the constructor:
12
+ # When you create a client, you pass in hash arguments specifying how the client
13
+ # should access the SoftLayer API.
14
+ #
15
+ # The following symbols are the keys for options you pass to the constructor:
29
16
  # - +:username+ - a non-empty string providing the username to use for requests to the client
30
17
  # - +:api_key+ - a non-empty string providing the api key to use for requests to the client
31
18
  # - +:endpoint_url+ - a non-empty string providing the endpoint URL to use for requests to the client
@@ -56,6 +43,13 @@ module SoftLayer
56
43
  # will be used by many methods if you do not provide an explicit client.
57
44
  @@default_client = nil
58
45
 
46
+ ##
47
+ # :attr_accessor:
48
+ # The client class can maintain a single instance of Client as the "default client"
49
+ # Other parts of the library that accept a client as part of their calling sequence
50
+ # will look for the default client if one is not provided in the call
51
+ #
52
+ # This routine returns the client set as the default client. It can be nil
59
53
  def self.default_client
60
54
  return @@default_client
61
55
  end