public TimeSeriesBatchOperation NewBatch(TimeSeriesBatchOptions options = null) { if (parent.Name == null) { throw new ArgumentException("Time series isn't set!"); } parent.AssertInitialized(); return(new TimeSeriesBatchOperation(parent, parent.Name, options)); }
/// <summary> /// Create new time series on the server. /// </summary> /// <param name="timeSeriesDocument">Settings for the time series. If null, default settings will be used, and the name specified in the client ctor will be used</param> /// <param name="shouldUpdateIfExists">Indicates if time series should be updated if they exist.</param> /// <param name="credentials">Credentials used for this operation.</param> /// <param name="token">Cancellation token used for this operation.</param> public async Task <TimeSeriesStore> CreateTimeSeriesAsync(TimeSeriesDocument timeSeriesDocument, bool shouldUpdateIfExists = false, OperationCredentials credentials = null, CancellationToken token = default(CancellationToken)) { if (timeSeriesDocument == null) { throw new ArgumentNullException("timeSeriesDocument"); } parent.AssertInitialized(); var timeSeriesName = timeSeriesDocument.Id.Replace(Constants.TimeSeries.Prefix, ""); var requestUri = parent.Url + "admin/ts/" + timeSeriesName; if (shouldUpdateIfExists) { requestUri += "?update=true"; } using (var request = parent.CreateHttpJsonRequest(requestUri, HttpMethods.Put)) { try { await request.WriteAsync(RavenJObject.FromObject(timeSeriesDocument)).WithCancellation(token).ConfigureAwait(false); } catch (ErrorResponseException e) { if (e.StatusCode == HttpStatusCode.Conflict) { throw new InvalidOperationException("Cannot create time series with the name '" + timeSeriesName + "' because it already exists. Use CreateOrUpdateTimeSeriesAsync in case you want to update an existing time series", e); } throw; } } return(new TimeSeriesStore { Name = timeSeriesName, Url = parent.Url, Credentials = credentials ?? parent.Credentials }); }
public async Task FlushAsync() { if (string.IsNullOrWhiteSpace(parent.Name)) { throw new InvalidOperationException("Default time series name cannot be empty!"); } parent.AssertInitialized(); await parent.ReplicationInformer.UpdateReplicationInformationIfNeededAsync().ConfigureAwait(false); await defaultBatchOperation.Value.FlushAsync().ConfigureAwait(false); }