1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922
|
# coding: utf-8
"""
InfluxDB OSS API Service.
The InfluxDB v2 API provides a programmatic interface for all interactions with InfluxDB. Access the InfluxDB API using the `/api/v2/` endpoint. # noqa: E501
OpenAPI spec version: 2.0.0
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import re # noqa: F401
from influxdb_client.service._base_service import _BaseService
class InvokableScriptsService(_BaseService):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
def __init__(self, api_client=None): # noqa: E501,D401,D403
"""InvokableScriptsService - a operation defined in OpenAPI."""
super().__init__(api_client)
def delete_scripts_id(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Delete a script.
Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records. #### Limitations - You can delete only one script per request. - If the script ID you provide doesn't exist for the organization, InfluxDB responds with an HTTP `204` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.delete_scripts_id(script_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. Deletes the specified script. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.delete_scripts_id_with_http_info(script_id, **kwargs) # noqa: E501
else:
(data) = self.delete_scripts_id_with_http_info(script_id, **kwargs) # noqa: E501
return data
def delete_scripts_id_with_http_info(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Delete a script.
Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records. #### Limitations - You can delete only one script per request. - If the script ID you provide doesn't exist for the organization, InfluxDB responds with an HTTP `204` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.delete_scripts_id_with_http_info(script_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. Deletes the specified script. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not self._is_cloud_instance():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._delete_scripts_id_prepare(script_id, **kwargs) # noqa: E501
return self.api_client.call_api(
'/api/v2/scripts/{scriptID}', 'DELETE',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type=None, # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
async def delete_scripts_id_async(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Delete a script.
Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records. #### Limitations - You can delete only one script per request. - If the script ID you provide doesn't exist for the organization, InfluxDB responds with an HTTP `204` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes an asynchronous HTTP request.
:param async_req bool
:param str script_id: A script ID. Deletes the specified script. (required)
:return: None
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not await self._is_cloud_instance_async():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._delete_scripts_id_prepare(script_id, **kwargs) # noqa: E501
return await self.api_client.call_api(
'/api/v2/scripts/{scriptID}', 'DELETE',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type=None, # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
def _delete_scripts_id_prepare(self, script_id, **kwargs): # noqa: E501,D401,D403
local_var_params = locals()
all_params = ['script_id'] # noqa: E501
self._check_operation_params('delete_scripts_id', all_params, local_var_params)
# verify the required parameter 'script_id' is set
if ('script_id' not in local_var_params or
local_var_params['script_id'] is None):
raise ValueError("Missing the required parameter `script_id` when calling `delete_scripts_id`") # noqa: E501
path_params = {}
if 'script_id' in local_var_params:
path_params['scriptID'] = local_var_params['script_id'] # noqa: E501
query_params = []
header_params = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
return local_var_params, path_params, query_params, header_params, body_params
def get_scripts(self, **kwargs): # noqa: E501,D401,D403
"""List scripts.
Lists [scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_scripts(async_req=True)
>>> result = thread.get()
:param async_req bool
:param int offset: The offset for pagination. The number of records to skip. For more information about pagination parameters, see [Pagination]({{% INFLUXDB_DOCS_URL %}}/api/#tag/Pagination).
:param int limit: The maximum number of scripts to return. Default is `100`.
:param str name: The script name. Lists scripts with the specified name.
:return: Scripts
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.get_scripts_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.get_scripts_with_http_info(**kwargs) # noqa: E501
return data
def get_scripts_with_http_info(self, **kwargs): # noqa: E501,D401,D403
"""List scripts.
Lists [scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_scripts_with_http_info(async_req=True)
>>> result = thread.get()
:param async_req bool
:param int offset: The offset for pagination. The number of records to skip. For more information about pagination parameters, see [Pagination]({{% INFLUXDB_DOCS_URL %}}/api/#tag/Pagination).
:param int limit: The maximum number of scripts to return. Default is `100`.
:param str name: The script name. Lists scripts with the specified name.
:return: Scripts
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not self._is_cloud_instance():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._get_scripts_prepare(**kwargs) # noqa: E501
return self.api_client.call_api(
'/api/v2/scripts', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Scripts', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
async def get_scripts_async(self, **kwargs): # noqa: E501,D401,D403
"""List scripts.
Lists [scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes an asynchronous HTTP request.
:param async_req bool
:param int offset: The offset for pagination. The number of records to skip. For more information about pagination parameters, see [Pagination]({{% INFLUXDB_DOCS_URL %}}/api/#tag/Pagination).
:param int limit: The maximum number of scripts to return. Default is `100`.
:param str name: The script name. Lists scripts with the specified name.
:return: Scripts
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not await self._is_cloud_instance_async():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._get_scripts_prepare(**kwargs) # noqa: E501
return await self.api_client.call_api(
'/api/v2/scripts', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Scripts', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
def _get_scripts_prepare(self, **kwargs): # noqa: E501,D401,D403
local_var_params = locals()
all_params = ['offset', 'limit', 'name'] # noqa: E501
self._check_operation_params('get_scripts', all_params, local_var_params)
if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501
raise ValueError("Invalid value for parameter `offset` when calling `get_scripts`, must be a value greater than or equal to `0`") # noqa: E501
if 'limit' in local_var_params and local_var_params['limit'] > 500: # noqa: E501
raise ValueError("Invalid value for parameter `limit` when calling `get_scripts`, must be a value less than or equal to `500`") # noqa: E501
if 'limit' in local_var_params and local_var_params['limit'] < 0: # noqa: E501
raise ValueError("Invalid value for parameter `limit` when calling `get_scripts`, must be a value greater than or equal to `0`") # noqa: E501
path_params = {}
query_params = []
if 'offset' in local_var_params:
query_params.append(('offset', local_var_params['offset'])) # noqa: E501
if 'limit' in local_var_params:
query_params.append(('limit', local_var_params['limit'])) # noqa: E501
if 'name' in local_var_params:
query_params.append(('name', local_var_params['name'])) # noqa: E501
header_params = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
return local_var_params, path_params, query_params, header_params, body_params
def get_scripts_id(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Retrieve a script.
Retrieves a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_scripts_id(script_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. Retrieves the specified script. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.get_scripts_id_with_http_info(script_id, **kwargs) # noqa: E501
else:
(data) = self.get_scripts_id_with_http_info(script_id, **kwargs) # noqa: E501
return data
def get_scripts_id_with_http_info(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Retrieve a script.
Retrieves a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_scripts_id_with_http_info(script_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. Retrieves the specified script. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not self._is_cloud_instance():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._get_scripts_id_prepare(script_id, **kwargs) # noqa: E501
return self.api_client.call_api(
'/api/v2/scripts/{scriptID}', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Script', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
async def get_scripts_id_async(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Retrieve a script.
Retrieves a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes an asynchronous HTTP request.
:param async_req bool
:param str script_id: A script ID. Retrieves the specified script. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not await self._is_cloud_instance_async():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._get_scripts_id_prepare(script_id, **kwargs) # noqa: E501
return await self.api_client.call_api(
'/api/v2/scripts/{scriptID}', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Script', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
def _get_scripts_id_prepare(self, script_id, **kwargs): # noqa: E501,D401,D403
local_var_params = locals()
all_params = ['script_id'] # noqa: E501
self._check_operation_params('get_scripts_id', all_params, local_var_params)
# verify the required parameter 'script_id' is set
if ('script_id' not in local_var_params or
local_var_params['script_id'] is None):
raise ValueError("Missing the required parameter `script_id` when calling `get_scripts_id`") # noqa: E501
path_params = {}
if 'script_id' in local_var_params:
path_params['scriptID'] = local_var_params['script_id'] # noqa: E501
query_params = []
header_params = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
return local_var_params, path_params, query_params, header_params, body_params
def get_scripts_id_params(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Find script parameters..
Analyzes a script and determines required parameters. Find all `params` keys referenced in a script and return a list of keys. If it is possible to determine the type of the value from the context then the type is also returned -- for example: The following sample script contains a _`mybucket`_ parameter : ```json "script": "from(bucket: params.mybucket) |> range(start: -7d) |> limit(n:1)" ``` Requesting the parameters using `GET /api/v2/scripts/SCRIPT_ID/params` returns the following: ```json { "params": { "mybucket": "string" } } ``` The type name returned for a parameter will be one of: - `any` - `bool` - `duration` - `float` - `int` - `string` - `time` - `uint` The type name `any` is used when the type of a parameter cannot be determined from the context, or the type is determined to be a structured type such as an array or record. #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_scripts_id_params(script_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. The script to analyze for params. (required)
:return: Params
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.get_scripts_id_params_with_http_info(script_id, **kwargs) # noqa: E501
else:
(data) = self.get_scripts_id_params_with_http_info(script_id, **kwargs) # noqa: E501
return data
def get_scripts_id_params_with_http_info(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Find script parameters..
Analyzes a script and determines required parameters. Find all `params` keys referenced in a script and return a list of keys. If it is possible to determine the type of the value from the context then the type is also returned -- for example: The following sample script contains a _`mybucket`_ parameter : ```json "script": "from(bucket: params.mybucket) |> range(start: -7d) |> limit(n:1)" ``` Requesting the parameters using `GET /api/v2/scripts/SCRIPT_ID/params` returns the following: ```json { "params": { "mybucket": "string" } } ``` The type name returned for a parameter will be one of: - `any` - `bool` - `duration` - `float` - `int` - `string` - `time` - `uint` The type name `any` is used when the type of a parameter cannot be determined from the context, or the type is determined to be a structured type such as an array or record. #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_scripts_id_params_with_http_info(script_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. The script to analyze for params. (required)
:return: Params
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not self._is_cloud_instance():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._get_scripts_id_params_prepare(script_id, **kwargs) # noqa: E501
return self.api_client.call_api(
'/api/v2/scripts/{scriptID}/params', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Params', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
async def get_scripts_id_params_async(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Find script parameters..
Analyzes a script and determines required parameters. Find all `params` keys referenced in a script and return a list of keys. If it is possible to determine the type of the value from the context then the type is also returned -- for example: The following sample script contains a _`mybucket`_ parameter : ```json "script": "from(bucket: params.mybucket) |> range(start: -7d) |> limit(n:1)" ``` Requesting the parameters using `GET /api/v2/scripts/SCRIPT_ID/params` returns the following: ```json { "params": { "mybucket": "string" } } ``` The type name returned for a parameter will be one of: - `any` - `bool` - `duration` - `float` - `int` - `string` - `time` - `uint` The type name `any` is used when the type of a parameter cannot be determined from the context, or the type is determined to be a structured type such as an array or record. #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes an asynchronous HTTP request.
:param async_req bool
:param str script_id: A script ID. The script to analyze for params. (required)
:return: Params
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not await self._is_cloud_instance_async():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._get_scripts_id_params_prepare(script_id, **kwargs) # noqa: E501
return await self.api_client.call_api(
'/api/v2/scripts/{scriptID}/params', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Params', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
def _get_scripts_id_params_prepare(self, script_id, **kwargs): # noqa: E501,D401,D403
local_var_params = locals()
all_params = ['script_id'] # noqa: E501
self._check_operation_params('get_scripts_id_params', all_params, local_var_params)
# verify the required parameter 'script_id' is set
if ('script_id' not in local_var_params or
local_var_params['script_id'] is None):
raise ValueError("Missing the required parameter `script_id` when calling `get_scripts_id_params`") # noqa: E501
path_params = {}
if 'script_id' in local_var_params:
path_params['scriptID'] = local_var_params['script_id'] # noqa: E501
query_params = []
header_params = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
return local_var_params, path_params, query_params, header_params, body_params
def patch_scripts_id(self, script_id, script_update_request, **kwargs): # noqa: E501,D401,D403
"""Update a script.
Updates an invokable script. Use this endpoint to modify values for script properties (`description` and `script`). To update a script, pass an object that contains the updated key-value pairs. #### Limitations - If you send an empty request body, the script will neither update nor store an empty script, but InfluxDB will respond with an HTTP `200` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.patch_scripts_id(script_id, script_update_request, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. Updates the specified script. (required)
:param ScriptUpdateRequest script_update_request: An object that contains the updated script properties to apply. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.patch_scripts_id_with_http_info(script_id, script_update_request, **kwargs) # noqa: E501
else:
(data) = self.patch_scripts_id_with_http_info(script_id, script_update_request, **kwargs) # noqa: E501
return data
def patch_scripts_id_with_http_info(self, script_id, script_update_request, **kwargs): # noqa: E501,D401,D403
"""Update a script.
Updates an invokable script. Use this endpoint to modify values for script properties (`description` and `script`). To update a script, pass an object that contains the updated key-value pairs. #### Limitations - If you send an empty request body, the script will neither update nor store an empty script, but InfluxDB will respond with an HTTP `200` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.patch_scripts_id_with_http_info(script_id, script_update_request, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. Updates the specified script. (required)
:param ScriptUpdateRequest script_update_request: An object that contains the updated script properties to apply. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not self._is_cloud_instance():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._patch_scripts_id_prepare(script_id, script_update_request, **kwargs) # noqa: E501
return self.api_client.call_api(
'/api/v2/scripts/{scriptID}', 'PATCH',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Script', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
async def patch_scripts_id_async(self, script_id, script_update_request, **kwargs): # noqa: E501,D401,D403
"""Update a script.
Updates an invokable script. Use this endpoint to modify values for script properties (`description` and `script`). To update a script, pass an object that contains the updated key-value pairs. #### Limitations - If you send an empty request body, the script will neither update nor store an empty script, but InfluxDB will respond with an HTTP `200` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes an asynchronous HTTP request.
:param async_req bool
:param str script_id: A script ID. Updates the specified script. (required)
:param ScriptUpdateRequest script_update_request: An object that contains the updated script properties to apply. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not await self._is_cloud_instance_async():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._patch_scripts_id_prepare(script_id, script_update_request, **kwargs) # noqa: E501
return await self.api_client.call_api(
'/api/v2/scripts/{scriptID}', 'PATCH',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Script', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
def _patch_scripts_id_prepare(self, script_id, script_update_request, **kwargs): # noqa: E501,D401,D403
local_var_params = locals()
all_params = ['script_id', 'script_update_request'] # noqa: E501
self._check_operation_params('patch_scripts_id', all_params, local_var_params)
# verify the required parameter 'script_id' is set
if ('script_id' not in local_var_params or
local_var_params['script_id'] is None):
raise ValueError("Missing the required parameter `script_id` when calling `patch_scripts_id`") # noqa: E501
# verify the required parameter 'script_update_request' is set
if ('script_update_request' not in local_var_params or
local_var_params['script_update_request'] is None):
raise ValueError("Missing the required parameter `script_update_request` when calling `patch_scripts_id`") # noqa: E501
path_params = {}
if 'script_id' in local_var_params:
path_params['scriptID'] = local_var_params['script_id'] # noqa: E501
query_params = []
header_params = {}
body_params = None
if 'script_update_request' in local_var_params:
body_params = local_var_params['script_update_request']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
return local_var_params, path_params, query_params, header_params, body_params
def post_scripts(self, script_create_request, **kwargs): # noqa: E501,D401,D403
"""Create a script.
Creates an [invokable script](https://docs.influxdata.com/resources/videos/api-invokable-scripts/) and returns the script. #### Related guides - [Invokable scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) - [Creating custom InfluxDB endpoints](https://docs.influxdata.com/resources/videos/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.post_scripts(script_create_request, async_req=True)
>>> result = thread.get()
:param async_req bool
:param ScriptCreateRequest script_create_request: The script to create. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.post_scripts_with_http_info(script_create_request, **kwargs) # noqa: E501
else:
(data) = self.post_scripts_with_http_info(script_create_request, **kwargs) # noqa: E501
return data
def post_scripts_with_http_info(self, script_create_request, **kwargs): # noqa: E501,D401,D403
"""Create a script.
Creates an [invokable script](https://docs.influxdata.com/resources/videos/api-invokable-scripts/) and returns the script. #### Related guides - [Invokable scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) - [Creating custom InfluxDB endpoints](https://docs.influxdata.com/resources/videos/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.post_scripts_with_http_info(script_create_request, async_req=True)
>>> result = thread.get()
:param async_req bool
:param ScriptCreateRequest script_create_request: The script to create. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not self._is_cloud_instance():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._post_scripts_prepare(script_create_request, **kwargs) # noqa: E501
return self.api_client.call_api(
'/api/v2/scripts', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Script', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
async def post_scripts_async(self, script_create_request, **kwargs): # noqa: E501,D401,D403
"""Create a script.
Creates an [invokable script](https://docs.influxdata.com/resources/videos/api-invokable-scripts/) and returns the script. #### Related guides - [Invokable scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) - [Creating custom InfluxDB endpoints](https://docs.influxdata.com/resources/videos/api-invokable-scripts/)
This method makes an asynchronous HTTP request.
:param async_req bool
:param ScriptCreateRequest script_create_request: The script to create. (required)
:return: Script
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not await self._is_cloud_instance_async():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._post_scripts_prepare(script_create_request, **kwargs) # noqa: E501
return await self.api_client.call_api(
'/api/v2/scripts', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='Script', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
def _post_scripts_prepare(self, script_create_request, **kwargs): # noqa: E501,D401,D403
local_var_params = locals()
all_params = ['script_create_request'] # noqa: E501
self._check_operation_params('post_scripts', all_params, local_var_params)
# verify the required parameter 'script_create_request' is set
if ('script_create_request' not in local_var_params or
local_var_params['script_create_request'] is None):
raise ValueError("Missing the required parameter `script_create_request` when calling `post_scripts`") # noqa: E501
path_params = {}
query_params = []
header_params = {}
body_params = None
if 'script_create_request' in local_var_params:
body_params = local_var_params['script_create_request']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
return local_var_params, path_params, query_params, header_params, body_params
def post_scripts_id_invoke(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Invoke a script.
Runs a script and returns the result. When the script runs, InfluxDB replaces `params` keys referenced in the script with `params` key-values passed in the request body--for example: The following sample script contains a _`mybucket`_ parameter : ```json "script": "from(bucket: params.mybucket) |> range(start: -7d) |> limit(n:1)" ``` The following example `POST /api/v2/scripts/SCRIPT_ID/invoke` request body passes a value for the _`mybucket`_ parameter: ```json { "params": { "mybucket": "air_sensor" } } ``` #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.post_scripts_id_invoke(script_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. Runs the specified script. (required)
:param ScriptInvocationParams script_invocation_params:
:return: file
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.post_scripts_id_invoke_with_http_info(script_id, **kwargs) # noqa: E501
else:
(data) = self.post_scripts_id_invoke_with_http_info(script_id, **kwargs) # noqa: E501
return data
def post_scripts_id_invoke_with_http_info(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Invoke a script.
Runs a script and returns the result. When the script runs, InfluxDB replaces `params` keys referenced in the script with `params` key-values passed in the request body--for example: The following sample script contains a _`mybucket`_ parameter : ```json "script": "from(bucket: params.mybucket) |> range(start: -7d) |> limit(n:1)" ``` The following example `POST /api/v2/scripts/SCRIPT_ID/invoke` request body passes a value for the _`mybucket`_ parameter: ```json { "params": { "mybucket": "air_sensor" } } ``` #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.post_scripts_id_invoke_with_http_info(script_id, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str script_id: A script ID. Runs the specified script. (required)
:param ScriptInvocationParams script_invocation_params:
:return: file
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not self._is_cloud_instance():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._post_scripts_id_invoke_prepare(script_id, **kwargs) # noqa: E501
return self.api_client.call_api(
'/api/v2/scripts/{scriptID}/invoke', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='file', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
async def post_scripts_id_invoke_async(self, script_id, **kwargs): # noqa: E501,D401,D403
"""Invoke a script.
Runs a script and returns the result. When the script runs, InfluxDB replaces `params` keys referenced in the script with `params` key-values passed in the request body--for example: The following sample script contains a _`mybucket`_ parameter : ```json "script": "from(bucket: params.mybucket) |> range(start: -7d) |> limit(n:1)" ``` The following example `POST /api/v2/scripts/SCRIPT_ID/invoke` request body passes a value for the _`mybucket`_ parameter: ```json { "params": { "mybucket": "air_sensor" } } ``` #### Related guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/)
This method makes an asynchronous HTTP request.
:param async_req bool
:param str script_id: A script ID. Runs the specified script. (required)
:param ScriptInvocationParams script_invocation_params:
:return: file
If the method is called asynchronously,
returns the request thread.
""" # noqa: E501
if not await self._is_cloud_instance_async():
from influxdb_client.client.warnings import CloudOnlyWarning
CloudOnlyWarning.print_warning('InvokableScriptsService',
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/') # noqa: E501
local_var_params, path_params, query_params, header_params, body_params = \
self._post_scripts_id_invoke_prepare(script_id, **kwargs) # noqa: E501
return await self.api_client.call_api(
'/api/v2/scripts/{scriptID}/invoke', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=[],
files={},
response_type='file', # noqa: E501
auth_settings=[],
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats={},
urlopen_kw=kwargs.get('urlopen_kw', None))
def _post_scripts_id_invoke_prepare(self, script_id, **kwargs): # noqa: E501,D401,D403
local_var_params = locals()
all_params = ['script_id', 'script_invocation_params'] # noqa: E501
self._check_operation_params('post_scripts_id_invoke', all_params, local_var_params)
# verify the required parameter 'script_id' is set
if ('script_id' not in local_var_params or
local_var_params['script_id'] is None):
raise ValueError("Missing the required parameter `script_id` when calling `post_scripts_id_invoke`") # noqa: E501
path_params = {}
if 'script_id' in local_var_params:
path_params['scriptID'] = local_var_params['script_id'] # noqa: E501
query_params = []
header_params = {}
body_params = None
if 'script_invocation_params' in local_var_params:
body_params = local_var_params['script_invocation_params']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['text/csv', 'application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
return local_var_params, path_params, query_params, header_params, body_params
|