Пример #1
0
        public static async Task <HttpResponseMessage> ExecuteGitCommand(
            this IGitRepo gitRepo,
            HttpMethod method,
            string requestUri,
            ILogger logger,
            string body            = null,
            string versionOverride = null)
        {
            using (HttpClient client = gitRepo.CreateHttpClient(versionOverride))
            {
                var requestManager = new HttpRequestManager(client, method, requestUri, logger, body, versionOverride);

                return(await requestManager.ExecuteAsync());
            }
        }
Пример #2
0
 /// <summary>
 /// Execute a remote github command using the REST APi
 /// </summary>
 /// <param name="method">Http method</param>
 /// <param name="requestUri">Request path</param>
 /// <param name="logger">Logger</param>
 /// <param name="body">Body if <paramref name="method"/> is POST or PATCH</param>
 /// <param name="versionOverride">Use alternate API version, if specified.</param>
 /// <returns></returns>
 private async Task <HttpResponseMessage> ExecuteRemoteGitCommandAsync(
     HttpMethod method,
     string requestUri,
     ILogger logger,
     string body            = null,
     string versionOverride = null,
     int retryCount         = 15,
     bool logFailure        = true)
 {
     using (HttpClient client = CreateHttpClient())
     {
         var requestManager = new HttpRequestManager(client, method, requestUri, logger, body, versionOverride, logFailure);
         return(await requestManager.ExecuteAsync(retryCount));
     }
 }
Пример #3
0
        public async Task <string> GetSubscriptionAsync(int subscriptionId, string barPassword)
        {
            using (HttpClient client = CreateHttpClient(barPassword))
            {
                _logger.LogInformation($"Querying for a subscription with id {subscriptionId}...");

                HttpRequestManager requestManager = new HttpRequestManager(client, HttpMethod.Get, $"/subscriptions/{subscriptionId}", _logger);

                HttpResponseMessage response = await requestManager.ExecuteAsync();

                _logger.LogInformation($"Querying for a subscription with id {subscriptionId} succeeded!");

                return(await response.Content.ReadAsStringAsync());
            }
        }