3232INFLUX_PROFILERS = "INFLUX_PROFILERS"
3333INFLUX_TAG = "INFLUX_TAG"
3434
35+
3536def write_client_options (** kwargs ):
3637 """
3738 Function for providing additional arguments for the WriteApi client.
@@ -104,11 +105,19 @@ def _merge_options(defaults, exclude_keys=None, custom=None):
104105
105106def _parse_precision (precision ):
106107 """
107- Parse and validate precision value.
108-
109- :param precision: Precision value to validate
110- :return: Validated precision value
111- :raises ValueError: If precision is invalid
108+ Parses the precision value and ensures it is valid.
109+
110+ This function checks that the given `precision` is one of the allowed
111+ values defined in `WritePrecision`. If the precision is invalid, it
112+ raises a `ValueError`. The function returns the valid precision value
113+ if it passes validation.
114+
115+ :param precision: The precision value to be validated.
116+ Must be one of WritePrecision.NS, WritePrecision.MS,
117+ WritePrecision.S, or WritePrecision.US.
118+ :return: The valid precision value.
119+ :rtype: WritePrecision
120+ :raises ValueError: If the provided precision is not valid.
112121 """
113122 if precision not in [WritePrecision .NS , WritePrecision .MS , WritePrecision .S , WritePrecision .US ]:
114123 raise ValueError (f"Invalid precision value: { precision } " )
@@ -117,11 +126,18 @@ def _parse_precision(precision):
117126
118127def _parse_gzip_threshold (threshold ):
119128 """
120- Parse and validate gzip threshold value.
121-
122- :param threshold: Threshold value to validate
123- :return: Validated threshold value
124- :raises ValueError: If threshold is invalid
129+ Parses and validates the provided threshold value.
130+
131+ This function ensures that the given threshold is a valid integer value,
132+ and it raises an appropriate error if the threshold is not valid. It also
133+ enforces that the threshold value is non-negative.
134+
135+ :param threshold: The input threshold value to be parsed and validated.
136+ :type threshold: Any
137+ :return: The validated threshold value as an integer.
138+ :rtype: int
139+ :raises ValueError: If the provided threshold is not an integer or if it is
140+ negative.
125141 """
126142 try :
127143 threshold = int (threshold )
@@ -248,30 +264,32 @@ def __init__(
248264 flight_client_options = flight_client_options ,
249265 proxy = kwargs .get ("proxy" , None ), options = q_opts_builder .build ())
250266
251-
252267 @classmethod
253268 def from_env (cls , ** kwargs : Any ) -> 'InfluxDBClient3' :
254269
255270 """
256- Create an instance of `InfluxDBClient3` using environment variables for configuration.
257-
258- This function retrieves and validates the following required environment variables:
259- - `INFLUX_HOST`: The hostname or IP address of the InfluxDB server.
260- - `INFLUX_TOKEN`: The authentication token used for accessing the server.
261- - `INFLUX_DATABASE`: The default database for the client operations.
262- And optional environment variable:
263- - `INFLUX_ORG`: The organization associated with InfluxDB operations.
264- Defaults to "default" if not set.
265-
266- If any of the required environment variables are not set, a ValueError will be
267- raised with details about the missing variables.
268-
269- :param kwargs: Additional keyword arguments that will be passed to the
270- `InfluxDBClient3` constructor for customization. This allows for
271- configuring specific client behaviors like write_client_options,
272- flight_client_options, SSL settings, etc.
273- :return: An initialized `InfluxDBClient3` instance.
274- :raises ValueError: If any required environment variables are not set.
271+ Creates an instance of InfluxDBClient3 configured by specific environment
272+ variables. This method automatically loads configuration settings,
273+ such as connection details, security parameters, and performance
274+ options, from environment variables and initializes the client
275+ accordingly.
276+
277+ :param cls:
278+ The class used to create the client instance.
279+ :param kwargs:
280+ Additional optional parameters that can be passed to customize the
281+ configuration or override specific settings derived from the
282+ environment variables.
283+
284+ :raises ValueError:
285+ If any required environment variables are missing or have empty
286+ values.
287+
288+ :return:
289+ An initialized instance of the `InfluxDBClient3` class with all the
290+ configuration settings applied.
291+ :rtype:
292+ InfluxDBClient3
275293 """
276294
277295 required_vars = {
@@ -344,7 +362,6 @@ def from_env(cls, **kwargs: Any) -> 'InfluxDBClient3':
344362 ** kwargs
345363 )
346364
347-
348365 def write (self , record = None , database = None , ** kwargs ):
349366 """
350367 Write data to InfluxDB.
0 commit comments