Class: InfluxDB2::InvokableScriptsApi
- Inherits:
-
DefaultApi
- Object
- DefaultApi
- InfluxDB2::InvokableScriptsApi
- Defined in:
- lib/influxdb2/client/invokable_scripts_api.rb
Overview
Use API invokable scripts to create custom InfluxDB API endpoints that query, process, and shape data.
API invokable scripts let you assign scripts to API endpoints and then execute them as standard REST operations in InfluxDB Cloud.
Constant Summary
Constants inherited from DefaultApi
DefaultApi::DEFAULT_REDIRECT_COUNT, DefaultApi::DEFAULT_TIMEOUT, DefaultApi::HEADER_CONTENT_TYPE
Instance Method Summary collapse
-
#create_script(script_create_request) ⇒ Script
Create a script.
-
#delete_script(script_id) ⇒ Object
Delete a script.
-
#find_scripts(opts = {}) ⇒ Script
List scripts.
-
#initialize(options:) ⇒ InvokableScriptsApi
constructor
A new instance of InvokableScriptsApi.
-
#invoke_script(script_id, params: nil) ⇒ Array
Invoke synchronously a script and return result as a [FluxTable].
-
#invoke_script_raw(script_id, params: nil) ⇒ String
Invoke synchronously a script and return result as a [String].
-
#invoke_script_stream(script_id, params: nil) ⇒ Object
Invoke synchronously a script and return result as a stream of FluxRecord.
-
#update_script(script_id, update_request) ⇒ Script
Update a script.
Methods inherited from DefaultApi
Constructor Details
#initialize(options:) ⇒ InvokableScriptsApi
Returns a new instance of InvokableScriptsApi.
30 31 32 |
# File 'lib/influxdb2/client/invokable_scripts_api.rb', line 30 def initialize(options:) super(options: ) end |
Instance Method Details
#create_script(script_create_request) ⇒ Script
Create a script.
39 40 41 42 43 44 45 |
# File 'lib/influxdb2/client/invokable_scripts_api.rb', line 39 def create_script(script_create_request) uri = _parse_uri('/api/v2/scripts') response = _request_json(script_create_request.to_body.to_json, uri, headers: { 'Accept' => 'application/json' }) _to_object(response, Script) end |
#delete_script(script_id) ⇒ Object
Delete a script.
64 65 66 67 68 69 |
# File 'lib/influxdb2/client/invokable_scripts_api.rb', line 64 def delete_script(script_id) uri = _parse_uri_script(script_id) _request_json('', uri, headers: { 'Accept' => 'application/json' }, method: Net::HTTP::Delete) end |
#find_scripts(opts = {}) ⇒ Script
List scripts.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/influxdb2/client/invokable_scripts_api.rb', line 78 def find_scripts(opts = {}) limit = !opts[:limit].nil? ? opts[:limit] : [] offset = !opts[:offset].nil? ? opts[:offset] : [] uri = _parse_uri('/api/v2/scripts') uri.query = URI.encode_www_form(limit: limit, offset: offset) response = _request_json('', uri, headers: { 'Accept' => 'application/json' }, method: Net::HTTP::Get) _to_object(response, Scripts).scripts end |
#invoke_script(script_id, params: nil) ⇒ Array
Invoke synchronously a script and return result as a [FluxTable].
106 107 108 109 110 111 112 113 |
# File 'lib/influxdb2/client/invokable_scripts_api.rb', line 106 def invoke_script(script_id, params: nil) response = invoke_script_raw(script_id, params: params) parser = InfluxDB2::FluxCsvParser.new(response, stream: false, response_mode: InfluxDB2::FluxResponseMode::ONLY_NAMES) parser.parse parser.tables end |
#invoke_script_raw(script_id, params: nil) ⇒ String
Invoke synchronously a script and return result as a [String].
96 97 98 |
# File 'lib/influxdb2/client/invokable_scripts_api.rb', line 96 def invoke_script_raw(script_id, params: nil) _invoke_script(script_id, params: params).read_body end |
#invoke_script_stream(script_id, params: nil) ⇒ Object
Invoke synchronously a script and return result as a stream of FluxRecord.
121 122 123 124 125 |
# File 'lib/influxdb2/client/invokable_scripts_api.rb', line 121 def invoke_script_stream(script_id, params: nil) response = _invoke_script(script_id, params: params) InfluxDB2::FluxCsvParser.new(response, stream: true, response_mode: InfluxDB2::FluxResponseMode::ONLY_NAMES) end |
#update_script(script_id, update_request) ⇒ Script
Update a script.
53 54 55 56 57 58 59 |
# File 'lib/influxdb2/client/invokable_scripts_api.rb', line 53 def update_script(script_id, update_request) uri = _parse_uri_script(script_id) response = _request_json(update_request.to_body.to_json, uri, headers: { 'Accept' => 'application/json' }, method: Net::HTTP::Patch) _to_object(response, Script) end |