1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//! [](https://crates.io/crates/praiya)
//! [](https://opensource.org/licenses/Apache-2.0)
//! [](https://docs.rs/praiya/)
//! [](https://github.com/fussybeaver/praiya/actions/workflows/main.yml)
//!
//!
//! # Praiya: an async PagerDuty API for Rust
//!
//! Praiya leverages the official [PagerDuty OpenAPI swagger
//! specification](https://github.com/PagerDuty/api-schema) to generate models and mock server
//! stubs, in order to closely match the real-world [PagerDuty
//! API](https://developer.pagerduty.com/api-reference/) behaviour. Praiya's async paradigm runs on
//! [Hyper](https://github.com/hyperium/hyper) and [Tokio](https://github.com/tokio-rs/tokio),
//! tests are run against a [Prism](https://stoplight.io/open-source/prism) server that matches the
//! OpenAPI specification responses.
//!
//! # Install
//!
//! Add the following to your `Cargo.toml` file.
//!
//! ```nocompile
//! [dependencies]
//! praiya = "*"
//! ```
//!
//! # API
//! ## Documentation
//!
//! [API docs](https://docs.rs/praiya/)
//!
//! Praiya has currently implemented the following API endpoints:
//!
//! - [ ] abilities
//! - [ ] add_ons
//! - [ ] analytics
//! - [ ] audit
//! - [ ] business_services
//! - [X] escalation_policies
//! - [ ] extension_schemas
//! - [ ] extensions
//! - [X] incidents
//! - [ ] log_entries
//! - [ ] maintenance_windows
//! - [ ] notifications
//! - [X] on_calls
//! - [ ] priorities
//! - [ ] response_plays
//! - [ ] rulesets
//! - [X] schedules
//! - [ ] service_dependencies
//! - [X] services
//! - [X] slack_connections
//! - [ ] tags
//! - [ ] teams
//! - [X] users
//! - [ ] vendors
//!
//! # Usage
//!
//! ## Connecting to the PagerDuty API server
//!
//! A new `Praiya` client takes the PagerDuty API token and will build an SSL context:
//!
//! ```rust
//! praiya::Praiya::new("PAGERDUTY_TOKEN");
//!
//! ```
//!
//! ## Examples
//!
//! ### Listing incidents
//!
//! To list triggered and acknowledged incidents in your organisation:
//!
//! ```rust,no_run
//! use praiya::ParamsBuilder;
//!
//! use futures_util::TryStreamExt;
//!
//! let pagerduty = praiya::Praiya::new("PAGERDUTY_TOKEN");
//!
//! let mut opts_builder = praiya::endpoints::incidents::ListIncidentsParamsBuilder::new();
//! opts_builder.statuses(vec!["triggered", "acknowledged"]);
//! let opts = opts_builder.build();
//!
//! async move {
//! let incidents: Vec<praiya::models::Incident> = pagerduty
//! .incidents("from@example.com")
//! .list_incidents(opts)
//! .try_collect()
//! .await
//! .expect("Unable to list PagerDuty incidents");
//! };
//! ```
//!
//! # Development
//!
//! Contributions are welcome, please observe the following advice.
//!
//! ## Building the stubs
//!
//! Serialization stubs are generated through the [Swagger
//! library](https://github.com/swagger-api/swagger-codegen/). To generate these files, use the
//! following:
//!
//! ```bash
//! mvn -D org.slf4j.simpleLogger.defaultLogLevel=debug compiler:compile generate-resources
//! ```
//!
//! ## Mock test server
//!
//! The mock servers run with the [Prism](https://stoplight.io/open-source/prism) project against a
//! [forked branch](https://github.com/fussybeaver/pagerduty-api-schema/tree/praiya-master) of the
//! official PagerDuty API schema, in order to maintain stability of the Praiya CI pipelines.
//!
//! Mock servers are started with [Docker Compose](https://docs.docker.com/compose/):
//!
//! ```nocompile
//! docker-compose up -d
//! ```
//!
//! or alternatively use the npm library.
//!
//! ```nocompile
//! npm install -g @stoplight/prism-cli
//! # for example
//! prism mock https://raw.githubusercontent.com/fussybeaver/pagerduty-api-schema/praiya-master/reference/REST/openapiv3.json
//! ```
//!
//! ## Tests
//!
//! In order to run tests, point the client to the appropriate mock server:
//!
//! For the slack API:
//!
//! ```nocompile
//! env PAGERDUTY_API_ENDPOINT=http://127.0.0.1:8080 RUST_LOG=praiya=debug cargo test slack
//! ```
//!
//! For the default API's:
//!
//! ```nocompile
//! env PAGERDUTY_API_ENDPOINT=http://127.0.0.1:8081 RUST_LOG=praiya=debug cargo test incidents
//! env PAGERDUTY_API_ENDPOINT=http://127.0.0.1:8081 RUST_LOG=praiya=debug cargo test services
//! ...
//! ```
//!
//! ## Documentation
//!
//! This README is generated with [cargo-readme](https://github.com/livioribeiro/cargo-readme)
//!
//! ```nocompile
//! cargo readme --no-title > README.md
//! ```
//!
//! # License
//!
//! This software is licensed under the liberal [Apache License 2.0](https://opensource.org/licenses/Apache-2.0)
//!
extern crate serde_derive;
use HashMap;
pub use crate;
pub use crate;
pub use default_models as models;
pub use endpoints as api;