protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetIncidentRequest request;

            try
            {
                request = new GetIncidentRequest
                {
                    IncidentKey  = IncidentKey,
                    Csi          = Csi,
                    Ocid         = Ocid,
                    OpcRequestId = OpcRequestId,
                    Homeregion   = Homeregion,
                    ProblemType  = ProblemType
                };

                response = client.GetIncident(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Incident);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
예제 #2
0
        public async Task Handle_WhenIncidentClientReturnsSuccessful_ReturnCorrectIncident()
        {
            long   expectedIncidentId    = 1;
            string expectedIncidentTitle = "Customers are unable to access [REDACTED] from [REDACTED]";
            var    expectedIncident      = new Incident
            {
                Id    = expectedIncidentId,
                Title = expectedIncidentTitle
            };
            var serviceUnderTest = new GetIncidentHandler(
                await MockFactory.IncidentContext("Get").ConfigureAwait(continueOnCapturedContext: false),
                new NoConnector(new NoClient(), new StubLoggerFactory()));
            var request = new GetIncidentRequest(
                expectedIncidentId,
                new DummyAuthenticatedUserContext());


            var result = await serviceUnderTest
                         .Handle(request, new System.Threading.CancellationToken())
                         .ConfigureAwait(continueOnCapturedContext: false);


            Assert.AreEqual(expectedIncidentId, result.Id);
            Assert.AreEqual(expectedIncidentTitle, result.Title);
        }
예제 #3
0
        /// <summary>
        /// Gets the details of the support ticket.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public GetIncidentResponse GetIncident(GetIncidentRequest request)
        {
            var uri = new Uri($"{GetEndPoint(SupportManagementServices.Incidents, this.Region)}/{request.IncidentKey}");

            var headers = new HttpRequestHeaderParam()
            {
                OpcRequestId = request.OpcRequestId
            };

            headers.FreeHeader.Add("csi", request.Csi);
            headers.FreeHeader.Add("ocid", request.Ocid);
            if (!string.IsNullOrEmpty(request.Homeregion))
            {
                headers.FreeHeader.Add("homeregion", request.Homeregion);
            }
            using (var webResponse = this.RestClient.Get(uri, headers))
                using (var stream = webResponse.GetResponseStream())
                    using (var reader = new StreamReader(stream))
                    {
                        var response = reader.ReadToEnd();

                        return(new GetIncidentResponse()
                        {
                            Incident = this.JsonSerializer.Deserialize <IncidentDetails>(response),
                            OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                            ETag = webResponse.Headers.Get("ETag")
                        });
                    }
        }
예제 #4
0
        /// <summary>
        /// This API fetches the details of a requested Incident
        /// </summary>
        /// <param name="request">The request object containing the details to send. Required.</param>
        /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
        /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
        /// <returns>A response object containing details about the completed operation</returns>
        public async Task <GetIncidentResponse> GetIncident(GetIncidentRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called getIncident");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/v2/incidents/{incidentKey}".Trim('/')));
            HttpMethod         method         = new HttpMethod("Get");
            HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);

            requestMessage.Headers.Add("Accept", "application/json");
            GenericRetrier      retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
            HttpResponseMessage responseMessage;

            try
            {
                if (retryingClient != null)
                {
                    responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage);
                }

                return(Converter.FromHttpResponseMessage <GetIncidentResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"GetIncident failed with error: {e.Message}");
                throw;
            }
        }
        public GetIncidentResponse GetIncident(GetIncidentRequest objGetIncidentRequest)
        {
            LogHelper.LogTextDebug("", "Enter");
            LogHelper.LogObjectPropertiesDebug(objGetIncidentRequest, "IncidentRequest");
            Incident objIncident = null;

            try
            {
                GetIncidentResponse objGetIncidentResponse = null;
                if (string.IsNullOrEmpty(objGetIncidentRequest.IncidentNumber))
                {
                    throw new CustomError("NullData", "Incident Number is null");
                }
                else
                {
                    objIncident            = new IncidentController().GetIncident(objIncident.IncidentNumber);
                    objGetIncidentResponse = new TranslateIncident().TranslateIncidenttoGetIncidentResponse(objIncident);
                }
                LogHelper.LogTextDebug("Success", "Returning Incident Response");
                return(objGetIncidentResponse);
            }
            catch (ITSM_WebserviceException ex)
            {
                LogHelper.LogTextWarn(string.Format("Message : {0}\nError : {1}\nStack Trace : {2}", ex.Message, ex.ErrorCode, ex.StackTrace), "Exception");
                throw ITSMExceptionManager.GetCustomSoapException(ex);
            }
            catch (Exception ex)
            {
                LogHelper.LogTextWarn(string.Format("Message : {0}\nStack Trace : {2}", ex.Message, ex.StackTrace), "Exception");
                throw ITSMExceptionManager.GetCustomSoapException("Unknown Error", ex.Message);
            }
        }