Class: ALGOSEC_SDK::Client
- Inherits:
-
Object
- Object
- ALGOSEC_SDK::Client
- Includes:
- BusinessFlowHelper, Rest
- Defined in:
- lib/algosec-sdk/client.rb
Overview
The client defines the connection to the AlgoSec and handles communication with it
Constant Summary
Constants included from Rest
Rest::RESPONSE_CODE_ACCEPTED, Rest::RESPONSE_CODE_BAD_REQUEST, Rest::RESPONSE_CODE_CREATED, Rest::RESPONSE_CODE_NOT_FOUND, Rest::RESPONSE_CODE_NO_CONTENT, Rest::RESPONSE_CODE_OK, Rest::RESPONSE_CODE_UNAUTHORIZED
Instance Attribute Summary collapse
-
#disable_proxy ⇒ Object
Returns the value of attribute disable_proxy.
-
#host ⇒ Object
Returns the value of attribute host.
-
#http_client ⇒ Object
Returns the value of attribute http_client.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#password ⇒ Object
Returns the value of attribute password.
-
#ssl_enabled ⇒ Object
Returns the value of attribute ssl_enabled.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
Create a client object.
Methods included from BusinessFlowHelper
#apply_application_draft, #create_application, #create_application_flow, #create_missing_network_objects, #create_missing_services, #create_network_object, #create_network_service, #decommission_application, #define_application_flows, #delete_flow_by_id, #get_app_id_by_name, #get_app_revision_id_by_name, #get_application_by_name, #get_application_flow_by_name, #get_application_flows, #get_application_flows_hash, #get_applications, #get_flow_connectivity, #implement_app_flows_plan, #login, #plan_application_flows, #search_network_object
Methods included from Rest
#init_http_client, #response_handler, #rest_api, #rest_delete, #rest_get, #rest_patch, #rest_post, #rest_put
Constructor Details
#initialize(options = {}) ⇒ Client
Create a client object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/algosec-sdk/client.rb', line 24 def initialize( = {}) = Hash[.map { |k, v| [k.to_sym, v] }] # Convert string hash keys to symbols @logger = [:logger] || Logger.new(STDOUT) %i[debug info warn error level=].each do |m| raise "Logger must respond to #{m} method " unless @logger.respond_to?(m) end @log_level = [:log_level] || :info @logger.level = begin @logger.class.const_get(@log_level.upcase) rescue StandardError @log_level end @host = [:host] || ENV['ALGOSEC_HOST'] raise InvalidClient, 'Must set the host option' unless @host @host = 'https://' + @host unless @host.start_with?('http://', 'https://') @ssl_enabled = true # Default if ENV.key?('ALGOSEC_SSL_ENABLED') @ssl_enabled = case ENV['ALGOSEC_SSL_ENABLED'] when 'true', '1' then true when 'false', '0' then false else ENV['ALGOSEC_SSL_ENABLED'] end end @ssl_enabled = [:ssl_enabled] unless [:ssl_enabled].nil? unless [true, false].include?(@ssl_enabled) raise InvalidClient, "ssl_enabled option must be true or false. Got '#{@ssl_enabled}'" end unless @ssl_enabled @logger.warn "SSL is disabled for all requests to #{@host}!"\ ' We recommend you import the necessary certificates instead of disabling SSL.' end @disable_proxy = [:disable_proxy] unless [true, false, nil].include?(@disable_proxy) raise InvalidClient, 'disable_proxy option must be true, false, or nil' end @logger.warn 'User option not set. Using default (admin)' unless [:user] || ENV['ALGOSEC_USER'] @user = [:user] || ENV['ALGOSEC_USER'] || 'admin' @password = [:password] || ENV['ALGOSEC_PASSWORD'] raise InvalidClient, 'Must set the password option' unless @password init_http_client end |
Instance Attribute Details
#disable_proxy ⇒ Object
Returns the value of attribute disable_proxy.
11 12 13 |
# File 'lib/algosec-sdk/client.rb', line 11 def disable_proxy @disable_proxy end |
#host ⇒ Object
Returns the value of attribute host.
11 12 13 |
# File 'lib/algosec-sdk/client.rb', line 11 def host @host end |
#http_client ⇒ Object
Returns the value of attribute http_client.
11 12 13 |
# File 'lib/algosec-sdk/client.rb', line 11 def http_client @http_client end |
#log_level ⇒ Object
Returns the value of attribute log_level.
11 12 13 |
# File 'lib/algosec-sdk/client.rb', line 11 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/algosec-sdk/client.rb', line 11 def logger @logger end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/algosec-sdk/client.rb', line 11 def password @password end |
#ssl_enabled ⇒ Object
Returns the value of attribute ssl_enabled.
11 12 13 |
# File 'lib/algosec-sdk/client.rb', line 11 def ssl_enabled @ssl_enabled end |
#user ⇒ Object
Returns the value of attribute user.
11 12 13 |
# File 'lib/algosec-sdk/client.rb', line 11 def user @user end |