Exemplo n.º 1
0
        /// <summary>
        /// Write a Data point 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="point">specifies the Data point to write into bucket</param>
        public async Task WritePointAsync(string bucket, string org, PointData point)
        {
            Arguments.CheckNonEmptyString(bucket, nameof(bucket));
            Arguments.CheckNonEmptyString(org, nameof(org));

            if (point == null)
            {
                return;
            }

            BatchWriteData data = new BatchWritePoint(new BatchWriteOptions(bucket, org,
                                                                            point.Precision), _options, point);

            await WriteData(org, bucket, point.Precision, new List <BatchWriteData> {
                data
            });
        }
        /// <summary>
        /// Write a Data point 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="point">specifies the Data point to write into bucket</param>
        public async Task <IRestResponse> WritePointAsync(string bucket, string org, PointData point)
        {
            Arguments.CheckNonEmptyString(bucket, nameof(bucket));
            Arguments.CheckNonEmptyString(org, nameof(org));

            if (point == null)
            {
                return(new RestResponse()
                {
                    StatusCode = System.Net.HttpStatusCode.BadRequest, ErrorMessage = "The write doesn't contain any data, skipping"
                });
            }

            BatchWriteData data = new BatchWritePoint(new BatchWriteOptions(bucket, org, point.Precision), _options, point);

            return(await WriteData(org, bucket, point.Precision, new List <BatchWriteData> {
                data
            }));
        }
        /// <summary>
        /// Write Data points 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="points">specifies the Data points to write into bucket</param>
        public async Task <IRestResponse> WritePointsAsync(string bucket, string org, List <PointData> points)
        {
            Arguments.CheckNonEmptyString(bucket, nameof(bucket));
            Arguments.CheckNonEmptyString(org, nameof(org));

            if (points.Count == 0)
            {
                return(new RestResponse()
                {
                    StatusCode = System.Net.HttpStatusCode.BadRequest, ErrorMessage = "The write doesn't contain any data, skipping"
                });
            }

            List <BatchWriteData> list = new List <BatchWriteData>();

            foreach (var point in points)
            {
                BatchWriteData data = new BatchWritePoint(new BatchWriteOptions(bucket, org, point.Precision), _options, point);
                list.Add(data);
            }

            return(await WriteData(org, bucket, points[0].Precision, list));
        }