internal async Task <HttpOperationResponse <ViewConfiguration> > GetRepositoriesInternalAsync( string vcb = default, CancellationToken cancellationToken = default ) { var _path = "/api/2018-03-14/repo"; var _query = new QueryBuilder(); if (!string.IsNullOrEmpty(vcb)) { _query.Add("_vcb", Client.Serialize(vcb)); } var _uriBuilder = new UriBuilder(Client.BaseUri); _uriBuilder.Path = _uriBuilder.Path.TrimEnd('/') + _path; _uriBuilder.Query = _query.ToString(); var _url = _uriBuilder.Uri; HttpRequestMessage _req = null; HttpResponseMessage _res = null; try { _req = new HttpRequestMessage(HttpMethod.Get, _url); if (Client.Credentials != null) { await Client.Credentials.ProcessHttpRequestAsync(_req, cancellationToken).ConfigureAwait(false); } _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false); var _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); if (!_res.IsSuccessStatusCode) { var ex = new RestApiException { Request = new HttpRequestMessageWrapper(_req, null), Response = new HttpResponseMessageWrapper(_res, _responseContent), }; HandleFailedGetRepositoriesRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } return(new HttpOperationResponse <ViewConfiguration> { Request = _req, Response = _res, Body = Client.Deserialize <ViewConfiguration>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <IImmutableList <DetailedVMScalingHistory> > > GetDetailedVMScalingHistoryInternalAsync( DateTimeOffset date, string scaleSet = default, CancellationToken cancellationToken = default ) { if (date == default) { throw new ArgumentNullException(nameof(date)); } var _path = "/api/2018-03-14/scalesets/detailedHistory"; var _query = new QueryBuilder(); if (date != default) { _query.Add("date", Client.Serialize(date)); } if (!string.IsNullOrEmpty(scaleSet)) { _query.Add("scaleSet", Client.Serialize(scaleSet)); } var _uriBuilder = new UriBuilder(Client.BaseUri); _uriBuilder.Path = _uriBuilder.Path.TrimEnd('/') + _path; _uriBuilder.Query = _query.ToString(); var _url = _uriBuilder.Uri; HttpRequestMessage _req = null; HttpResponseMessage _res = null; try { _req = new HttpRequestMessage(HttpMethod.Get, _url); if (Client.Credentials != null) { await Client.Credentials.ProcessHttpRequestAsync(_req, cancellationToken).ConfigureAwait(false); } _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false); var _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); if (!_res.IsSuccessStatusCode) { var ex = new RestApiException { Request = new HttpRequestMessageWrapper(_req, null), Response = new HttpResponseMessageWrapper(_res, _responseContent), }; HandleFailedGetDetailedVMScalingHistoryRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } return(new HttpOperationResponse <IImmutableList <DetailedVMScalingHistory> > { Request = _req, Response = _res, Body = Client.Deserialize <IImmutableList <DetailedVMScalingHistory> >(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse> LogInternalAsync( string id, string logUri, string xHelixJobToken, string format = default, string module = default, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } if (string.IsNullOrEmpty(logUri)) { throw new ArgumentNullException(nameof(logUri)); } if (string.IsNullOrEmpty(xHelixJobToken)) { throw new ArgumentNullException(nameof(xHelixJobToken)); } var _path = "/api/2018-03-14/telemetry/job/workitem/{id}/log"; _path = _path.Replace("{id}", Client.Serialize(id)); var _query = new QueryBuilder(); if (!string.IsNullOrEmpty(logUri)) { _query.Add("logUri", Client.Serialize(logUri)); } if (!string.IsNullOrEmpty(format)) { _query.Add("format", Client.Serialize(format)); } if (!string.IsNullOrEmpty(module)) { _query.Add("module", Client.Serialize(module)); } var _uriBuilder = new UriBuilder(Client.BaseUri); _uriBuilder.Path = _uriBuilder.Path.TrimEnd('/') + _path; _uriBuilder.Query = _query.ToString(); var _url = _uriBuilder.Uri; HttpRequestMessage _req = null; HttpResponseMessage _res = null; try { _req = new HttpRequestMessage(HttpMethod.Post, _url); if (!string.IsNullOrEmpty(xHelixJobToken)) { _req.Headers.Add("X-Helix-Job-Token", xHelixJobToken); } if (Client.Credentials != null) { await Client.Credentials.ProcessHttpRequestAsync(_req, cancellationToken).ConfigureAwait(false); } _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false); var _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); if (!_res.IsSuccessStatusCode) { var ex = new RestApiException { Request = new HttpRequestMessageWrapper(_req, null), Response = new HttpResponseMessageWrapper(_res, _responseContent), }; HandleFailedLogRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } return(new HttpOperationResponse { Request = _req, Response = _res, }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <string> > StartXUnitWorkItemInternalAsync( string friendlyName, string xHelixJobToken, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(friendlyName)) { throw new ArgumentNullException(nameof(friendlyName)); } if (string.IsNullOrEmpty(xHelixJobToken)) { throw new ArgumentNullException(nameof(xHelixJobToken)); } var _path = "/api/2018-03-14/telemetry/job/xunit"; var _query = new QueryBuilder(); if (!string.IsNullOrEmpty(friendlyName)) { _query.Add("friendlyName", Client.Serialize(friendlyName)); } var _uriBuilder = new UriBuilder(Client.BaseUri); _uriBuilder.Path = _uriBuilder.Path.TrimEnd('/') + _path; _uriBuilder.Query = _query.ToString(); var _url = _uriBuilder.Uri; HttpRequestMessage _req = null; HttpResponseMessage _res = null; try { _req = new HttpRequestMessage(HttpMethod.Post, _url); if (!string.IsNullOrEmpty(xHelixJobToken)) { _req.Headers.Add("X-Helix-Job-Token", xHelixJobToken); } if (Client.Credentials != null) { await Client.Credentials.ProcessHttpRequestAsync(_req, cancellationToken).ConfigureAwait(false); } _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false); var _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); if (!_res.IsSuccessStatusCode) { var ex = new RestApiException { Request = new HttpRequestMessageWrapper(_req, null), Response = new HttpResponseMessageWrapper(_res, _responseContent), }; HandleFailedStartXUnitWorkItemRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } return(new HttpOperationResponse <string> { Request = _req, Response = _res, Body = Client.Deserialize <string>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse> SetReasonInternalAsync( string analysisName, string analysisType, string job, FailureReason reason, string workitem, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(analysisName)) { throw new ArgumentNullException(nameof(analysisName)); } if (string.IsNullOrEmpty(analysisType)) { throw new ArgumentNullException(nameof(analysisType)); } if (string.IsNullOrEmpty(job)) { throw new ArgumentNullException(nameof(job)); } if (reason == default) { throw new ArgumentNullException(nameof(reason)); } if (string.IsNullOrEmpty(workitem)) { throw new ArgumentNullException(nameof(workitem)); } var _path = "/api/2018-03-14/analysis/{job}/{analysisType}/reason"; _path = _path.Replace("{job}", Client.Serialize(job)); _path = _path.Replace("{analysisType}", Client.Serialize(analysisType)); var _query = new QueryBuilder(); if (!string.IsNullOrEmpty(workitem)) { _query.Add("workitem", Client.Serialize(workitem)); } if (!string.IsNullOrEmpty(analysisName)) { _query.Add("analysisName", Client.Serialize(analysisName)); } var _uriBuilder = new UriBuilder(Client.BaseUri); _uriBuilder.Path = _uriBuilder.Path.TrimEnd('/') + _path; _uriBuilder.Query = _query.ToString(); var _url = _uriBuilder.Uri; HttpRequestMessage _req = null; HttpResponseMessage _res = null; try { _req = new HttpRequestMessage(HttpMethod.Put, _url); string _requestContent = null; if (reason != default) { _requestContent = Client.Serialize(reason); _req.Content = new StringContent(_requestContent, Encoding.UTF8) { Headers = { ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"), }, }; } if (Client.Credentials != null) { await Client.Credentials.ProcessHttpRequestAsync(_req, cancellationToken).ConfigureAwait(false); } _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false); string _responseContent; if (!_res.IsSuccessStatusCode) { _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); var ex = new RestApiException( new HttpRequestMessageWrapper(_req, _requestContent), new HttpResponseMessageWrapper(_res, _responseContent)); HandleFailedSetReasonRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse { Request = _req, Response = _res, }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <GetDetailsResponse> > GetDetailsInternalAsync( string analysisName, string analysisType, string job, string workitem, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(analysisName)) { throw new ArgumentNullException(nameof(analysisName)); } if (string.IsNullOrEmpty(analysisType)) { throw new ArgumentNullException(nameof(analysisType)); } if (string.IsNullOrEmpty(job)) { throw new ArgumentNullException(nameof(job)); } if (string.IsNullOrEmpty(workitem)) { throw new ArgumentNullException(nameof(workitem)); } var _path = "/api/2018-03-14/analysis/{job}/{analysisType}"; _path = _path.Replace("{job}", Client.Serialize(job)); _path = _path.Replace("{analysisType}", Client.Serialize(analysisType)); var _query = new QueryBuilder(); if (!string.IsNullOrEmpty(workitem)) { _query.Add("workitem", Client.Serialize(workitem)); } if (!string.IsNullOrEmpty(analysisName)) { _query.Add("analysisName", Client.Serialize(analysisName)); } var _uriBuilder = new UriBuilder(Client.BaseUri); _uriBuilder.Path = _uriBuilder.Path.TrimEnd('/') + _path; _uriBuilder.Query = _query.ToString(); var _url = _uriBuilder.Uri; HttpRequestMessage _req = null; HttpResponseMessage _res = null; try { _req = new HttpRequestMessage(HttpMethod.Get, _url); if (Client.Credentials != null) { await Client.Credentials.ProcessHttpRequestAsync(_req, cancellationToken).ConfigureAwait(false); } _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false); string _responseContent; if (!_res.IsSuccessStatusCode) { _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); var ex = new RestApiException( new HttpRequestMessageWrapper(_req, null), new HttpResponseMessageWrapper(_res, _responseContent)); HandleFailedGetDetailsRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <GetDetailsResponse> { Request = _req, Response = _res, Body = Client.Deserialize <GetDetailsResponse>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <IImmutableList <ContainerInformation> > > ListInternalAsync( bool getSasTokens = default, CancellationToken cancellationToken = default ) { var _path = "/api/2018-03-14/storage"; var _query = new QueryBuilder(); if (getSasTokens != default) { _query.Add("getSasTokens", Client.Serialize(getSasTokens)); } var _uriBuilder = new UriBuilder(Client.BaseUri); _uriBuilder.Path = _uriBuilder.Path.TrimEnd('/') + _path; _uriBuilder.Query = _query.ToString(); var _url = _uriBuilder.Uri; HttpRequestMessage _req = null; HttpResponseMessage _res = null; try { _req = new HttpRequestMessage(HttpMethod.Get, _url); if (Client.Credentials != null) { await Client.Credentials.ProcessHttpRequestAsync(_req, cancellationToken).ConfigureAwait(false); } _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false); var _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); if (!_res.IsSuccessStatusCode) { var ex = new RestApiException { Request = new HttpRequestMessageWrapper(_req, null), Response = new HttpResponseMessageWrapper(_res, _responseContent), }; HandleFailedListRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } return(new HttpOperationResponse <IImmutableList <ContainerInformation> > { Request = _req, Response = _res, Body = Client.Deserialize <IImmutableList <ContainerInformation> >(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }