示例#1
0
        public ScoringClient(string host, int port, bool useSsl = false, string authKey = null, string serviceName = null)
        {
            ChannelCredentials baseCreds;

            if (useSsl)
            {
                baseCreds = new SslCredentials();
            }
            else
            {
                baseCreds = ChannelCredentials.Insecure;
            }
            var channel     = new Channel(host, port, baseCreds);
            var callInvoker = channel.Intercept(
                metadata =>
            {
                if (!string.IsNullOrEmpty(authKey))
                {
                    metadata.Add("authorization", $"bearer {authKey}");
                }
                metadata.Add(
                    new Metadata.Entry("x-ms-aml-grpc-service-route", $"/api/v1/service/{serviceName}"));
                return(metadata);
            });

            _client = new PredictionServiceClientWrapper(new PredictionService.PredictionServiceClient(callInvoker));
        }
        public ScoringClient(string host, int port, bool useSsl = false, string authKey = null, string serviceName = null)
        {
            ChannelCredentials baseCreds, creds;

            baseCreds = useSsl ? new SslCredentials() : ChannelCredentials.Insecure;
            if (authKey != null && useSsl)
            {
                creds = ChannelCredentials.Create(baseCreds, CallCredentials.FromInterceptor(
                                                      async(context, metadata) =>
                {
                    metadata.Add(new Metadata.Entry("authorization", authKey));
                    await Task.CompletedTask;
                }));
            }
            else
            {
                creds = baseCreds;
            }
            var channel     = new Channel(host, port, creds);
            var callInvoker = channel.Intercept(
                metadata =>
            {
                metadata.Add(
                    new Metadata.Entry("x-ms-aml-grpc-service-route", $"/api/v1/service/{serviceName}"));
                return(metadata);
            });

            _client = new PredictionServiceClientWrapper(new PredictionService.PredictionServiceClient(callInvoker));
        }
        public ScoringClient(string host, int port, bool useSsl = false, string authKey = null)
        {
            ChannelCredentials baseCreds, creds;

            baseCreds = useSsl ? new SslCredentials() : ChannelCredentials.Insecure;
            if (authKey != null && useSsl)
            {
                creds = ChannelCredentials.Create(baseCreds, CallCredentials.FromInterceptor(
                                                      async(context, metadata) => {
                    metadata.Add(new Metadata.Entry("authorization", authKey));
                    await Task.CompletedTask;
                }));
            }
            else
            {
                creds = baseCreds;
            }
            var channel = new Channel(host, port, creds);

            _client = new PredictionServiceClientWrapper(new PredictionService.PredictionServiceClient(channel));
        }
示例#4
0
 /// <summary>
 /// The user revokes a refresh token
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='refreshToken'>
 /// The refresh token to be revoked
 /// </param>
 public static AccessTokenResponse RevokeRefreshToken(this IPredictionServiceClient operations, string refreshToken)
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IPredictionServiceClient)s).RevokeRefreshTokenAsync(refreshToken), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
示例#5
0
 /// <summary>
 /// The user renews access token and refresh token
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='renewTokenRequest'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <AccessTokenResponse> RenewTokenAsync(this IPredictionServiceClient operations, RenewTokenRequest renewTokenRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.RenewTokenWithHttpMessagesAsync(renewTokenRequest, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#6
0
        /// <summary>
        /// Gets a specific file from an execution in predictionService.
        /// </summary>
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        /// <param name='executionId'>
        /// Execution id of the execution
        /// </param>
        /// <param name='index'>
        /// Index of the execution in the batch.
        /// </param>
        /// <param name='fileName'>
        /// Name of the file to be returned.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async System.Threading.Tasks.Task <System.IO.Stream> GetBatchExecutionFileAsync(this IPredictionServiceClient operations, string executionId, int index, string fileName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            var _result = await operations.GetBatchExecutionFileWithHttpMessagesAsync(executionId, index, fileName, null, cancellationToken).ConfigureAwait(false);

            _result.Request.Dispose();
            return(_result.Body);
        }
示例#7
0
 /// <summary>
 /// Gets a specific file from an execution in predictionService.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='executionId'>
 /// Execution id of the execution
 /// </param>
 /// <param name='index'>
 /// Index of the execution in the batch.
 /// </param>
 /// <param name='fileName'>
 /// Name of the file to be returned.
 /// </param>
 public static System.IO.Stream GetBatchExecutionFile(this IPredictionServiceClient operations, string executionId, int index, string fileName)
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IPredictionServiceClient)s).GetBatchExecutionFileAsync(executionId, index, fileName), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
示例#8
0
 /// <summary>
 /// Gets all files from an individual execution in predictionService.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='executionId'>
 /// Execution id of the execution
 /// </param>
 /// <param name='index'>
 /// Index of the execution in the batch.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <System.Collections.Generic.IList <string> > GetBatchExecutionFilesAsync(this IPredictionServiceClient operations, string executionId, int index, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.GetBatchExecutionFilesWithHttpMessagesAsync(executionId, index, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#9
