Skip to content

Commit

Permalink
Merge pull request #13 from bgpkit/feature/api-overhaul
Browse files Browse the repository at this point in the history
Major overhaul
  • Loading branch information
digizeph authored Dec 19, 2022
2 parents 493ed36 + 2db8da5 commit bcc792f
Show file tree
Hide file tree
Showing 6 changed files with 459 additions and 150 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bgpkit-broker"
version = "0.4.1"
version = "0.5.0"
edition = "2018"
authors = ["Mingwei Zhang <mingwei@bgpkit.com>"]
readme = "README.md"
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,44 @@
[twitter-badge]: https://shields.io/badge/Follow-lightgrey?logo=twitter&style=social
[twitter-url]: https://twitter.com/bgpkit

[BGPKIT](https://bgpkit.com) Broker is an online data API service that allows users to search for publicly available BGP archive
[BGPKIT Broker](https://bgpkit.com/broker) is an online data API service that allows users to search for publicly available BGP archive
files by time, collector, project, or data type. The service indexes the archives in close to real-time (delay is
less than 5 minutes). Currently, we are indexing BGP table dump and updates files from RIPE RIS and RouteViews.

This Rust library provides access to the BGPKIT Broker API with the capability to search and paginate results.

## Usage

Add the following dependency line to your project's `Cargo.toml` file:
```yaml
bgpkit-broker = "0.5"
```

## Example

```rust
use bgpkit_broker::{BgpkitBroker, BrokerItem, QueryParams};
You can run the follow example with `cargo run --example query` ([source code](./examples/query.rs)).

fn main() {

let broker = BgpkitBroker::new_with_params(
"https://api.broker.bgpkit.com/v2",
QueryParams{
ts_start: Some(1634693400),
ts_end: Some(1634693400),
page: 2,
..Default::default()
});
```rust
use bgpkit_broker::{BgpkitBroker, BrokerItem};

pub fn main() {
let broker = BgpkitBroker::new()
.ts_start("1634693400")
.ts_end("1634693400");

// method 1: create iterator from reference (so that you can reuse the broker object)
// same as `&broker.into_iter()`
for item in &broker {
println!("{:?}", item);
println!("{}", item);
}

// method 2: create iterator from the broker object (taking ownership)
let items = broker.into_iter().collect::<Vec<BrokerItem>>();

assert_eq!(items.len(), 106);
}

```


## Contribution

### Issues and Pull Requests
Expand Down
18 changes: 18 additions & 0 deletions examples/query.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use bgpkit_broker::{BgpkitBroker, BrokerItem};

pub fn main() {
let broker = BgpkitBroker::new()
.ts_start("1634693400")
.ts_end("1634693400");

// method 1: create iterator from reference (so that you can reuse the broker object)
// same as `&broker.into_iter()`
for item in &broker {
println!("{}", item);
}

// method 2: create iterator from the broker object (taking ownership)
let items = broker.into_iter().collect::<Vec<BrokerItem>>();

assert_eq!(items.len(), 106);
}
2 changes: 2 additions & 0 deletions src/latest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//! Queries BGPKIT Broker and get the latest MRT file meta data from all collectors
Loading

0 comments on commit bcc792f

Please sign in to comment.