heroku_rs/endpoints/apps/
mod.rs

1use crate::framework::response::ApiResult;
2use serde::Deserialize;
3
4pub mod delete;
5pub mod get;
6pub mod patch;
7pub mod post;
8pub mod put;
9
10pub use delete::{AppDelete, AppDisableAcm, AppWebhookDelete, SNIDelete, SSLDelete};
11pub use get::{
12    AccountAppList, AppDetails, AppFeatureDetails, AppFeatureList, AppList, AppSetupDetails,
13    AppWebhookDeliveryDetails, AppWebhookDeliveryList, AppWebhookDetails, AppWebhookList,
14    SNIDetails, SNIList, SSLDetails, SSLList, WebhookEventDetails, WebhookEventList,
15};
16pub use patch::{
17    AppFeatureUpdate, AppFeatureUpdateParams, AppRefreshAcm, AppUpdate, AppUpdateParams,
18    AppWebhookUpdate, AppWebhookUpdateParams, SNIUpdate, SNIUpdateParams, SSLUpdate,
19    SSLUpdateParams,
20};
21pub use post::{
22    AppCreate, AppCreateParams, AppEnableAcm, AppSetupCreate, AppSetupCreateParams,
23    AppWebhookCreate, AppWebhookCreateParams, SNICreate, SNICreateParams, SSLCreate,
24    SSLCreateParams,
25};
26
27impl ApiResult for App {}
28impl ApiResult for Vec<App> {}
29
30impl ApiResult for AppFeature {}
31impl ApiResult for Vec<AppFeature> {}
32
33impl ApiResult for AppWebhook {}
34impl ApiResult for Vec<AppWebhook> {}
35
36impl ApiResult for AppWebhookDelivery {}
37impl ApiResult for Vec<AppWebhookDelivery> {}
38
39impl ApiResult for AppSetup {}
40impl ApiResult for Vec<AppSetup> {}
41
42impl ApiResult for SNI {}
43impl ApiResult for Vec<SNI> {}
44
45impl ApiResult for SSL {}
46impl ApiResult for Vec<SSL> {}
47
48impl ApiResult for WebhookEvent {}
49impl ApiResult for Vec<WebhookEvent> {}
50
51pub use app_setup::AppSetup;
52pub use sni_endpoints::SNI;
53pub use ssl_endpoints::SSL;
54pub use webhook_event::WebhookEvent;
55
56/// Heroku App
57///
58/// Stability: production
59///
60/// An app represents the program that you would like to deploy and run on Heroku.
61///
62/// [See Heroku documentation for more information about this endpoint](https://devcenter.heroku.com/articles/platform-api-reference#app)
63#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
64pub struct App {
65    /// ACM status of this app
66    pub acm: bool,
67    /// when app was archived
68    pub archived_at: Option<String>,
69    /// description from buildpack of app
70    pub buildpack_provided_description: Option<String>,
71    /// Stacks are the different application execution environments available in the Heroku platform.
72    pub build_stack: BuildStack,
73    /// when app was created
74    pub created_at: String,
75    /// git repo URL of app
76    pub git_url: String,
77    /// unique identifier
78    pub id: String,
79    /// describes whether a Private Spaces app is externally routable or not
80    pub internal_routing: Option<bool>,
81    /// maintenance status of app
82    pub maintenance: bool,
83    /// name of app
84    pub name: String,
85    /// account owner
86    pub owner: Owner,
87    /// identity of team
88    pub organization: Option<Organization>,
89    /// identity of team
90    pub team: Option<Team>,
91    /// A region represents a geographic location in which your application may run.
92    pub region: Region,
93    /// when app was released
94    pub released_at: Option<String>,
95    /// git repo size in bytes of app
96    pub repo_size: Option<i64>,
97    /// slug size in bytes of app
98    pub slug_size: Option<i64>,
99    /// identity of space
100    pub space: Option<Space>,
101    /// Stacks are the different application execution environments available in the Heroku platform.
102    pub stack: Stack,
103    /// when app was updated
104    pub updated_at: String,
105    /// web URL of app
106    pub web_url: String,
107}
108
109/// BuildStack struct containing identifier of stack and stack name.
110#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
111pub struct BuildStack {
112    /// identifier of stack
113    pub id: String,
114    /// stack name
115    pub name: String,
116}
117
118/// Owner struct containing email and name or the account.
119#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
120pub struct Owner {
121    /// email of owner
122    pub email: String,
123    /// unique identifier of owner
124    pub id: String,
125}
126
127/// Organization struct containing id, name allows you to manage access to a shared group of applications and other resources.
128#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
129pub struct Organization {
130    /// unique identifier of organization
131    pub id: String,
132    /// unique identifier of organization
133    pub name: String,
134}
135
136/// Teams struct containing id, name allows you to manage access to a shared group of applications and other resources.
137#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
138pub struct Team {
139    /// unique identifier of team
140    pub id: String,
141    /// unique name of team
142    pub name: String,
143}
144
145/// Region struct containing id, name related to the geographic location in which your application may run.
146#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
147pub struct Region {
148    /// unique identifier
149    pub id: String,
150    /// name of region
151    pub name: String,
152}
153
154/// Space struct containing id, name and shield related to the app execution environment.
155#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
156pub struct Space {
157    /// unique identifier of space
158    pub id: String,
159    /// unique name of space
160    pub name: String,
161    /// true if this space has shield enabled
162    pub shield: bool,
163}
164
165/// Stacks are the different application execution environments available in the Heroku platform.
166#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
167pub struct Stack {
168    /// unique identifier
169    pub id: String,
170    /// name of stack
171    pub name: String,
172}
173
174/// App Feature
175///
176/// Stability: production
177///
178/// An app feature represents a Heroku labs capability that can be enabled or disabled for an app on Heroku.
179///
180/// [See Heroku documentation for more information about this endpoint](https://devcenter.heroku.com/articles/platform-api-reference#app-feature)
181///
182// TODO: (ben) inspect the nullable properties more. As of 20th March 2020, Heroku docs say that none of these properties can be nullable,
183//     but some are... and that's leading so an error decoding response body. e.g. invalid type: null, expected a string.
184#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
185pub struct AppFeature {
186    /// when app feature was created
187    pub created_at: String,
188    /// description of app feature
189    pub description: String,
190    /// documentation URL of app feature
191    pub doc_url: String,
192    /// whether or not app feature has been enabled
193    pub enabled: bool,
194    /// unique identifier of app feature
195    pub id: String,
196    /// unique name of app feature
197    pub name: String,
198    /// state of app feature
199    pub state: String,
200    /// when app feature was updated
201    pub updated_at: String,
202    /// user readable feature name
203    pub display_name: Option<String>,
204    /// e-mail to send feedback about the feature
205    pub feedback_email: Option<String>,
206}
207
208/// App Webhook
209///
210/// Stability: production
211///
212/// Represents the details of a webhook subscription
213///
214/// [See Heroku documentation for more information about this endpoint](https://devcenter.heroku.com/articles/platform-api-reference#app-webhook)
215#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
216pub struct AppWebhook {
217    /// the app that has the webhook
218    pub app: WebhookApp,
219    /// when app webhook was created
220    pub created_at: String,
221    /// unique identifier of app webhook
222    pub id: String,
223    /// the entities that the subscription provides notifications for
224    pub include: Vec<String>,
225    /// If notify, Heroku makes a single, fire-and-forget delivery attempt.
226    /// If sync, Heroku attempts multiple deliveries until the request is successful or a limit is reached.
227    /// one of: "notify" or "sync"
228    pub level: String,
229    /// when app webhook was updated
230    pub updated_at: String,
231    /// the URL where the webhook’s notification requests are sent
232    pub url: String,
233}
234
235/// WebhookApp
236#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
237pub struct WebhookApp {
238    /// unique identifier
239    pub id: String,
240    /// name of app
241    pub name: String,
242}
243
244/// App Webhook Delivery
245///
246/// Stability: production
247///
248/// Represents the delivery of a webhook notification, including its current status.
249///
250/// [See Heroku documentation for more information about this endpoint](https://devcenter.heroku.com/articles/platform-api-reference#app-webhook-delivery)
251#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
252pub struct AppWebhookDelivery {
253    /// when the delivery was created
254    pub created_at: String,
255    /// the event’s struct containing
256    pub event: WebhookDeliveryEvent,
257    /// the delivery’s unique identifier
258    pub id: String,
259    /// number of times a delivery has been attempted
260    pub num_attempts: i64,
261    /// when delivery will be attempted again
262    pub next_attempt_at: Option<String>,
263    /// last attempt of a delivery
264    pub last_attempt: Option<WebhookDeliveryLastAttempt>,
265    /// the delivery’s status one of:"pending" or "scheduled" or "retrying" or "failed" or "succeeded"
266    pub status: String,
267    /// when the delivery was last updated
268    pub updated_at: String,
269    /// the webhook which we get the deliveries for
270    pub webhook: WebhookDeliveryWebhook,
271}
272
273/// WebhookDeliveryEvent
274#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
275pub struct WebhookDeliveryEvent {
276    /// the event’s unique identifier
277    pub id: String,
278    /// the type of entity that the event is related to
279    pub include: String,
280}
281
282/// WebhookDeliveryLastAttempt
283#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
284pub struct WebhookDeliveryLastAttempt {
285    /// unique identifier of attempt
286    pub id: String,
287    /// http response code received during attempt
288    pub code: Option<i64>,
289    /// error class encountered during attempt
290    pub error_class: Option<String>,
291    /// status of an attempt. One of:"scheduled" or "succeeded" or "failed"
292    pub status: String,
293    /// when attempt was created
294    pub created_at: String,
295    /// when attempt was updated
296    pub updated_at: String,
297}
298
299/// WebhookDeliveryWebhook
300#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
301pub struct WebhookDeliveryWebhook {
302    /// the webhook’s unique identifier
303    pub id: String,
304    /// If notify, Heroku makes a single, fire-and-forget delivery attempt.
305    /// If sync, Heroku attempts multiple deliveries until the request is successful or a limit is reached.
306    /// One of:"notify" or "sync"
307    pub level: String,
308}
309
310mod app_setup {
311    use chrono::offset::Utc;
312    use chrono::DateTime;
313
314    /// App Setup
315    ///
316    /// Stability: production
317    ///
318    /// An app setup represents an app on Heroku that is setup using an environment, addons, and scripts described in an app.json manifest file.
319    ///
320    /// [See Heroku documentation for more information about this endpoint](https://devcenter.heroku.com/articles/platform-api-reference#app-setup)
321    ///
322    // TODO: (ben) inspect the nullable properties more. As of 20th March 2020, Heroku docs say that none of these properties can be nullable,
323    //     but some are... and that's leading so an error decoding response body. e.g. invalid type: null, expected a string.
324    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
325    pub struct AppSetup {
326        /// unique identifier of app setup
327        pub id: String,
328        /// when app setup was created
329        pub created_at: DateTime<Utc>,
330        /// when app setup was updated
331        pub updated_at: DateTime<Utc>,
332        /// the overall status of app setup
333        ///  one of:"failed" or "pending" or "succeeded"
334        pub status: String,
335        /// reason that app setup has failed
336        pub failure_message: Option<String>,
337        /// app
338        pub app: App,
339        /// identity and status of build
340        pub build: Option<Build>,
341        /// errors associated with invalid app.json manifest file
342        pub manifest_errors: Vec<String>,
343        /// result of postdeploy script
344        pub postdeploy: Option<Postdeploy>,
345        /// fully qualified success url
346        pub resolved_success_url: Option<String>,
347    }
348
349    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
350    pub struct App {
351        /// unique identifier
352        pub id: String,
353        /// name of app
354        ///  pattern: ^[a-z][a-z0-9-]{1,28}[a-z0-9]$
355        pub name: String,
356    }
357
358    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
359    pub struct Build {
360        /// unique identifier of build
361        pub id: String,
362        /// status of build
363        ///  one of:"failed" or "pending" or "succeeded"
364        pub status: String,
365        /// Build process output will be available from this URL as a stream. The stream is available as either text/plain or text/event-stream.
366        /// Clients should be prepared to handle disconnects and can resume the stream by sending a Range header (for text/plain) or a Last-Event-Id header (for text/event-stream).
367        pub output_stream_url: String,
368    }
369
370    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
371    pub struct Postdeploy {
372        /// output of the postdeploy script
373        pub output: String,
374        /// The exit code of the postdeploy script
375        pub exit_code: i64,
376    }
377}
378
379mod sni_endpoints {
380    use chrono::offset::Utc;
381    use chrono::DateTime;
382
383    /// SNI Endpoint
384    ///
385    /// Stability: development
386    ///
387    /// SNI Endpoint is a public address serving a custom SSL cert for HTTPS traffic, using the SNI TLS extension, to a Heroku app.
388    ///
389    /// [See Heroku documentation for more information about this endpoint](https://devcenter.heroku.com/articles/platform-api-reference#sni-endpoint)
390    #[derive(Deserialize, Serialize, Debug, Clone)]
391    pub struct SNI {
392        /// raw contents of the public certificate chain (eg: .crt or .pem file)
393        pub certificate_chain: String,
394        /// deprecated; refer to GET /apps/:id/domains for valid CNAMEs for this app
395        pub cname: String,
396        /// when endpoint was created
397        pub created_at: DateTime<Utc>,
398        /// unique identifier of this SNI endpoint
399        pub id: String,
400        /// unique name for SNI endpoint
401        ///  pattern: ^[a-z][a-z0-9-]{2,29}$
402        pub name: String,
403        /// when SNI endpoint was updated
404        pub updated_at: DateTime<Utc>,
405    }
406}
407
408mod ssl_endpoints {
409    use chrono::offset::Utc;
410    use chrono::DateTime;
411
412    /// SNI Endpoint
413    ///
414    /// Stability: development
415    ///
416    /// SNI Endpoint is a public address serving a custom SSL cert for HTTPS traffic, using the SNI TLS extension, to a Heroku app.
417    ///
418    /// [See Heroku documentation for more information about this endpoint](https://devcenter.heroku.com/articles/platform-api-reference#sni-endpoint)
419    #[derive(Deserialize, Serialize, Debug, Clone)]
420    pub struct SSL {
421        /// app
422        pub app: App,
423        /// raw contents of the public certificate chain (eg: .crt or .pem file)
424        pub certificate_chain: String,
425        /// canonical name record, the address to point a domain at
426        pub cname: String,
427        /// when endpoint was created
428        pub created_at: DateTime<Utc>,
429        /// unique identifier of this SSL endpoint
430        pub id: String,
431        /// unique name for SSL endpoint
432        ///  pattern: ^[a-z][a-z0-9-]{2,29}$
433        pub name: String,
434        /// when endpoint was updated
435        pub updated_at: DateTime<Utc>,
436    }
437    #[derive(Deserialize, Serialize, Debug, Clone)]
438    pub struct App {
439        /// unique identifier
440        pub id: String,
441        /// name of app
442        ///  pattern: ^[a-z][a-z0-9-]{1,28}[a-z0-9]$
443        pub name: String,
444    }
445}
446
447mod webhook_event {
448    use chrono::offset::Utc;
449    use chrono::DateTime;
450    use serde_json::Value;
451
452    /// App Webhook Event
453    ///
454    /// Stability: production
455    ///
456    /// Represents a webhook event that occurred.
457    ///
458    /// [See Heroku documentation for more information about this endpoint](https://devcenter.heroku.com/articles/platform-api-reference#app-webhook-event)
459    #[derive(Deserialize, Serialize, Debug, Clone)]
460    pub struct WebhookEvent {
461        /// when event was created
462        pub created_at: DateTime<Utc>,
463        /// the event’s unique identifier
464        pub id: String,
465        /// the type of entity that the event is related to
466        pub include: String,
467        /// the type of event that occurred
468        pub payload: Payload,
469        /// when the event was last updated
470        pub updated_at: DateTime<Utc>,
471    }
472
473    #[derive(Deserialize, Serialize, Debug, Clone)]
474    pub struct Payload {
475        /// the type of event that occurred
476        pub action: String,
477        /// payload actor
478        pub actor: Actor,
479        /// the current details of the event
480        pub data: Value,
481        /// previous details of the event (if any)
482        pub previous_data: Value,
483        /// the type of resource associated with the event
484        pub resource: String,
485        /// the version of the details provided for the event
486        pub version: String,
487    }
488
489    #[derive(Deserialize, Serialize, Debug, Clone)]
490    pub struct Actor {
491        /// unique email address
492        pub email: String,
493        /// identifier of an account
494        pub id: String,
495    }
496}