Ejemplo n.º 1
0
        /// <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, selector, cancellationToken);

                    return(new PageResponse <ConfigurationSetting>(settingBatch.Settings, response, settingBatch.NextBatchLink));

                default:
                    throw await response.CreateRequestFailedExceptionAsync();
                }
            }
        }
Ejemplo n.º 2
0
 void BuildUriForRevisions(HttpPipelineUriBuilder builder, SettingSelector selector)
 {
     builder.Uri = _baseUri;
     builder.AppendPath(RevisionsRoute);
     BuildBatchQuery(builder, selector);
 }
Ejemplo n.º 3
0
 public virtual IEnumerable <Response <ConfigurationSetting> > GetRevisions(SettingSelector selector, CancellationToken cancellationToken = default)
 {
     return(PageResponseEnumerator.CreateEnumerable(nextLink => GetRevisionsPage(selector, nextLink, cancellationToken)));
 }
 void BuildUriForRevisions(RequestUriBuilder builder, SettingSelector selector, string pageLink)
 {
     builder.Uri = _baseUri;
     builder.AppendPath(RevisionsRoute);
     BuildBatchQuery(builder, selector, pageLink);
 }
 void BuildUriForGetBatch(HttpPipelineUriBuilder builder, SettingSelector selector, string pageLink)
 {
     builder.Uri = _baseUri;
     builder.AppendPath(KvRoute);
     BuildBatchQuery(builder, selector, pageLink);
 }
Ejemplo n.º 6
0
        /// <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 <PageResponse <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 PageResponse <ConfigurationSetting>(settingBatch.Settings, response, settingBatch.NextBatchLink));

                default:
                    throw await response.CreateRequestFailedExceptionAsync().ConfigureAwait(false);
                }
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Ejemplo n.º 7
0
 internal SettingBatch(ConfigurationSetting[] settings, string link, SettingSelector selector)
 {
     _settings = settings;
     _link     = link;
     _selector = selector;
 }