Class: KineticSdk::Filehub
- Inherits:
-
Object
- Object
- KineticSdk::Filehub
- Includes:
- Utils::KineticHttpUtils
- Defined in:
- lib/kinetic_sdk/filehub/filehub-sdk.rb,
lib/kinetic_sdk/filehub/lib/filestores.rb,
lib/kinetic_sdk/filehub/lib/access_keys.rb
Overview
Filehub is a Ruby class that acts as a wrapper for the Kinetic FileHub 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 Filestore.
-
#add_filestore(payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Filestore.
-
#delete_access_key(slug, id, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an Access Key for a Filestore.
-
#delete_filestore(slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Filestore.
-
#find_access_key(slug, id, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an Access Key for a Filestore.
-
#find_access_keys(slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Access Keys for a Filestore.
-
#find_filestore(slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Filestore.
-
#find_filestores(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Filestore.
-
#initialize(opts = {}) ⇒ Filehub
constructor
Initalize the FileHub 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 Filestore Access Key.
-
#update_filestore(slug, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Filestore.
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 = {}) ⇒ Filehub
Initalize the FileHub SDK with the web server URL and configuration user credentials, along with any custom option values.
Example: using a configuration file
KineticSdk::Filehub.new({
config_file: "/opt/config1.yaml"
})
Example: using a properties hash
KineticSdk::Filehub.new({
app_server_url: "http://localhost:8080/kinetic-filehub",
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/filehub/filehub-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/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/filehub/filehub-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/filehub/filehub-sdk.rb', line 13 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/kinetic_sdk/filehub/filehub-sdk.rb', line 13 def @options end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
13 14 15 |
# File 'lib/kinetic_sdk/filehub/filehub-sdk.rb', line 13 def password @password end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
13 14 15 |
# File 'lib/kinetic_sdk/filehub/filehub-sdk.rb', line 13 def server @server end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
13 14 15 |
# File 'lib/kinetic_sdk/filehub/filehub-sdk.rb', line 13 def username @username end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
13 14 15 |
# File 'lib/kinetic_sdk/filehub/filehub-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 Filestore
13 14 15 16 |
# File 'lib/kinetic_sdk/filehub/lib/access_keys.rb', line 13 def add_access_key(slug, payload, headers=default_headers) @logger.info("Adding Access Key for Filestore \"#{slug}\"") post("#{@api_url}/filestores/#{slug}/access-keys", payload, headers) end |
#add_filestore(payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Filestore
14 15 16 17 |
# File 'lib/kinetic_sdk/filehub/lib/filestores.rb', line 14 def add_filestore(payload, headers=default_headers) @logger.info("Adding Filestore \"#{payload['name']}\" with slug \"#{payload['slug']}\"") post("#{@api_url}/filestores", payload, headers) end |
#delete_access_key(slug, id, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an Access Key for a Filestore
24 25 26 27 |
# File 'lib/kinetic_sdk/filehub/lib/access_keys.rb', line 24 def delete_access_key(slug, id, headers=default_headers) @logger.info("Deleting Access Key #{id} for Filestore \"#{slug}\"") delete("#{@api_url}/filestores/#{slug}/access-keys/#{id}", headers) end |
#delete_filestore(slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Filestore
24 25 26 27 |
# File 'lib/kinetic_sdk/filehub/lib/filestores.rb', line 24 def delete_filestore(slug, headers=default_headers) @logger.info("Deleting Filestore \"#{slug}\"") delete("#{@api_url}/filestores/#{slug}", headers) end |
#find_access_key(slug, id, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an Access Key for a Filestore
47 48 49 50 |
# File 'lib/kinetic_sdk/filehub/lib/access_keys.rb', line 47 def find_access_key(slug, id, params={}, headers=default_headers) @logger.info("Finding Access Key \"#{id}\" for Filestore \"#{slug}\"") get("#{@api_url}/filestores/#{slug}/access-keys/#{id}", params, headers) end |
#find_access_keys(slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Access Keys for a Filestore
35 36 37 38 |
# File 'lib/kinetic_sdk/filehub/lib/access_keys.rb', line 35 def find_access_keys(slug, params={}, headers=default_headers) @logger.info("Finding Access Keys for Filestore \"#{slug}\"") get("#{@api_url}/filestores/#{slug}/access-keys", params, headers) end |
#find_filestore(slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Filestore
45 46 47 48 |
# File 'lib/kinetic_sdk/filehub/lib/filestores.rb', line 45 def find_filestore(slug, params={}, headers=default_headers) @logger.info("Finding Filestore \"#{slug}\"") get("#{@api_url}/filestores/#{slug}", params, headers) end |
#find_filestores(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Filestore
34 35 36 37 |
# File 'lib/kinetic_sdk/filehub/lib/filestores.rb', line 34 def find_filestores(params={}, headers=default_headers) @logger.info("Find Filestores") get("#{@api_url}/filestores", params, headers) end |
#update_access_key(slug, id, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Filestore Access Key
61 62 63 64 |
# File 'lib/kinetic_sdk/filehub/lib/access_keys.rb', line 61 def update_access_key(slug, id, payload, headers=default_headers) @logger.info("Updating Access Key \"#{id}\" for Filestore \"#{slug}\"") put("#{@api_url}/filestores/#{slug}/access-keys/#{id}", payload, headers) end |
#update_filestore(slug, payload, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Filestore
61 62 63 64 |
# File 'lib/kinetic_sdk/filehub/lib/filestores.rb', line 61 def update_filestore(slug, payload, headers=default_headers) @logger.info("Updating Filestore \"#{slug}\"") put("#{@api_url}/filestores/#{slug}", payload, headers) end |