Class: KineticSdk::Bridgehub
- Inherits:
-
Object
- Object
- KineticSdk::Bridgehub
- Includes:
- Utils::KineticHttpUtils
- Defined in:
- lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb,
lib/kinetic_sdk/bridgehub/lib/bridge.rb,
lib/kinetic_sdk/bridgehub/lib/access_keys.rb
Overview
Bridgehub is a Ruby class that acts as a wrapper for the Kinetic BridgeHub REST API without having to make explicit HTTP requests.
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#add_access_key(slug, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add an Access Key for a Bridge.
-
#add_bridge(payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Bridge.
-
#delete_access_key(slug, id, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an Access Key for a Bridge.
-
#delete_bridge(slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Bridge.
-
#find_access_key(slug, id, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an Access Key for a Bridge.
-
#find_access_keys(slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Access Keys for a Bridge.
-
#find_bridge(slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Bridge.
-
#find_bridges(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Bridges.
-
#initialize(opts) ⇒ Bridgehub
constructor
Initalize the BridgeHub SDK with the web server URL and configuration user credentials, along with any custom option values.
-
#update_access_key(slug, id, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Bridge Access Key.
-
#update_bridge(slug, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Bridge.
Methods included from Utils::KineticHttpUtils
#default_headers, default_headers, #default_jwt_headers, default_jwt_headers, #delete, #encode, #gateway_retry_delay, #gateway_retry_limit, #get, #head, #header_accept_json, header_accept_json, #header_basic_auth, header_basic_auth, header_bearer_auth, #header_bearer_auth, #header_content_json, header_content_json, header_user_agent, #header_user_agent, #max_redirects, #mimetype, #patch, #post, #post_multipart, #put, #redirect_url, #stream_download_to_file
Constructor Details
#initialize(opts) ⇒ Bridgehub
Initalize the BridgeHub SDK with the web server URL and configuration user credentials, along with any custom option values.
Example: using a configuration file
KineticSdk::Bridgehub.new({
config_file: "/opt/config1.yaml"
})
Example: using a properties hash
KineticSdk::Bridgehub.new({
app_server_url: "http://localhost:8080/kinetic-bridgehub",
username: "admin",
password: "admin",
options: {
log_level: "debug",
ssl_verify_mode: "peer",
ssl_ca_file: "/usr/local/self_signing_ca.pem"
}
})
If the +config_file+ option is present, it will be loaded first, and any additional options will overwrite any values in the config file
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb', line 61 def initialize(opts) # initialize any variables = {} # process the configuration file if it was provided unless opts[:config_file].nil? .merge!(YAML::load_file opts[:config_file]) end # process the configuration hash if it was provided .merge!(opts) # process any individual options @options = .delete(:options) || {} # setup logging log_level = @options[:log_level] || @options["log_level"] log_output = @options[:log_output] || @options["log_output"] @logger = KineticSdk::Utils::KLogger.new(log_level, log_output) @username = [:username] @password = [:password] @server = [:app_server_url].chomp('/') @api_url = "#{@server}/app/manage-api/v1" @version = 1 end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
13 14 15 |
# File 'lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb', line 13 def api_url @api_url end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb', line 13 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb', line 13 def @options end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
13 14 15 |
# File 'lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb', line 13 def password @password end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
13 14 15 |
# File 'lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb', line 13 def server @server end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
13 14 15 |
# File 'lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb', line 13 def username @username end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
13 14 15 |
# File 'lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb', line 13 def version @version end |
Instance Method Details
#add_access_key(slug, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add an Access Key for a Bridge
13 14 15 16 |
# File 'lib/kinetic_sdk/bridgehub/lib/access_keys.rb', line 13 def add_access_key(slug, payload, headers=default_headers) @logger.info("Adding Access Key for Bridge \"#{slug}\"") post("#{@api_url}/bridges/#{slug}/access-keys", payload, headers) end |
#add_bridge(payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Bridge
15 16 17 18 |
# File 'lib/kinetic_sdk/bridgehub/lib/bridge.rb', line 15 def add_bridge(payload, headers=default_headers) @logger.info("Adding Bridge \"#{payload['name']}\" with slug \"#{payload['slug']}\"") post("#{@api_url}/bridges", payload, headers) end |
#delete_access_key(slug, id, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an Access Key for a Bridge
24 25 26 27 |
# File 'lib/kinetic_sdk/bridgehub/lib/access_keys.rb', line 24 def delete_access_key(slug, id, headers=default_headers) @logger.info("Deleting Access Key #{id} for Bridge \"#{slug}\"") delete("#{@api_url}/bridges/#{slug}/access-keys/#{id}", headers) end |
#delete_bridge(slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Bridge
25 26 27 28 |
# File 'lib/kinetic_sdk/bridgehub/lib/bridge.rb', line 25 def delete_bridge(slug, headers=default_headers) @logger.info("Deleting Bridge \"#{slug}\"") delete("#{@api_url}/bridges/#{slug}", headers) end |
#find_access_key(slug, id, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an Access Key for a Bridge
47 48 49 50 |
# File 'lib/kinetic_sdk/bridgehub/lib/access_keys.rb', line 47 def find_access_key(slug, id, params={}, headers=default_headers) @logger.info("Finding Access Key \"#{id}\" for Bridge \"#{slug}\"") get("#{@api_url}/bridges/#{slug}/access-keys/#{id}", params, headers) end |
#find_access_keys(slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Access Keys for a Bridge
35 36 37 38 |
# File 'lib/kinetic_sdk/bridgehub/lib/access_keys.rb', line 35 def find_access_keys(slug, params={}, headers=default_headers) @logger.info("Finding Access Keys for Bridge \"#{slug}\"") get("#{@api_url}/bridges/#{slug}/access-keys", params, headers) end |
#find_bridge(slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Bridge
46 47 48 49 |
# File 'lib/kinetic_sdk/bridgehub/lib/bridge.rb', line 46 def find_bridge(slug, params={}, headers=default_headers) @logger.info("Finding Bridge \"#{slug}\"") get("#{@api_url}/bridges/#{slug}", params, headers) end |
#find_bridges(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Bridges
35 36 37 38 |
# File 'lib/kinetic_sdk/bridgehub/lib/bridge.rb', line 35 def find_bridges(params={}, headers=default_headers) @logger.info("Finding Bridges") get("#{@api_url}/bridges", params, headers) end |
#update_access_key(slug, id, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Bridge Access Key
61 62 63 64 |
# File 'lib/kinetic_sdk/bridgehub/lib/access_keys.rb', line 61 def update_access_key(slug, id, payload, headers=default_headers) @logger.info("Updating Access Key \"#{id}\" for Bridge \"#{slug}\"") put("#{@api_url}/bridges/#{slug}/access-keys/#{id}", payload, headers) end |
#update_bridge(slug, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Bridge
63 64 65 66 |
# File 'lib/kinetic_sdk/bridgehub/lib/bridge.rb', line 63 def update_bridge(slug, payload, headers=default_headers) @logger.info("Updating Bridge \"#{slug}\"") put("#{@api_url}/bridges/#{slug}", payload, headers) end |