Skip to content

Add the concept of a "Default Client" to simplify calls that require a client as a starting point #22

@SLsthompson

Description

@SLsthompson

In Pull Request #19, cbreden suggested:

Since most people will be working with a single softlayer_client, it might be worth building out some class functions to give people some shortcuts when only one client has been instantiated with a single API user/key combo. For example, getting a specific virtual guest could then become:

--- def self.server_with_id(softlayer_client, server_id, options = {})
---   service = softlayer_client["Virtual_Guest"]
+++ def self.server_with_id(server_id, options = {})
+++   service = options.has_key?(:softlayer_client) ? softlayer_client["Virtual_Guest"] : SoftLayer::Client["Virtual_Guest"]

This probably has the highest amount of impact to the current code base, but there will be some major savings from not tracking a "softlayer_client" variable at all times. This is just one way I could see this being implemented too. Opens up the ability to use cleaner code like this later:

SoftLayer::VirtualServer.server_with_id(3556842)   # -> {gets new server instance with id 3556842}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions