Skip to content

Commit 9b8e182

Browse files
committed
feat: add warning about availability only on the InfluxDB Cloud
1 parent b057ca2 commit 9b8e182

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

influxdb_client/client/warnings.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,25 @@ def print_warning(query: str):
2929
- https://docs.influxdata.com/flux/latest/stdlib/influxdata/influxdb/schema/fieldsascols/
3030
"""
3131
warnings.warn(message, MissingPivotFunction)
32+
33+
34+
class CloudOnlyWarning(UserWarning):
35+
"""User warning about availability only on the InfluxDB Cloud."""
36+
37+
@staticmethod
38+
def print_warning(api_name: str, doc_url: str):
39+
"""Print warning about availability only on the InfluxDB Cloud."""
40+
41+
message = f"""The '{api_name}' API is available only on the InfluxDB Cloud.
42+
43+
For more info see:
44+
- {doc_url}
45+
- https://docs.influxdata.com/influxdb/cloud/
46+
47+
You can disable this warning by:
48+
import warnings
49+
from influxdb_client.client.warnings import CloudOnlyWarning
50+
51+
warnings.simplefilter("ignore", CloudOnlyWarning)
52+
"""
53+
warnings.warn(message, CloudOnlyWarning)

influxdb_client/service/bucket_schemas_service.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def __init__(self, api_client=None): # noqa: E501,D401,D403
3131
raise ValueError("Invalid value for `api_client`, must be defined.")
3232
self.api_client = api_client
3333

34+
from influxdb_client.client.warnings import CloudOnlyWarning
35+
CloudOnlyWarning.print_warning('BucketSchemasService',
36+
'https://docs.influxdata.com/influxdb/cloud/organizations/buckets/bucket-schema/')
37+
3438
def create_measurement_schema(self, bucket_id, **kwargs): # noqa: E501,D401,D403
3539
"""Create a measurement schema for a bucket.
3640

influxdb_client/service/invokable_scripts_service.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def __init__(self, api_client=None): # noqa: E501,D401,D403
3131
raise ValueError("Invalid value for `api_client`, must be defined.")
3232
self.api_client = api_client
3333

34+
from influxdb_client.client.warnings import CloudOnlyWarning
35+
CloudOnlyWarning.print_warning('InvokableScriptsService',
36+
'https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/')
37+
3438
def delete_scripts_id(self, script_id, **kwargs): # noqa: E501,D401,D403
3539
"""Delete a script.
3640

0 commit comments

Comments
 (0)