internal async Task <HttpOperationResponse <IImmutableList <AggregatedVMScalingHistory> > > GetAggregatedVMScalingHistoryInternalAsync( DateTimeOffset date, CancellationToken cancellationToken = default ) { if (date == default) { throw new ArgumentNullException(nameof(date)); } var _path = "/api/2019-06-17/scalesets/aggregatedHistory"; var _query = new QueryBuilder(); if (date != default) { _query.Add("date", Client.Serialize(date)); } 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); if (!_res.IsSuccessStatusCode) { await OnGetAggregatedVMScalingHistoryFailed(_req, _res); } string _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <IImmutableList <AggregatedVMScalingHistory> > { Request = _req, Response = _res, Body = Client.Deserialize <IImmutableList <AggregatedVMScalingHistory> >(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <Newtonsoft.Json.Linq.JToken> > WaitInternalAsync( string job, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(job)) { throw new ArgumentNullException(nameof(job)); } var _path = "/api/2019-06-17/jobs/{job}/wait"; _path = _path.Replace("{job}", Client.Serialize(job)); var _query = new QueryBuilder(); 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); if (!_res.IsSuccessStatusCode) { await OnWaitFailed(_req, _res); } string _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <Newtonsoft.Json.Linq.JToken> { Request = _req, Response = _res, Body = Client.Deserialize <Newtonsoft.Json.Linq.JToken>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <JenkinsResponse> > JenkinsInternalAsync( CancellationToken cancellationToken = default ) { var _path = "/api/2018-03-14/jobs/jenkins"; var _query = new QueryBuilder(); 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 (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)); HandleFailedJenkinsRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <JenkinsResponse> { Request = _req, Response = _res, Body = Client.Deserialize <JenkinsResponse>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <ViewConfiguration> > GetRepositoriesInternalAsync( string vcb = default, CancellationToken cancellationToken = default ) { var _path = "/api/2019-06-17/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); if (!_res.IsSuccessStatusCode) { await OnGetRepositoriesFailed(_req, _res); } string _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); 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 <ContainerInformation> > > ListInternalAsync( bool?getSasTokens = default, CancellationToken cancellationToken = default ) { var _path = "/api/2019-06-17/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); if (!_res.IsSuccessStatusCode) { await OnListFailed(_req, _res); } string _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <IImmutableList <ContainerInformation> > { Request = _req, Response = _res, Body = Client.Deserialize <IImmutableList <ContainerInformation> >(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <ContainerInformation> > ExtendExpirationInternalAsync( ContainerExtensionRequest body, CancellationToken cancellationToken = default ) { if (body == default) { throw new ArgumentNullException(nameof(body)); } var _path = "/api/2018-03-14/storage/renew"; var _query = new QueryBuilder(); 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); string _requestContent = null; if (body != default) { _requestContent = Client.Serialize(body); _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)); HandleFailedExtendExpirationRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <ContainerInformation> { Request = _req, Response = _res, Body = Client.Deserialize <ContainerInformation>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse> SetReasonInternalAsync( string analysisName, string analysisType, FailureReason body, 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 (body == default) { throw new ArgumentNullException(nameof(body)); } if (string.IsNullOrEmpty(job)) { throw new ArgumentNullException(nameof(job)); } if (string.IsNullOrEmpty(workitem)) { throw new ArgumentNullException(nameof(workitem)); } var _path = "/api/2019-06-17/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 (body != default) { _requestContent = Client.Serialize(body); _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); if (!_res.IsSuccessStatusCode) { await OnSetReasonFailed(_req, _res); } string _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 <Newtonsoft.Json.Linq.JToken> > 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 <Newtonsoft.Json.Linq.JToken> { Request = _req, Response = _res, Body = Client.Deserialize <Newtonsoft.Json.Linq.JToken>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <JobCreationResult> > NewInternalAsync( JobCreationRequest body, string idempotencyKey, CancellationToken cancellationToken = default ) { if (body == default) { throw new ArgumentNullException(nameof(body)); } if (!body.IsValid) { throw new ArgumentException("The parameter is not valid", nameof(body)); } if (string.IsNullOrEmpty(idempotencyKey)) { throw new ArgumentNullException(nameof(idempotencyKey)); } var _path = "/api/2019-06-17/jobs"; var _query = new QueryBuilder(); 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(idempotencyKey)) { _req.Headers.Add("Idempotency-Key", idempotencyKey); } string _requestContent = null; if (body != default) { _requestContent = Client.Serialize(body); _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); if (!_res.IsSuccessStatusCode) { await OnNewFailed(_req, _res); } string _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <JobCreationResult> { Request = _req, Response = _res, Body = Client.Deserialize <JobCreationResult>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse> ErrorInternalAsync( string eid, string id, string xHelixJobToken, string logUri = default, string message = default, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(eid)) { throw new ArgumentNullException(nameof(eid)); } if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } if (string.IsNullOrEmpty(xHelixJobToken)) { throw new ArgumentNullException(nameof(xHelixJobToken)); } var _path = "/api/2018-03-14/telemetry/job/workitem/{id}/error"; _path = _path.Replace("{id}", Client.Serialize(id)); var _query = new QueryBuilder(); if (!string.IsNullOrEmpty(eid)) { _query.Add("eid", Client.Serialize(eid)); } if (!string.IsNullOrEmpty(message)) { _query.Add("message", Client.Serialize(message)); } if (!string.IsNullOrEmpty(logUri)) { _query.Add("logUri", Client.Serialize(logUri)); } 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), }; HandleFailedErrorRequest(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 <MachineInformation> > GetMachineStatusInternalAsync( string machineName, string queueId, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(machineName)) { throw new ArgumentNullException(nameof(machineName)); } if (string.IsNullOrEmpty(queueId)) { throw new ArgumentNullException(nameof(queueId)); } var _path = "/api/2018-03-14/machines/{queueId}/{machineName}/state"; _path = _path.Replace("{queueId}", Client.Serialize(queueId)); _path = _path.Replace("{machineName}", Client.Serialize(machineName)); var _query = new QueryBuilder(); 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)); HandleFailedGetMachineStatusRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <MachineInformation> { Request = _req, Response = _res, Body = Client.Deserialize <MachineInformation>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <ChangeStateResponse> > ChangeStateInternalAsync( string machineName, string queueId, MachineStateChangeRequest requestInfo, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(machineName)) { throw new ArgumentNullException(nameof(machineName)); } if (string.IsNullOrEmpty(queueId)) { throw new ArgumentNullException(nameof(queueId)); } if (requestInfo == default) { throw new ArgumentNullException(nameof(requestInfo)); } var _path = "/api/2018-03-14/machines/{queueId}/{machineName}/state"; _path = _path.Replace("{queueId}", Client.Serialize(queueId)); _path = _path.Replace("{machineName}", Client.Serialize(machineName)); var _query = new QueryBuilder(); 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 (requestInfo != default) { _requestContent = Client.Serialize(requestInfo); _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)); HandleFailedChangeStateRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <ChangeStateResponse> { Request = _req, Response = _res, Body = Client.Deserialize <ChangeStateResponse>(_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/2019-06-17/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); if (!_res.IsSuccessStatusCode) { await OnLogFailed(_req, _res); } string _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 <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/2019-06-17/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); if (!_res.IsSuccessStatusCode) { await OnStartXUnitWorkItemFailed(_req, _res); } string _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <string> { Request = _req, Response = _res, Body = Client.Deserialize <string>(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <JobCreationResult> > NewInternalAsync( JobCreationRequest newJob, CancellationToken cancellationToken = default ) { if (newJob == default) { throw new ArgumentNullException(nameof(newJob)); } if (!newJob.IsValid) { throw new ArgumentException("The parameter is not valid", nameof(newJob)); } var _path = "/api/2018-03-14/jobs"; var _query = new QueryBuilder(); 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); string _requestContent = null; if (newJob != default) { _requestContent = Client.Serialize(newJob); _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); var _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); if (!_res.IsSuccessStatusCode) { var ex = new RestApiException { Request = new HttpRequestMessageWrapper(_req, _requestContent), Response = new HttpResponseMessageWrapper(_res, _responseContent), }; HandleFailedNewRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } return(new HttpOperationResponse <JobCreationResult> { Request = _req, Response = _res, Body = Client.Deserialize <JobCreationResult>(_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); string _responseContent; if (!_res.IsSuccessStatusCode) { _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); var ex = new RestApiException( new HttpRequestMessageWrapper(_req, null), new HttpResponseMessageWrapper(_res, _responseContent)); HandleFailedGetDetailedVMScalingHistoryRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); 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 <IImmutableList <JobSummary> > > ListInternalAsync( int?count = default, string filterBuild = default, string filterCreator = default, string filterName = default, string filterSource = default, string filterType = default, CancellationToken cancellationToken = default ) { var _path = "/api/2019-06-17/jobs"; var _query = new QueryBuilder(); if (count != default) { _query.Add("count", Client.Serialize(count)); } if (!string.IsNullOrEmpty(filterCreator)) { _query.Add("filter.creator", Client.Serialize(filterCreator)); } if (!string.IsNullOrEmpty(filterSource)) { _query.Add("filter.source", Client.Serialize(filterSource)); } if (!string.IsNullOrEmpty(filterType)) { _query.Add("filter.type", Client.Serialize(filterType)); } if (!string.IsNullOrEmpty(filterBuild)) { _query.Add("filter.build", Client.Serialize(filterBuild)); } if (!string.IsNullOrEmpty(filterName)) { _query.Add("filter.name", Client.Serialize(filterName)); } 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); if (!_res.IsSuccessStatusCode) { await OnListFailed(_req, _res); } string _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false); return(new HttpOperationResponse <IImmutableList <JobSummary> > { Request = _req, Response = _res, Body = Client.Deserialize <IImmutableList <JobSummary> >(_responseContent), }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <System.IO.Stream> > ConsoleLogInternalAsync( string id, string job, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(id)) { throw new ArgumentNullException(nameof(id)); } if (string.IsNullOrEmpty(job)) { throw new ArgumentNullException(nameof(job)); } var _path = "/api/2018-03-14/jobs/{job}/workitems/{id}/console"; _path = _path.Replace("{job}", Client.Serialize(job)); _path = _path.Replace("{id}", Client.Serialize(id)); var _query = new QueryBuilder(); 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)); HandleFailedConsoleLogRequest(ex); HandleFailedRequest(ex); Client.OnFailedRequest(ex); throw ex; } var _responseStream = await _res.Content.ReadAsStreamAsync().ConfigureAwait(false); return(new HttpOperationResponse <System.IO.Stream> { Request = _req, Response = _res, Body = _responseStream }); } catch (Exception) { _req?.Dispose(); _res?.Dispose(); throw; } }
internal async Task <HttpOperationResponse <string> > StartBuildWorkItemInternalAsync( string buildUri, string xHelixJobToken, CancellationToken cancellationToken = default ) { if (string.IsNullOrEmpty(buildUri)) { throw new ArgumentNullException(nameof(buildUri)); } if (string.IsNullOrEmpty(xHelixJobToken)) { throw new ArgumentNullException(nameof(xHelixJobToken)); } var _path = "/api/2018-03-14/telemetry/job/build"; var _query = new QueryBuilder(); if (!string.IsNullOrEmpty(buildUri)) { _query.Add("buildUri", Client.Serialize(buildUri)); } 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), }; HandleFailedStartBuildWorkItemRequest(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; } }