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
193
194
195
196
197
198
199
200
201
202
203
204
205
#![doc(html_root_url = "https://docs.rs/heroku_rs/0.4.1")]

//! # heroku_rs
//!
//! The `heroku_rs` crate provides convenient Rust bindings for the [Heroku V3 API][v3api].
//!
//! The heroku_rs [`HttpApiClient`][client] is blocking by deafult. 
//!
//! Additional examples:
//!
//! - [Heroku_rs repository examples](https://github.com/bensadiku/heroku_rs/tree/master/examples)
//!
//! 
//! ## Creating the Heroku [`HttpApiClient`][client]
//! 
//! The heroku client is build on top of [`reqwest`][reqwest] library. 
//! 
//! Creating the Heroku client only takes 1 line. This client has the default 30s http timeout and points to the production Heroku API. 
//! 
//! If you wish to custumize the http timeout or the base endpoint. See the Example 2 
//! 
//! # Example 1 - Creating a simple client
//! 
//! ```rust
//! use heroku_rs::framework::{apiclient::HerokuApiClient, HttpApiClient};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//!    let api_client = HttpApiClient::create("API_KEY")?;
//!   
//!    // You can start making requests here
//!    
//!    Ok(())
//! }
//! ```
//! In order to have a fully functional custom client you need to specify three things. [Credentials][credentials], [HttpApiClientConfig][httpApiClientConfig] and [ApiEnvironment][apiEnviroment]
//! 
//! # Example 2 - Creating a custom client
//! ```
//! use heroku_rs::framework::{
//! auth::Credentials,
//! apiclient::HerokuApiClient,
//! ApiEnvironment, HttpApiClient, HttpApiClientConfig,
//! };
//! 
//! use heroku_rs::endpoints::apps;
//! 
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! 
//!   let api_client = HttpApiClient::create("API_KEY")?;
//!   
//!   let response = api_client.request(&apps::AppList {});
//!   
//!   match response {
//!       Ok(success) => println!("Success: {:#?}", success),
//!       Err(e) => println!("Error: {}", e),
//!   }
//!   
//!   Ok(())
//! }
//! ```
//! ## Making a GET request to Heroku.
//! 
//!
//! This request returns a vector of [`app`][app]s, if successful.
//! 
//!
//! ```rust
//!use heroku_rs::framework::{apiclient::HerokuApiClient, HttpApiClient};
//!use heroku_rs::endpoints::apps;
//!
//!# fn main() -> Result<(), Box<dyn std::error::Error>> {
//!#
//!    let api_client = HttpApiClient::create("API_KEY")?;
//!
//!    let response = api_client.request(&apps::AppList {});
//!
//!    match response {
//!        Ok(success) => println!("Success: {:#?}", success),
//!        Err(e) => println!("Error: {}", e),
//!    }
//!#
//!#    Ok(())
//!# }
//! ```
//!
//! ## Making POST requests to Heroku.
//! 
//! 
//! Some POST requests do not need body paramers at all. 
//! 
//! This crate provides convinient parameter structs to inform you which endpoints take what parameters and which parameters are optional. 
//! 
//! If you can see the `params` parameter in this example, it takes three fields, all three are optional, matched from the Heroku documentation.
//! 
//! ```rust
//!use heroku_rs::framework::{apiclient::HerokuApiClient, HttpApiClient};
//!use heroku_rs::endpoints::apps;
//!
//!# fn main() -> Result<(), Box<dyn std::error::Error>> {
//!#
//!    let api_client = HttpApiClient::create("API_KEY")?;
//! 
//!    let app_name = String::from("FOO");
//! 
//!    let response = api_client.request(&apps::AppCreate {
//!        // This will create an app with the name name `FOO_APP`
//!        params: apps::AppCreateParams {
//!            name: Some(app_name),
//!            region: None,
//!            stack: None,
//!        },
//!    });
//!
//!    match response {
//!       Ok(success) => println!("Success: {:#?}", success),
//!       Err(e) => println!("Error: {}", e),
//!    }
//!#
//!# Ok(())
//!# }
//! ```
//! 
//! 
//! ## Making DELETE requests to Heroku.
//! 
//! 
//! Contraty to POST requests, DELETE requests do not need body parameters at all.
//! 
//! Some DELETE requests return a body on the response if successful, some do not.
//! 
//! 
//! ```rust
//!use heroku_rs::framework::{apiclient::HerokuApiClient, HttpApiClient};
//!use heroku_rs::endpoints::apps;
//!
//!# fn main() -> Result<(), Box<dyn std::error::Error>> {
//! 
//!    let api_client = HttpApiClient::create("API_KEY")?;
//! 
//!    let app_id = String::from("FOO");
//! 
//!    // This will delete the `FOO` app.
//!    let response = api_client.request(&apps::AppDelete { app_id });
//!
//!    match response {
//!       Ok(success) => println!("Success: {:#?}", success),
//!       Err(e) => println!("Error: {}", e),
//!    }
//!#
//!#   Ok(())
//!# }
//! ```
//! 
//! 
//! ## Making PATCH requests to Heroku.
//! 
//! 
//! Similar to POST requests, Some PATCH requests do not need body paramers. 
//! 
//! 
//! ```rust
//!use heroku_rs::framework::{apiclient::HerokuApiClient, HttpApiClient};
//!use heroku_rs::endpoints::apps;
//!
//!# fn main() -> Result<(), Box<dyn std::error::Error>> {
//!
//!    let api_client = HttpApiClient::create("API_KEY")?;
//!
//!    let app_id = String::from("FOO");
//! 
//!    // This will enable maintenance for the "FOO" app.
//!     let response = api_client.request(&apps::AppUpdate {
//!         app_id,
//!         params: apps::AppUpdateParams {
//!             build_stack: None,
//!             maintenance: Some(true),
//!             name: None,
//!         },
//!     });
//!
//!    match response {
//!       Ok(success) => println!("Success: {:#?}", success),
//!       Err(e) => println!("Error: {}", e),
//!    }
//!#
//!#   Ok(())
//!# }
//! ```
//! 
//! [reqwest]: https://github.com/seanmonstar/reqwest
//! [client]: framework/struct.HttpApiClient.html
//! [v3api]: https://devcenter.heroku.com/articles/platform-api-reference#
//! [app]: endpoints/apps/struct.App.html
//! [apiEnviroment]: framework/enum.ApiEnvironment.html
//! [httpApiClientConfig]: framework/struct.HttpApiClientConfig.html
//! [credentials]: framework/auth/enum.Credentials.html

extern crate chrono;
extern crate reqwest;
#[macro_use]
extern crate serde;
extern crate serde_json;

pub mod endpoints;
pub mod framework;