0
 /// <summary>
 /// Consume the predictionService web service.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='webServiceParameters'>
 /// Input parameters to the web service.
 /// </param>
 public static WebServiceResult Predict(this IPredictionServiceClient operations, InputParameters webServiceParameters)
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IPredictionServiceClient)s).PredictAsync(webServiceParameters), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
示例#10
0
 /// <summary>
 /// Gets all batch executions for predictionService.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='executionId'>
 /// Execution id of the execution
 /// </param>
 /// <param name='showPartialResults'>
 /// Returns the already processed results of the batch execution even if it
 /// hasn't been fully completed.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <BatchWebServiceResult> GetBatchExecutionStatusAsync(this IPredictionServiceClient operations, string executionId, bool?showPartialResults = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.GetBatchExecutionStatusWithHttpMessagesAsync(executionId, showPartialResults, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#11
0
 /// <summary>
 /// Gets all batch executions for predictionService.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='executionId'>
 /// Execution id of the execution
 /// </param>
 /// <param name='showPartialResults'>
 /// Returns the already processed results of the batch execution even if it
 /// hasn't been fully completed.
 /// </param>
 public static BatchWebServiceResult GetBatchExecutionStatus(this IPredictionServiceClient operations, string executionId, bool?showPartialResults = default(bool?))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IPredictionServiceClient)s).GetBatchExecutionStatusAsync(executionId, showPartialResults), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
示例#12
0
 /// <summary>
 /// Logs the user in
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='loginRequest'>
 /// </param>
 public static AccessTokenResponse Login(this IPredictionServiceClient operations, LoginRequest loginRequest)
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IPredictionServiceClient)s).LoginAsync(loginRequest), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
示例#13
0
 /// <summary>
 /// Consume the predictionService web service asynchronously.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='batchWebServiceParameters'>
 /// Input parameters to the web service.
 /// </param>
 /// <param name='parallelCount'>
 /// Number of threads used to process entries in the batch. Default value is
 /// 10. Please make sure not to use too high of a number because it might
 /// negatively impact performance.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <StartBatchExecutionResponse> StartBatchExecutionAsync(this IPredictionServiceClient operations, System.Collections.Generic.IList <InputParameters> batchWebServiceParameters, int?parallelCount = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.StartBatchExecutionWithHttpMessagesAsync(batchWebServiceParameters, parallelCount, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#14
0
 /// <summary>
 /// Consume the predictionService web service asynchronously.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='batchWebServiceParameters'>
 /// Input parameters to the web service.
 /// </param>
 /// <param name='parallelCount'>
 /// Number of threads used to process entries in the batch. Default value is
 /// 10. Please make sure not to use too high of a number because it might
 /// negatively impact performance.
 /// </param>
 public static StartBatchExecutionResponse StartBatchExecution(this IPredictionServiceClient operations, System.Collections.Generic.IList <InputParameters> batchWebServiceParameters, int?parallelCount = default(int?))
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IPredictionServiceClient)s).StartBatchExecutionAsync(batchWebServiceParameters, parallelCount), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
示例#15
0
 /// <summary>
 /// Consume the predictionService web service.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='webServiceParameters'>
 /// Input parameters to the web service.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async System.Threading.Tasks.Task <WebServiceResult> PredictAsync(this IPredictionServiceClient operations, InputParameters webServiceParameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
 {
     using (var _result = await operations.PredictWithHttpMessagesAsync(webServiceParameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#16
0
 public ScoringClient(IPredictionServiceClient client)
 {
     _client = client;
 }
示例#17
0
 /// <summary>
 /// Gets all files from an individual execution in predictionService.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='executionId'>
 /// Execution id of the execution
 /// </param>
 /// <param name='index'>
 /// Index of the execution in the batch.
 /// </param>
 public static System.Collections.Generic.IList <string> GetBatchExecutionFiles(this IPredictionServiceClient operations, string executionId, int index)
 {
     return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IPredictionServiceClient)s).GetBatchExecutionFilesAsync(executionId, index), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }