public virtual Response <PersonalizerServiceProperties> Update(PersonalizerServiceProperties config, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ServiceConfigurationClient.Update"); scope.Start(); try { return(RestClient.Update(config, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <Response <PersonalizerServiceProperties> > UpdateAsync(PersonalizerServiceProperties config, CancellationToken cancellationToken = default) { if (config == null) { throw new ArgumentNullException(nameof(config)); } using var message = CreateUpdateRequest(config); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { PersonalizerServiceProperties value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = PersonalizerServiceProperties.DeserializePersonalizerServiceProperties(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal HttpMessage CreateUpdateRequest(PersonalizerServiceProperties config) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Put; var uri = new RawRequestUriBuilder(); uri.AppendRaw(endpoint, false); uri.AppendRaw("/personalizer/v1.1-preview.3", false); uri.AppendPath("/configurations/service", false); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(config); request.Content = content; return(message); }
/// <summary> Update the Personalizer service configuration. </summary> /// <param name="config"> The personalizer service configuration. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual async Task <Response <PersonalizerServiceProperties> > UpdatePersonalizerPropertiesAsync(PersonalizerServiceProperties config, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.UpdatePersonalizerProperties"); scope.Start(); try { return(await ServiceConfigurationRestClient.UpdateAsync(config, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }