/// <summary> Initializes a new instance of LogClient. </summary> /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> /// <param name="endpoint"> Supported Cognitive Services endpoint. </param> internal PersonalizerAdministrationClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint) { string stringEndpoint = endpoint.AbsoluteUri; LogRestClient = new LogRestClient(_clientDiagnostics, _pipeline, stringEndpoint); ServiceConfigurationRestClient = new ServiceConfigurationRestClient(_clientDiagnostics, _pipeline, stringEndpoint); ModelRestClient = new ModelRestClient(_clientDiagnostics, _pipeline, stringEndpoint); EvaluationsRestClient = new EvaluationsRestClient(_clientDiagnostics, _pipeline, stringEndpoint); PolicyRestClient = new PolicyRestClient(_clientDiagnostics, _pipeline, stringEndpoint); _clientDiagnostics = clientDiagnostics; _pipeline = pipeline; }
/// <summary> Get properties of the model file generated by Personalizer service. </summary> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual Response <PersonalizerModelProperties> GetPersonalizerModelProperties(CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.GetPersonalizerModelProperties"); scope.Start(); try { return(ModelRestClient.GetProperties(cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> Replace the current model used by Personalizer service with an updated model. </summary> /// <param name="modelBody">Stream representing the digitally signed model zip archive.</param> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual Response ImportPersonalizerSignedModel(Stream modelBody, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.ImportPersonalizerSignedModel"); scope.Start(); try { return(ModelRestClient.Import(modelBody, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> Get properties of the model file generated by Personalizer service. </summary> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual async Task <Response <PersonalizerModelProperties> > GetPersonalizerModelPropertiesAsync(CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.GetPersonalizerModelProperties"); scope.Start(); try { return(await ModelRestClient.GetPropertiesAsync(cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> Replace the current model used by Personalizer service with an updated model. </summary> /// <param name="modelBody">Stream representing the digitally signed model zip archive.</param> /// <param name="cancellationToken"> The cancellation token to use. </param> public virtual async Task <Response> ImportPersonalizerSignedModelAsync(Stream modelBody, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.ImportPersonalizerSignedModel"); scope.Start(); try { return(await ModelRestClient.ImportAsync(modelBody, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> Export the current model used by Personalizer service. </summary> /// <param name="isSigned">True if requesting signed model zip archive, false otherwise.</param> /// <param name="cancellationToken"> The cancellation token to use. </param> /// <remarks> Exports the Personalizer model. </remarks> public virtual Response <Stream> ExportPersonalizerModel(bool isSigned, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.ExportPersonalizerModel"); scope.Start(); try { return(ModelRestClient.Get(isSigned, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
public ModelClient(string endpoint, AzureKeyCredential credential, PersonalizerClientOptions options = null) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (credential == null) { throw new ArgumentNullException(nameof(credential)); } options ??= new PersonalizerClientOptions(); _clientDiagnostics = new ClientDiagnostics(options); _pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, "Ocp-Apim-Subscription-Key")); RestClient = new ModelRestClient(_clientDiagnostics, _pipeline, endpoint); }
public ModelClient(string endpoint, TokenCredential credential, PersonalizerClientOptions options = null) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (credential == null) { throw new ArgumentNullException(nameof(credential)); } options ??= new PersonalizerClientOptions(); _clientDiagnostics = new ClientDiagnostics(options); string[] scopes = { "https://cognitiveservices.azure.com/.default" }; _pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, scopes)); RestClient = new ModelRestClient(_clientDiagnostics, _pipeline, endpoint); }
/// <summary> Initializes a new instance of PersonalizerClient. </summary> /// <param name="endpoint"> Supported Cognitive Services endpoint. </param> /// <param name="credential"> A credential used to authenticate to an Azure Service. </param> /// <param name="options"> The options for configuring the client. </param> public PersonalizerAdministrationClient(Uri endpoint, AzureKeyCredential credential, PersonalizerClientOptions options = null) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (credential == null) { throw new ArgumentNullException(nameof(credential)); } options ??= new PersonalizerClientOptions(); _clientDiagnostics = new ClientDiagnostics(options); _pipeline = HttpPipelineBuilder.Build(options, new AzureKeyCredentialPolicy(credential, "Ocp-Apim-Subscription-Key")); string stringEndpoint = endpoint.AbsoluteUri; LogRestClient = new LogRestClient(_clientDiagnostics, _pipeline, stringEndpoint); ServiceConfigurationRestClient = new ServiceConfigurationRestClient(_clientDiagnostics, _pipeline, stringEndpoint); ModelRestClient = new ModelRestClient(_clientDiagnostics, _pipeline, stringEndpoint); EvaluationsRestClient = new EvaluationsRestClient(_clientDiagnostics, _pipeline, stringEndpoint); PolicyRestClient = new PolicyRestClient(_clientDiagnostics, _pipeline, stringEndpoint); }
/// <summary> Initializes a new instance of PersonalizerClient. </summary> /// <param name="endpoint"> Supported Cognitive Services endpoint. </param> /// <param name="credential"> A credential used to authenticate to an Azure Service. </param> /// <param name="options"> The options for configuring the client. </param> public PersonalizerAdministrationClient(Uri endpoint, TokenCredential credential, PersonalizerClientOptions options = null) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (credential == null) { throw new ArgumentNullException(nameof(credential)); } options ??= new PersonalizerClientOptions(); _clientDiagnostics = new ClientDiagnostics(options); string[] scopes = { "https://cognitiveservices.azure.com/.default" }; _pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(credential, scopes)); string stringEndpoint = endpoint.AbsoluteUri; LogRestClient = new LogRestClient(_clientDiagnostics, _pipeline, stringEndpoint); ServiceConfigurationRestClient = new ServiceConfigurationRestClient(_clientDiagnostics, _pipeline, stringEndpoint); ModelRestClient = new ModelRestClient(_clientDiagnostics, _pipeline, stringEndpoint); EvaluationsRestClient = new EvaluationsRestClient(_clientDiagnostics, _pipeline, stringEndpoint); PolicyRestClient = new PolicyRestClient(_clientDiagnostics, _pipeline, stringEndpoint); }
internal ModelClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint) { RestClient = new ModelRestClient(clientDiagnostics, pipeline, endpoint); _clientDiagnostics = clientDiagnostics; _pipeline = pipeline; }