public async Task <string> SetOverrideAsync(DateTime start, DateTime end, PagerDutyPerson pdPerson) { var overrideData = new { @override = new { start, end, user_id = pdPerson.Id } }; var result = await PagerDutyApi.Instance.GetFromPagerDutyAsync("schedules/" + Id + "/overrides", getFromJson : response => response.ToString(), httpMethod : "POST", data : overrideData); PagerDutyApi.Instance.OnCallUsers.Poll(true); PagerDutyApi.Instance.PrimaryScheduleOverrides.Poll(true); return(result); }
public async Task<string> SetOverrideAsync(DateTime start, DateTime end, PagerDutyPerson pdPerson) { var overrideData = new { @override = new { start, end, user_id = pdPerson.Id } }; var result = await PagerDutyApi.Instance.GetFromPagerDutyAsync("schedules/" + Id + "/overrides", getFromJson: response => response.ToString(), httpMethod: "POST", data: overrideData); PagerDutyApi.Instance.OnCallUsers.Poll(true); PagerDutyApi.Instance.PrimaryScheduleOverrides.Poll(true); return result; }
public async Task <Incident> UpdateIncidentStatusAsync(string incidentId, PagerDutyPerson person, IncidentStatus newStatus) { if (person == null) { throw new ArgumentNullException(nameof(person)); } var data = new { incident = new { type = "incident_reference", status = newStatus.ToString() } }; var headers = new Dictionary <string, string> { ["From"] = person.Email }; try { var result = await Instance.GetFromPagerDutyAsync($"incidents/{incidentId}", response => JSON.Deserialize <PagerDutyIncidentUpdateResp>(response, JilOptions), httpMethod : "PUT", data : data, extraHeaders : headers).ConfigureAwait(false); await Incidents.PollAsync(true).ConfigureAwait(false); return(result?.Response ?? new Incident()); } catch (DeserializationException de) { Current.LogException( de.AddLoggedData("Message", de.Message) .AddLoggedData("Snippet After", de.SnippetAfterError) ); return(null); } }
public async Task<List<Incident>> UpdateIncidentStatusAsync(string incidentId, PagerDutyPerson person, IncidentStatus newStatus) { if (person == null) throw new ArgumentNullException(nameof(person)); var data = new PagerDutyIncidentPut { Incidents = new List<Incident> { new Incident {Id = incidentId, Status = newStatus} }, RequesterId = person.Id }; var result = await Instance.GetFromPagerDutyAsync("incidents", response => JSON.Deserialize<IncidentResponse>(response.ToString(), JilOptions), httpMethod: "PUT", data: data); Incidents.Poll(true); return result?.Incidents ?? new List<Incident>(); }
public async Task <string> SetOverrideAsync(DateTime start, DateTime end, PagerDutyPerson pdPerson) { var overrideData = new { @override = new { start, end, user = new { id = pdPerson.Id, type = "user_reference" } } }; var result = await PagerDutyAPI.Instance.GetFromPagerDutyAsync("schedules/" + Id + "/overrides", getFromJson : response => response, httpMethod : "POST", data : overrideData).ConfigureAwait(false); await PagerDutyAPI.Instance.OnCallInfo.PollAsync(true).ConfigureAwait(false); await PagerDutyAPI.Instance.PrimaryScheduleOverrides.PollAsync(true).ConfigureAwait(false); return(result); }
public async Task <List <Incident> > UpdateIncidentStatusAsync(string incidentId, PagerDutyPerson person, IncidentStatus newStatus) { if (person == null) { throw new ArgumentNullException(nameof(person)); } var data = new PagerDutyIncidentPut { Incidents = new List <Incident> { new Incident { Id = incidentId, Status = newStatus } }, RequesterId = person.Id }; var result = await Instance.GetFromPagerDutyAsync("incidents", response => JSON.Deserialize <IncidentResponse>(response.ToString(), JilOptions), httpMethod : "PUT", data : data); Incidents.Poll(true); return(result?.Incidents ?? new List <Incident>()); }