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
//! [`BumpClient`](struct.BumpClient.html) is the main entry point for this library.
//!
//! Library created with [`libninja`](https://www.libninja.com).
#![allow(non_camel_case_types)]
#![allow(unused)]
pub mod model;
pub mod request;
use crate::model::*;

pub struct BumpClient {
    pub(crate) client: httpclient::Client,
    authentication: Option<BumpAuthentication>,
}
impl BumpClient {
    pub fn from_env() -> Self {
        let url = std::env::var("BUMP_BASE_URL")
            .expect("Missing environment variable BUMP_BASE_URL");
        Self::new(&url)
    }
}
impl BumpClient {
    pub fn new(url: &str) -> Self {
        let client = httpclient::Client::new(Some(url.to_string()));
        let authentication = None;
        Self { client, authentication }
    }
    pub fn with_authentication(mut self, authentication: BumpAuthentication) -> Self {
        self.authentication = Some(authentication);
        self
    }
    pub fn authenticate<'a>(
        &self,
        mut r: httpclient::RequestBuilder<'a>,
    ) -> httpclient::RequestBuilder<'a> {
        if let Some(ref authentication) = self.authentication {
            match authentication {
                BumpAuthentication::AuthorizationToken { authorization_token } => {
                    r = r.token_auth(authorization_token);
                }
                BumpAuthentication::BasicToken { basic_token } => {
                    r = r.basic_auth(basic_token);
                }
            }
        }
        r
    }
    pub fn with_middleware<M: httpclient::Middleware + 'static>(
        mut self,
        middleware: M,
    ) -> Self {
        self.client = self.client.with_middleware(middleware);
        self
    }
    /**Create a diff

Create a diff between any two given API definitions.
The diff result will be available asynchronously and needs to be retrieved with the [`GET /diffs/:id` API endpoint](#operation-get-diffs-parameter).
*/
    pub fn post_diffs(&self) -> request::PostDiffsRequest {
        request::PostDiffsRequest {
            client: &self,
            url: None,
            previous_url: None,
            previous_definition: None,
            previous_references: None,
            definition: None,
            references: None,
            expires_at: None,
        }
    }
    /**Fetch detailed information from an existing diff

Fetch the result of a previously created diff with the [`POST /diffs` API endpoint](#operation-post-diffs).
*/
    pub fn get_diffs_by_id(&self, id: &str) -> request::GetDiffsByIdRequest {
        request::GetDiffsByIdRequest {
            client: &self,
            id: id.to_owned(),
            formats: None,
        }
    }
    /**Fetch information of an existing Hub

Fetch information of an existing Hub including the list of APIs it contains. The response follows the [APIs.json specification](http://apisjson.org/)
*/
    pub fn get_hubs_by_hub_id_or_slug(
        &self,
        hub_id_or_slug: &str,
    ) -> request::GetHubsByHubIdOrSlugRequest {
        request::GetHubsByHubIdOrSlugRequest {
            client: &self,
            hub_id_or_slug: hub_id_or_slug.to_owned(),
        }
    }
    /**Create a new version

Deploy a new version for a given documentation, which will become the current version.
*/
    pub fn post_versions(
        &self,
        args: request::PostVersionsRequired,
    ) -> request::PostVersionsRequest {
        request::PostVersionsRequest {
            client: &self,
            documentation: args.documentation.to_owned(),
            hub: args.hub.to_owned(),
            documentation_name: args.documentation_name.to_owned(),
            auto_create_documentation: args.auto_create_documentation,
            definition: args.definition.to_owned(),
            references: args.references,
            branch_name: args.branch_name.to_owned(),
            previous_version_id: args.previous_version_id.to_owned(),
            unpublished: args.unpublished,
        }
    }
    /**Validate a documentation definition

Validate a definition against its schema (OpenAPI or AsyncAPI) and return errors without creating a new version. This is useful in a CI process, to validate that a changed definition file is valid and won't fail when being deployed on Bump.
*/
    pub fn post_validations(
        &self,
        args: request::PostValidationsRequired,
    ) -> request::PostValidationsRequest {
        request::PostValidationsRequest {
            client: &self,
            documentation: args.documentation.to_owned(),
            hub: args.hub.to_owned(),
            documentation_name: args.documentation_name.to_owned(),
            auto_create_documentation: args.auto_create_documentation,
            url: args.url.to_owned(),
            definition: args.definition.to_owned(),
            references: args.references,
        }
    }
    /**Create a preview

Create a preview for a given documentation file. The preview will have a unique temporary URL, and will be active for 30 minutes.
*/
    pub fn post_previews(&self, definition: &str) -> request::PostPreviewsRequest {
        request::PostPreviewsRequest {
            client: &self,
            definition: definition.to_owned(),
            references: None,
        }
    }
    /**Update an existing preview

Update a preview with the given documentation file. The preview will stay active for 30 minutes after the last update.
*/
    pub fn put_previews_by_preview_id(
        &self,
        preview_id: &str,
        definition: &str,
    ) -> request::PutPreviewsByPreviewIdRequest {
        request::PutPreviewsByPreviewIdRequest {
            client: &self,
            preview_id: preview_id.to_owned(),
            definition: definition.to_owned(),
            references: None,
        }
    }
    /**Fetch a full documentation version including diff summary

Fetch a full documentation version including diff summary.
*/
    pub fn get_versions_by_version_id(
        &self,
        version_id: &str,
    ) -> request::GetVersionsByVersionIdRequest {
        request::GetVersionsByVersionIdRequest {
            client: &self,
            version_id: version_id.to_owned(),
        }
    }
    /**Check the API status

Responds a pong if the API is up and running.*/
    pub fn get_ping(&self) -> request::GetPingRequest {
        request::GetPingRequest {
            client: &self,
        }
    }
}
pub enum BumpAuthentication {
    AuthorizationToken { authorization_token: String },
    BasicToken { basic_token: String },
}
impl BumpAuthentication {
    pub fn from_env() -> Self {
        Self::AuthorizationToken {
            authorization_token: std::env::var("BUMP_AUTHORIZATION_TOKEN")
                .expect("Environment variable BUMP_AUTHORIZATION_TOKEN is not set."),
        }
    }
}