public void CloseIfStillOpen()
        {
            var config = GetPagerDutyConfig();
            var subject = "[IPHost] 'Parkmobile NL Web02 on web02-nl.parkmobile.com' - 'ok'";
            var api = new IntegrationApi(config);

            var incidents = api.GetOpenIncidents();

            var incident = incidents.FirstOrDefault(i => i.trigger_summary_data != null
                           && i.trigger_summary_data.IndexOf("IPHOST", StringComparison.OrdinalIgnoreCase) >= 0);

            if (incident != null)
            {
                var resolveEvent = new ResolveEvent(new IncidentEvent
                {
                    incident_key = incident.incident_key
                }, subject);

                var resResponse = api.Resolve(resolveEvent);

                Assert.IsTrue(resResponse.IsOk(), "Incident should be resolved");

            }
            else
            {
                //none open
            }
        }
        public void RaiseIfNotKnown()
        {
            var config = GetPagerDutyConfig();
            var subject = "[IPHost] 'Parkmobile NL Web02 on web02-nl.parkmobile.com' - 'down'";
            var api = new IntegrationApi(config);

            var incidents = api.GetOpenIncidents();

            var incident = incidents.FirstOrDefault(i => i.trigger_summary_data != null
                           && i.trigger_summary_data.IndexOf("IPHOST", StringComparison.OrdinalIgnoreCase) >= 0 );

            if (incident == null)
            {
                //raise new
                var newIncident = new IncidentEvent
                {
                    client = "IPHost",
                    description = subject,
                    incident_key = Guid.NewGuid().ToString(),
                    service_key = config.EventAuthToken,
                };

                var response = api.Trigger(newIncident);

                Assert.IsTrue(response.IsOk(), "Incident should be created");
            }
            else
            {
                //already known, keep on going
            }
        }
        public void GetOpenIndicidents()
        {
            var api = new IntegrationApi(GetPagerDutyConfig());

            var incidents = api.GetOpenIncidents();
            Assert.IsNotNull(incidents);
        }