Ejemplo n.º 1
0
        public async Task <Core.Models.ExecutionContext> ExecuteAsync(ExecutionRequest request, CancellationToken cancelToken)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (cancelToken == null)
            {
                throw new ArgumentNullException(nameof(cancelToken));
            }

            var apiModel    = request.ToApiModel();
            var apiUrl      = $"{proxyConfig.BaseUrl.TrimEnd('/')}/";
            var apiResponse = await jsonHttpClient.PostAsync <ExecutionContextApiModel>(apiUrl, apiModel);

            switch (apiResponse.StatusCode)
            {
            case HttpStatusCode.OK:
                return(apiResponse.Content.ToCoreModel());

            default:
                throw new HttpRequestException($"[Request {request.ExecutionId}]: " +
                                               $"Execution adapter API [{apiUrl}] responded with an unexpected status code: [{apiResponse.StatusCode}].");
            }
        }
Ejemplo n.º 2
0
        public async override Task <JObject> GetServiceConfigurationAsync(ExecutionRequest execRequest)
        {
            if (execRequest == null)
            {
                throw new ArgumentNullException(nameof(execRequest));
            }

            var apiModel    = execRequest.ToApiModel();
            var apiUrl      = $"{proxyConfig.BaseUrl.TrimEnd('/')}/config-request";
            var apiResponse = await jsonHttpClient.PostAsync <JObject>(apiUrl, apiModel);

            switch (apiResponse.StatusCode)
            {
            case HttpStatusCode.NoContent:
                return(null);

            case HttpStatusCode.OK:
                return(apiResponse.Content);

            default:
                throw new HttpRequestException($"[Request {execRequest.ExecutionId}]: " +
                                               $"Execution service API [{apiUrl}] responded with an unexpected status code: [{apiResponse.StatusCode}].");
            }
        }