Class: RightScale::ApiClient
- Inherits:
-
BaseRetryClient
- Object
- BaseRetryClient
- RightScale::ApiClient
- Defined in:
- lib/right_agent/clients/api_client.rb
Overview
HTTP interface to RightApi for use when mapping actor-based requests to API requests
Constant Summary collapse
- API_VERSION =
RightApi API version for use in X-API-Version header
"1.5"
- MAX_AUDIT_SUMMARY_LENGTH =
Maximum length of an audit summary as enforced by RightApi
255
- DEFAULT_OPEN_TIMEOUT =
Default time to wait for HTTP connection to open
2
- DEFAULT_REQUEST_TIMEOUT =
Default time to wait for response from request, which is chosen to be 5 seconds greater than the response timeout inside the RightNet router
35
- API_MAP =
Map from actor-based request paths to RightApi HTTP verb and path; only requests whose type matches an entry in this hash will be routed to the RightApi; all others will be routed to RightNet
{ "/auditor/create_entry" => [:post, "/audit_entries"], "/auditor/update_entry" => [:post, "/audit_entries/:id/append"], "/booter/declare" => [:post, "/right_net/booter/declare"], "/booter/get_repositories" => [:get, "/right_net/booter/get_repositories"], "/booter/get_boot_bundle" => [:get, "/right_net/booter/get_boot_bundle"], "/booter/get_decommission_bundle" => [:get, "/right_net/booter/get_decommission_bundle"], "/booter/get_missing_attributes" => [:get, "/right_net/booter/get_missing_attributes"], "/booter/get_login_policy" => [:get, "/right_net/booter/get_login_policy"], "/forwarder/schedule_right_script" => [:post, "/right_net/scheduler/bundle_right_script"], "/forwarder/schedule_recipe" => [:post, "/right_net/scheduler/bundle_recipe"], "/forwarder/shutdown" => [:post, "/right_net/scheduler/shutdown"], "/key_server/retrieve_public_keys" => [:get, "/right_net/key_server/retrieve_public_keys"], "/router/ping" => [:get, "/health-check"], # Currently cannot use RightApi for query_tags because it does not support server # tag scoping by account or deployment like the router does #"/router/query_tags" => [:post, "/tags/by_tag"], "/router/add_tags" => [:post, "/tags/multi_add"], "/router/delete_tags" => [:post, "/tags/multi_delete"], "/state_recorder/record" => [:put, "/right_net/state_recorder/record"], "/storage_valet/get_planned_volumes" => [:get, "/right_net/storage_valet/get_planned_volumes"], "/storage_valet/attach_volume" => [:post, "/right_net/storage_valet/attach_volume"], "/storage_valet/detach_volume" => [:post, "/right_net/storage_valet/detach_volume"], "/updater/update_inputs" => [:post, "/right_net/scheduler/update_inputs"], "/vault/read_documents" => [:get, "/right_net/vault/read_documents"] }
- AUDIT_FILTER_PARAMS =
Symbols for audit request parameters whose values are to be hidden when logging
["detail", "text"]
Constants inherited from BaseRetryClient
BaseRetryClient::DEFAULT_RECONNECT_INTERVAL, BaseRetryClient::DEFAULT_RETRY_INTERVALS, BaseRetryClient::DEFAULT_RETRY_TIMEOUT, BaseRetryClient::PERMITTED_STATE_TRANSITIONS
Instance Attribute Summary collapse
-
#self_href ⇒ Object
readonly
Resource href for this agent.
Attributes inherited from BaseRetryClient
Instance Method Summary collapse
-
#initialize(auth_client, options) ⇒ ApiClient
constructor
Create RightApi client of specified type.
-
#push(type, payload, target, options = {}) ⇒ NilClass
Route a request to a single target or multiple targets with no response expected Persist the request en route to reduce the chance of it being lost at the expense of some additional network overhead Enqueue the request if the target is not currently available Never automatically retry the request if there is the possibility of it being duplicated Set time-to-live to be forever.
-
#request(type, payload, target, options = {}) ⇒ Result, NilClass
Route a request to a single target with a response expected Automatically retry the request if a response is not received in a reasonable amount of time or if there is a non-delivery response indicating the target is not currently available Timeout the request if a response is not received in time, typically configured to 30 sec Because of retries there is the possibility of duplicated requests, and these are detected and discarded automatically for non-idempotent actions Allow the request to expire per the agent’s configured time-to-live, typically 1 minute.
-
#support?(type) ⇒ Array
Determine whether request supported by this client.
Methods inherited from BaseRetryClient
#close, #communicated, #init, #stats, #status
Constructor Details
#initialize(auth_client, options) ⇒ ApiClient
Create RightApi client of specified type
88 89 90 |
# File 'lib/right_agent/clients/api_client.rb', line 88 def initialize(auth_client, ) init(:api, auth_client, .merge(:server_name => "RightApi", :api_version => API_VERSION)) end |
Instance Attribute Details
#self_href ⇒ Object (readonly)
Resource href for this agent
74 75 76 |
# File 'lib/right_agent/clients/api_client.rb', line 74 def self_href @self_href end |
Instance Method Details
#push(type, payload, target, options = {}) ⇒ NilClass
Route a request to a single target or multiple targets with no response expected Persist the request en route to reduce the chance of it being lost at the expense of some additional network overhead Enqueue the request if the target is not currently available Never automatically retry the request if there is the possibility of it being duplicated Set time-to-live to be forever
126 127 128 |
# File 'lib/right_agent/clients/api_client.rb', line 126 def push(type, payload, target, = {}) map_request(type, payload, ) end |
#request(type, payload, target, options = {}) ⇒ Result, NilClass
Route a request to a single target with a response expected Automatically retry the request if a response is not received in a reasonable amount of time or if there is a non-delivery response indicating the target is not currently available Timeout the request if a response is not received in time, typically configured to 30 sec Because of retries there is the possibility of duplicated requests, and these are detected and discarded automatically for non-idempotent actions Allow the request to expire per the agent’s configured time-to-live, typically 1 minute
161 162 163 |
# File 'lib/right_agent/clients/api_client.rb', line 161 def request(type, payload, target, = {}) map_request(type, payload, ) end |