public async Task <Response <SettingBatch> > GetRevisionsAsync(SettingSelector selector, CancellationToken cancellation = default) { using (var request = _pipeline.CreateRequest()) { request.Method = HttpPipelineMethod.Get; BuildUriForRevisions(request.UriBuilder, selector); request.AddHeader(MediaTypeKeyValueApplicationHeader); if (selector.AsOf.HasValue) { var dateTime = selector.AsOf.Value.UtcDateTime.ToString(AcceptDateTimeFormat); request.AddHeader(AcceptDatetimeHeader, dateTime); } var response = await _pipeline.SendRequestAsync(request, cancellation).ConfigureAwait(false); if (response.Status == 200 || response.Status == 206 /* partial */) { var batch = await ConfigurationServiceSerializer.ParseBatchAsync(response, selector, cancellation); return(new Response <SettingBatch>(response, batch)); } else { throw new RequestFailedException(response); } } }
public async Task <Response <SettingBatch> > GetRevisionsAsync(BatchRequestOptions options, CancellationToken cancellation = default) { var uri = BuildUriForRevisions(options); using (var request = _pipeline.CreateRequest()) { request.SetRequestLine(HttpVerb.Get, uri); request.AddHeader(MediaTypeKeyValueApplicationHeader); AddOptionsHeaders(options, request); var response = await _pipeline.SendRequestAsync(request, cancellation).ConfigureAwait(false); if (response.Status == 200 || response.Status == 206 /* partial */) { var batch = await ConfigurationServiceSerializer.ParseBatchAsync(response, options, cancellation); return(new Response <SettingBatch>(response, batch)); } else { throw new RequestFailedException(response); } } }
/// <summary> /// Lists chronological/historical representation of <see cref="ConfigurationSetting"/> from the configuration store that match the options selected in the <see cref="SettingSelector"/>. /// </summary> /// <remarks>Revisions are provided in descending order from their respective <see cref="ConfigurationSetting.LastModified"/> date.</remarks> /// <param name="selector">Set of options for selecting settings from the configuration store.</param> /// <param name="pageLink"></param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> private async Task <Page <ConfigurationSetting> > GetRevisionsPageAsync(SettingSelector selector, string pageLink, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _pipeline.Diagnostics.CreateScope("Azure.ApplicationModel.Configuration.ConfigurationClient.GetRevisionsPage"); scope.Start(); try { using Request request = CreateGetRevisionsRequest(selector, pageLink); Response response = await _pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false); switch (response.Status) { case 200: case 206: SettingBatch settingBatch = await ConfigurationServiceSerializer.ParseBatchAsync(response, cancellationToken).ConfigureAwait(false); return(new Page <ConfigurationSetting>(settingBatch.Settings, settingBatch.NextBatchLink, response)); default: throw await response.CreateRequestFailedExceptionAsync().ConfigureAwait(false); } } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Fetches the <see cref="ConfigurationSetting"/> from the configuration store that match the options selected in the <see cref="SettingSelector"/>. /// </summary> /// <param name="selector">Set of options for selecting settings from the configuration store.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> public virtual async Task <Response <SettingBatch> > GetBatchAsync(SettingSelector selector, CancellationToken cancellationToken = default) { using (Request request = CreateBatchRequest(selector)) { Response response = await _pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false); switch (response.Status) { case 200: case 206: return(new Response <SettingBatch>(response, await ConfigurationServiceSerializer.ParseBatchAsync(response, selector, cancellationToken))); default: throw await response.CreateRequestFailedExceptionAsync(); } } }
/// <summary> /// Lists chronological/historical representation of <see cref="ConfigurationSetting"/> from the configuration store that match the options selected in the <see cref="SettingSelector"/>. /// </summary> /// <remarks>Revisions are provided in descending order from their respective <see cref="ConfigurationSetting.LastModified"/> date.</remarks> /// <param name="selector">Set of options for selecting settings from the configuration store.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> private async Task <PageResponse <ConfigurationSetting> > GetRevisionsPageAsync(SettingSelector selector, string pageLink, CancellationToken cancellationToken = default) { using (Request request = CreateGetRevisionsRequest(selector, pageLink)) { Response response = await _pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false); switch (response.Status) { case 200: case 206: SettingBatch settingBatch = await ConfigurationServiceSerializer.ParseBatchAsync(response, cancellationToken).ConfigureAwait(false); return(new PageResponse <ConfigurationSetting>(settingBatch.Settings, response, settingBatch.NextBatchLink)); default: throw await response.CreateRequestFailedExceptionAsync().ConfigureAwait(false); } } }