Beispiel #1
0
        internal async Task <HttpOperationResponse <string> > StartJobInternalAsync(
            JobInfo info,
            CancellationToken cancellationToken = default
            )
        {
            if (info == default)
            {
                throw new ArgumentNullException(nameof(info));
            }

            if (!info.IsValid)
            {
                throw new ArgumentException("The parameter is not valid", nameof(info));
            }


            var _path = "/api/2018-03-14/telemetry/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.Post, _url);

                string _requestContent = null;
                if (info != default)
                {
                    _requestContent = Client.Serialize(info);
                    _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),
                    };
                    HandleFailedStartJobRequest(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;
            }
        }
Beispiel #2
0
 partial void HandleFailedWarningRequest(RestApiException ex);
Beispiel #3
0
 partial void HandleFailedLogRequest(RestApiException ex);
Beispiel #4
0
        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;
            }
        }
Beispiel #5
0
 partial void HandleFailedStartBuildWorkItemRequest(RestApiException ex);
Beispiel #6
0
 partial void HandleFailedChangeStateRequest(RestApiException ex);
Beispiel #7
0
        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;
            }
        }
Beispiel #8
0
 partial void HandleFailedMultiSourceRequest(RestApiException ex);
Beispiel #9
0
 partial void HandleFailedAnalysisSummaryRequest(RestApiException ex);
Beispiel #10
0
        internal async Task <HttpOperationResponse <QueueInfo> > QueueInfoInternalAsync(
            string queueId,
            CancellationToken cancellationToken = default
            )
        {
            if (string.IsNullOrEmpty(queueId))
            {
                throw new ArgumentNullException(nameof(queueId));
            }


            var _path = "/api/2018-03-14/info/queues/{queueId}";

            _path = _path.Replace("{queueId}", Client.Serialize(queueId));

            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));
                    HandleFailedQueueInfoRequest(ex);
                    HandleFailedRequest(ex);
                    Client.OnFailedRequest(ex);
                    throw ex;
                }
                _responseContent = await _res.Content.ReadAsStringAsync().ConfigureAwait(false);

                return(new HttpOperationResponse <QueueInfo>
                {
                    Request = _req,
                    Response = _res,
                    Body = Client.Deserialize <QueueInfo>(_responseContent),
                });
            }
            catch (Exception)
            {
                _req?.Dispose();
                _res?.Dispose();
                throw;
            }
        }
Beispiel #11
0
 partial void HandleFailedHistoryRequest(RestApiException ex);
Beispiel #12
0
 partial void HandleFailedQueueInfoRequest(RestApiException ex);
Beispiel #13
0
        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;
            }
        }
Beispiel #14
0
        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;
            }
        }
Beispiel #15
0
 partial void HandleFailedSetReasonRequest(RestApiException ex);
Beispiel #16
0
 partial void HandleFailedBuildRequest(RestApiException ex);
Beispiel #17
0
 partial void HandleFailedGetMachineStatusRequest(RestApiException ex);
Beispiel #18
0
 partial void HandleFailedJobSummaryRequest(RestApiException ex);
Beispiel #19
0
 partial void HandleFailedGetRepositoriesRequest(RestApiException ex);
Beispiel #20
0
 partial void HandleFailedWorkItemSummaryRequest(RestApiException ex);
Beispiel #21
0
 partial void HandleFailedGetDetailedVMScalingHistoryRequest(RestApiException ex);
Beispiel #22
0
 partial void HandleFailedAnalysisDetailRequest(RestApiException ex);
Beispiel #23
0
 internal void OnFailedRequest(RestApiException ex)
 {
     HandleFailedRequest(ex);
 }
Beispiel #24
0
 partial void HandleFailedPropertiesRequest(RestApiException ex);
Beispiel #25
0
 partial void HandleFailedFinishXUnitWorkItemRequest(RestApiException ex);
Beispiel #26
0
 partial void HandleFailedInvestigation_ContinueRequest(RestApiException ex);
Beispiel #27
0
 partial void HandleFailedErrorRequest(RestApiException ex);
Beispiel #28
0
 partial void HandleFailedGetDetailsRequest(RestApiException ex);
Beispiel #29
0
 partial void HandleFailedStartJobRequest(RestApiException ex);
Beispiel #30
0
 partial void HandleFailedExtendExpirationRequest(RestApiException ex);