PagerDuty 0.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package PagerDuty --version 0.0.0
NuGet\Install-Package PagerDuty -Version 0.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PagerDuty" Version="0.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PagerDuty --version 0.0.0
#r "nuget: PagerDuty, 0.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PagerDuty as a Cake Addin
#addin nuget:?package=PagerDuty&version=0.0.0

// Install PagerDuty as a Cake Tool
#tool nuget:?package=PagerDuty&version=0.0.0

PagerDuty

Client that sends Alert and Change events to the PagerDuty Events API V2

Prerequisites

Installation

You can install this library into your project from NuGet Gallery using any of the following techniques.

  • dotnet add package PagerDuty
  • Install-Package PagerDuty
  • Project › Manage NuGet Packages… in Visual Studio

Usage

Configuration

  1. Create an Integration in PagerDuty and get its Integration Key.
    1. Sign into your PagerDuty account.
    2. Go to Services › Service Directory.
    3. Select an existing Service for which you want to publish events, or create a new Service.
    4. In the Integrations tab of the Service, add a new Integration.
    5. Under Most popular integrations, select Events API V2, then click Add.
    6. Expand the newly-created Integration and copy its Integration Key, which will be used to authorize this library to send Events to the correct Service.
    7. Optionally, you can also rename the Integration to make it more recognizable.
  2. Construct a new PagerDuty API client instance in your project, passing your Integration Key as a constructor parameter.
    IPagerDuty pagerDuty = new PagerDuty(integrationKey: "dfca74ebb7450b3e6da3ba6083a323f4");
    

Triggering an Alert

Construct a new TriggerAlert instance with the required parameters, and pass it to the IPagerDuty.Send(Alert) method. This returns an AlertResponse.

AlertResponse alert = await pagerDuty.Send(new TriggerAlert(Severity.Error, "Summary of Alert"));

You can specify optional parameters with an object initializer or assignments.

var trigger = new TriggerAlert(Severity.Warning, "My summary") {
    Class = "my class",
    Component = "my component",
    Group = "my group",
    Links = { new Link("https://aldaviva.com/", "Aldaviva") },
    Images = { new Image("https://aldaviva.com/avatars/ben.jpg", "https://aldaviva.com/", "Ben Hutchison") },
    CustomDetails = new {
        A = 1,
        B = "2"
    }
};
trigger.Source = "my source";
trigger.Timestamp = DateTimeOffset.Now;

If a key in your CustomDetails object isn't a valid identifier in C#, for example if it contains spaces, you can also use an IDictionary<string, object>, or any other type that can be serialized into JSON.

trigger.CustomDetails = new Dictionary<string, object> {
    { "key 1", "value 1" },
    { "key 2", "value 2" },
};

Acknowledging an Alert

This is the same as triggering an Alert, except you construct an AcknowledgeAlert and set its DedupKey to the value in the AlertResponse from the prior TriggerAlert, which identifies the specific Alert to acknowledge.

await pagerDuty.Send(new AcknowledgeAlert(alert.DedupKey));

Resolving an Alert

This is the same as acknowledging an Alert, but with ResolveAlert.

await pagerDuty.Send(new ResolveAlert(alert.DedupKey));

Creating a change

You can also create Changes in additon to Alerts.

await pagerDuty.Send(new Change("Summary of Change"));

Cleaning up

PagerDuty contains an HttpClient, so when you're done with the instance, call Dispose() to clean it up and allow the HttpClient to be garbage collected.

pagerDuty.Dispose();

References

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 963 11/13/2023
1.0.0 80 11/12/2023
0.0.1 745 6/8/2022
0.0.0 373 6/5/2022