Praiya leverages the official PagerDuty OpenAPI swagger specification to generate models and mock server stubs, in order to closely match the real-world PagerDuty API behaviour. Praiya's async paradigm runs on Hyper and Tokio, tests are run against a Prism server that matches the OpenAPI specification responses.
Add the following to your Cargo.toml
file.
nocompile
[dependencies]
praiya = "0.1.0-rc1"
Praiya has currently implemented the following API endpoints:
A new Praiya
client takes the PagerDuty API token and will build an SSL context:
```rust praiya::Praiya::new("PAGERDUTY_TOKEN").expect("Unable to create PagerDuty client");
```
To list triggered and acknowledged incidents in your organisation:
```rust use praiya::ParamsBuilder;
use futures_util::TryStreamExt;
let pagerduty = praiya::Praiya::new("PAGERDUTY_TOKEN");
let mut optsbuilder = praiya::endpoints::incidents::IncidentsListIncidentsParamsBuilder::new(); optsbuilder.statuses(vec!["triggered", "acknowledged"]); let opts = opts_builder.build();
async move {
let incidents: Vec
Contributions are welcome, please observe the following advice.
Serialization stubs are generated through the Swagger library. To generate these files, use the following:
bash
mvn -D org.slf4j.simpleLogger.defaultLogLevel=debug compiler:compile generate-resources
The mock servers run with the Prism project against a forked branch of the official PagerDuty API schema, in order to maintain stability of the Praiya CI pipelines.
Mock servers are started with Docker Compose:
nocompile
docker-compose up -d
or alternatively use the npm library.
```nocompile npm install -g @stoplight/prism-cli
prism mock https://raw.githubusercontent.com/fussybeaver/pagerduty-api-schema/praiya-master/reference/REST/openapiv3.json ```
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
...
This README is generated with cargo-readme
rust
cargo readme --no-title > README.md
This software is licensed under the liberal Apache License 2.0
License: Apache-2.0