/// <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 the Offline Evaluation associated with the Id. </summary>
 /// <param name="evaluationId"> Id of the Offline Evaluation. </param>
 /// <param name="cancellationToken"> The cancellation token to use. </param>
 public virtual Response <PersonalizerEvaluation> GetPersonalizerEvaluation(string evaluationId, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.GetPersonalizerEvaluation");
     scope.Start();
     try
     {
         return(EvaluationsRestClient.Get(evaluationId, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 /// <summary> Get the Offline Evaluation associated with the Id. </summary>
 /// <param name="evaluationId"> Id of the Offline Evaluation. </param>
 /// <param name="cancellationToken"> The cancellation token to use. </param>
 public virtual async Task <Response <PersonalizerEvaluation> > GetPersonalizerEvaluationAsync(string evaluationId, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.GetPersonalizerEvaluation");
     scope.Start();
     try
     {
         return(await EvaluationsRestClient.GetAsync(evaluationId, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 /// <summary> Submit a new Offline Evaluation job. </summary>
 /// <param name="evaluation"> The Offline Evaluation job definition. </param>
 /// <param name="cancellationToken"> The cancellation token to use. </param>
 public virtual PersonalizerCreateEvaluationOperation CreatePersonalizerEvaluation(PersonalizerEvaluationOptions evaluation, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.CreatePersonalizerEvaluation");
     scope.Start();
     try
     {
         Response <PersonalizerEvaluation> result = EvaluationsRestClient.Create(evaluation, cancellationToken);
         return(new PersonalizerCreateEvaluationOperation(this, result.Value.Id, result.GetRawResponse(), cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
        public EvaluationsClient(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 EvaluationsRestClient(_clientDiagnostics, _pipeline, endpoint);
        }
        public EvaluationsClient(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 EvaluationsRestClient(_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> List of all Offline Evaluations. </summary>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        public virtual Pageable <PersonalizerEvaluation> GetPersonalizerEvaluations(CancellationToken cancellationToken = default)
        {
            return(PageResponseEnumerator.CreateEnumerable((continuationToken) =>
            {
                using var scope = _clientDiagnostics.CreateScope("PersonalizerAdministrationClient.GetPersonalizerEvaluations");
                scope.Start();
                try
                {
                    if (continuationToken != null)
                    {
                        throw new NotSupportedException("A continuation token is unsupported.");
                    }

                    Response <IReadOnlyList <PersonalizerEvaluation> > result = EvaluationsRestClient.List(cancellationToken);
                    return Page <PersonalizerEvaluation> .FromValues(result.Value, null, result.GetRawResponse());
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }));
        }
        /// <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 EvaluationsClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint)
 {
     RestClient         = new EvaluationsRestClient(clientDiagnostics, pipeline, endpoint);
     _clientDiagnostics = clientDiagnostics;
     _pipeline          = pipeline;
 }