/// <summary>
        /// Write Line Protocol records into specified bucket.
        /// </summary>
        /// <param name="bucket">specifies the destination bucket for writes</param>
        /// <param name="org">specifies the destination organization for writes</param>
        /// <param name="precision">specifies the precision for the unix timestamps within the body line-protocol</param>
        /// <param name="records">specifies the record in InfluxDB Line Protocol</param>
        public async Task WriteRecordsAsync(string bucket, string org, WritePrecision precision, List <string> records)
        {
            Arguments.CheckNonEmptyString(bucket, nameof(bucket));
            Arguments.CheckNonEmptyString(org, nameof(org));
            Arguments.CheckNotNull(precision, nameof(precision));

            var list = new List <BatchWriteData>();

            foreach (var record in records)
            {
                BatchWriteData data = new BatchWriteRecord(new BatchWriteOptions(bucket, org, precision), record);
                list.Add(data);
            }

            await WriteData(org, bucket, precision, list);
        }
Esempio n. 2
0
        /// <summary>
        /// Write Line Protocol records into specified bucket.
        /// </summary>
        /// <param name="bucket">specifies the destination bucket for writes</param>
        /// <param name="org">specifies the destination organization for writes</param>
        /// <param name="precision">specifies the precision for the unix timestamps within the body line-protocol</param>
        /// <param name="records">specifies the record in InfluxDB Line Protocol</param>
        /// <param name="cancellationToken">specifies the token to monitor for cancellation requests</param>
        public Task WriteRecordsAsync(string bucket, string org, WritePrecision precision, List <string> records, CancellationToken cancellationToken = default)
        {
            Arguments.CheckNonEmptyString(bucket, nameof(bucket));
            Arguments.CheckNonEmptyString(org, nameof(org));
            Arguments.CheckNotNull(precision, nameof(precision));

            var list = new List <BatchWriteData>();

            foreach (var record in records)
            {
                BatchWriteData data = new BatchWriteRecord(new BatchWriteOptions(bucket, org, precision), record);
                list.Add(data);
            }

            return(WriteData(org, bucket, precision, list, cancellationToken));
        }