Skip to main content

outscale_api/apis/
internet_service_api.rs

1/*
2 * 3DS OUTSCALE API
3 *
4 * Welcome to the OUTSCALE API documentation.<br /> The OUTSCALE API enables you to manage your resources in the OUTSCALE Cloud. This documentation describes the different actions available along with code examples.<br /><br /> Throttling: To protect against overloads, the number of identical requests allowed in a given time period is limited.<br /> Brute force: To protect against brute force attacks, the number of failed authentication attempts in a given time period is limited.<br /><br /> Note that the OUTSCALE Cloud is compatible with Amazon Web Services (AWS) APIs, but there are [differences in resource names](https://docs.outscale.com/en/userguide/About-the-APIs.html) between AWS and the OUTSCALE API.<br /> You can also manage your resources using the [Cockpit](https://docs.outscale.com/en/userguide/About-Cockpit.html) web interface.<br /><br /> An OpenAPI description of this API is also available for download: <button>[GitHub repository](https://github.com/outscale/osc-api)</button><br /> # Authentication Schemes ### Access Key/Secret Key The main way to authenticate your requests to the OUTSCALE API is to use an access key and a secret key.<br /> The mechanism behind this is based on AWS Signature Version 4, whose technical implementation details are described in [Signature of API Requests](https://docs.outscale.com/en/userguide/Signature-of-API-Requests.html).<br /><br /> In practice, the way to specify your access key and secret key depends on the tool or SDK you want to use to interact with the API.<br />  > For example, if you use OSC CLI: > 1. You need to create an **~/.osc/config.json** file to specify your access key, secret key, and the Region of your account. > 2. You then specify the `--profile` option when executing OSC CLI commands. > > For more information, see [Installing and Configuring OSC CLI](https://docs.outscale.com/en/userguide/Installing-and-Configuring-OSC-CLI.html).  See the code samples in each section of this documentation for specific examples in different programming languages.<br /> For more information about access keys, see [About Access Keys](https://docs.outscale.com/en/userguide/About-Access-Keys.html).  > If you try to sign requests with an invalid access key four times in a row, further authentication attempts will be prevented for 1 minute. This lockout time increases 1 minute every four failed attempts, for up to 10 minutes.  ### Login/Password For certain API actions, you can also use basic authentication with the login (email address) and password of your TINA account.<br /> This is useful only in special circumstances, for example if you do not know your access key/secret key and want to retrieve them programmatically.<br /> In most cases, however, you can use the Cockpit web interface to retrieve them.<br />  > For example, if you use OSC CLI: > 1. You need to create an **~/.osc/config.json** file to specify the Region of your account, but you leave the access key value and secret key value empty (`&quot;&quot;`). > 2. You then specify the `--profile`, `--authentication-method`, `--login`, and `--password` options when executing OSC CLI commands.  See the code samples in each section of this documentation for specific examples in different programming languages.  > If you try to sign requests with an invalid password four times in a row, further authentication attempts will be prevented for 1 minute. This lockout time increases 1 minute every four failed attempts, for up to 10 minutes.  ### No Authentication A few API actions do not require any authentication. They are indicated as such in this documentation.<br /> ### Other Security Mechanisms In parallel with the authentication schemes, you can add other security mechanisms to your OUTSCALE account, for example to restrict API requests by IP or other criteria.<br /> For more information, see [Managing Your API Accesses](https://docs.outscale.com/en/userguide/Managing-Your-API-Accesses.html). # Pagination Tutorial You can learn more about the pagination methods for read calls in the dedicated [pagination tutorial](https://docs.outscale.com/en/userguide/Tutorial-Paginating-an-API-Request.html). # Error Codes Reference You can learn more about errors returned by the API in the dedicated [errors page](api-errors.html).
5 *
6 * The version of the OpenAPI document: 1.39.1
7 * Contact: support@outscale.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, Error};
12use crate::apis::ResponseContent;
13
14/// struct for typed errors of method [`create_internet_service`]
15#[derive(Debug, Clone, Serialize, Deserialize)]
16#[serde(untagged)]
17pub enum CreateInternetServiceError {
18    Status400(crate::models::ErrorResponse),
19    Status401(crate::models::ErrorResponse),
20    Status500(crate::models::ErrorResponse),
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`delete_internet_service`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum DeleteInternetServiceError {
28    Status400(crate::models::ErrorResponse),
29    Status401(crate::models::ErrorResponse),
30    Status500(crate::models::ErrorResponse),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`link_internet_service`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum LinkInternetServiceError {
38    Status400(crate::models::ErrorResponse),
39    Status401(crate::models::ErrorResponse),
40    Status500(crate::models::ErrorResponse),
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`read_internet_services`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum ReadInternetServicesError {
48    Status400(crate::models::ErrorResponse),
49    Status401(crate::models::ErrorResponse),
50    Status500(crate::models::ErrorResponse),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`unlink_internet_service`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum UnlinkInternetServiceError {
58    Status400(crate::models::ErrorResponse),
59    Status401(crate::models::ErrorResponse),
60    Status500(crate::models::ErrorResponse),
61    UnknownValue(serde_json::Value),
62}
63
64/// Creates an internet service you can use with a Net.<br /> An internet service enables virtual machines (VMs) launched in a Net to connect to the Internet. It allows routing of incoming and outgoing Internet traffic and management of public IPs.<br /><br /> For more information, see [About Internet Services](https://docs.outscale.com/en/userguide/About-Internet-Services.html).
65pub fn create_internet_service(
66    configuration: &configuration::Configuration,
67    create_internet_service_request: Option<crate::models::CreateInternetServiceRequest>,
68) -> Result<crate::models::CreateInternetServiceResponse, Error<CreateInternetServiceError>> {
69    let local_var_configuration = configuration;
70
71    let local_var_client = &local_var_configuration.client;
72
73    let local_var_uri_str = format!(
74        "{}/CreateInternetService",
75        local_var_configuration.base_path
76    );
77    let mut local_var_req_builder =
78        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
79
80    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
81        let local_var_new_headers = match local_var_aws_v4_key.sign(
82            &local_var_uri_str,
83            "POST",
84            &serde_json::to_string(&create_internet_service_request)
85                .expect("param should serialize to string"),
86        ) {
87            Ok(new_headers) => new_headers,
88            Err(err) => return Err(Error::AWSV4SignatureError(err)),
89        };
90        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
91            local_var_req_builder =
92                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
93        }
94    }
95    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
96        local_var_req_builder =
97            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
98    }
99    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
100        let local_var_key = local_var_apikey.key.clone();
101        let local_var_value = match local_var_apikey.prefix {
102            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
103            None => local_var_key,
104        };
105        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
106    };
107    local_var_req_builder = local_var_req_builder.json(&create_internet_service_request);
108
109    let local_var_req = local_var_req_builder.build()?;
110    let local_var_resp = local_var_client.execute(local_var_req)?;
111
112    let local_var_status = local_var_resp.status();
113    let local_var_content = local_var_resp.text()?;
114
115    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
116        serde_json::from_str(&local_var_content).map_err(Error::from)
117    } else {
118        let local_var_entity: Option<CreateInternetServiceError> =
119            serde_json::from_str(&local_var_content).ok();
120        let local_var_error = ResponseContent {
121            status: local_var_status,
122            content: local_var_content,
123            entity: local_var_entity,
124        };
125        Err(Error::ResponseError(local_var_error))
126    }
127}
128
129/// Deletes an internet service.<br /> Before deleting an internet service, you must detach it from any Net it is attached to.
130pub fn delete_internet_service(
131    configuration: &configuration::Configuration,
132    delete_internet_service_request: Option<crate::models::DeleteInternetServiceRequest>,
133) -> Result<crate::models::DeleteInternetServiceResponse, Error<DeleteInternetServiceError>> {
134    let local_var_configuration = configuration;
135
136    let local_var_client = &local_var_configuration.client;
137
138    let local_var_uri_str = format!(
139        "{}/DeleteInternetService",
140        local_var_configuration.base_path
141    );
142    let mut local_var_req_builder =
143        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
144
145    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
146        let local_var_new_headers = match local_var_aws_v4_key.sign(
147            &local_var_uri_str,
148            "POST",
149            &serde_json::to_string(&delete_internet_service_request)
150                .expect("param should serialize to string"),
151        ) {
152            Ok(new_headers) => new_headers,
153            Err(err) => return Err(Error::AWSV4SignatureError(err)),
154        };
155        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
156            local_var_req_builder =
157                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
158        }
159    }
160    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
161        local_var_req_builder =
162            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
163    }
164    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
165        let local_var_key = local_var_apikey.key.clone();
166        let local_var_value = match local_var_apikey.prefix {
167            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
168            None => local_var_key,
169        };
170        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
171    };
172    local_var_req_builder = local_var_req_builder.json(&delete_internet_service_request);
173
174    let local_var_req = local_var_req_builder.build()?;
175    let local_var_resp = local_var_client.execute(local_var_req)?;
176
177    let local_var_status = local_var_resp.status();
178    let local_var_content = local_var_resp.text()?;
179
180    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
181        serde_json::from_str(&local_var_content).map_err(Error::from)
182    } else {
183        let local_var_entity: Option<DeleteInternetServiceError> =
184            serde_json::from_str(&local_var_content).ok();
185        let local_var_error = ResponseContent {
186            status: local_var_status,
187            content: local_var_content,
188            entity: local_var_entity,
189        };
190        Err(Error::ResponseError(local_var_error))
191    }
192}
193
194/// Attaches an internet service to a Net.<br /> To enable the connection between the Internet and a Net, you must attach an internet service to this Net.
195pub fn link_internet_service(
196    configuration: &configuration::Configuration,
197    link_internet_service_request: Option<crate::models::LinkInternetServiceRequest>,
198) -> Result<crate::models::LinkInternetServiceResponse, Error<LinkInternetServiceError>> {
199    let local_var_configuration = configuration;
200
201    let local_var_client = &local_var_configuration.client;
202
203    let local_var_uri_str = format!("{}/LinkInternetService", local_var_configuration.base_path);
204    let mut local_var_req_builder =
205        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
206
207    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
208        let local_var_new_headers = match local_var_aws_v4_key.sign(
209            &local_var_uri_str,
210            "POST",
211            &serde_json::to_string(&link_internet_service_request)
212                .expect("param should serialize to string"),
213        ) {
214            Ok(new_headers) => new_headers,
215            Err(err) => return Err(Error::AWSV4SignatureError(err)),
216        };
217        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
218            local_var_req_builder =
219                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
220        }
221    }
222    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
223        local_var_req_builder =
224            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
225    }
226    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
227        let local_var_key = local_var_apikey.key.clone();
228        let local_var_value = match local_var_apikey.prefix {
229            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
230            None => local_var_key,
231        };
232        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
233    };
234    local_var_req_builder = local_var_req_builder.json(&link_internet_service_request);
235
236    let local_var_req = local_var_req_builder.build()?;
237    let local_var_resp = local_var_client.execute(local_var_req)?;
238
239    let local_var_status = local_var_resp.status();
240    let local_var_content = local_var_resp.text()?;
241
242    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
243        serde_json::from_str(&local_var_content).map_err(Error::from)
244    } else {
245        let local_var_entity: Option<LinkInternetServiceError> =
246            serde_json::from_str(&local_var_content).ok();
247        let local_var_error = ResponseContent {
248            status: local_var_status,
249            content: local_var_content,
250            entity: local_var_entity,
251        };
252        Err(Error::ResponseError(local_var_error))
253    }
254}
255
256/// Lists one or more of your internet services.<br /> An internet service enables virtual machines (VMs) launched in a Net to connect to the Internet. It allows the routing of incoming and outgoing Internet traffic and management of public IPs.
257pub fn read_internet_services(
258    configuration: &configuration::Configuration,
259    read_internet_services_request: Option<crate::models::ReadInternetServicesRequest>,
260) -> Result<crate::models::ReadInternetServicesResponse, Error<ReadInternetServicesError>> {
261    let local_var_configuration = configuration;
262
263    let local_var_client = &local_var_configuration.client;
264
265    let local_var_uri_str = format!("{}/ReadInternetServices", local_var_configuration.base_path);
266    let mut local_var_req_builder =
267        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
268
269    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
270        let local_var_new_headers = match local_var_aws_v4_key.sign(
271            &local_var_uri_str,
272            "POST",
273            &serde_json::to_string(&read_internet_services_request)
274                .expect("param should serialize to string"),
275        ) {
276            Ok(new_headers) => new_headers,
277            Err(err) => return Err(Error::AWSV4SignatureError(err)),
278        };
279        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
280            local_var_req_builder =
281                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
282        }
283    }
284    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
285        local_var_req_builder =
286            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
287    }
288    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
289        let local_var_key = local_var_apikey.key.clone();
290        let local_var_value = match local_var_apikey.prefix {
291            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
292            None => local_var_key,
293        };
294        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
295    };
296    local_var_req_builder = local_var_req_builder.json(&read_internet_services_request);
297
298    let local_var_req = local_var_req_builder.build()?;
299    let local_var_resp = local_var_client.execute(local_var_req)?;
300
301    let local_var_status = local_var_resp.status();
302    let local_var_content = local_var_resp.text()?;
303
304    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
305        serde_json::from_str(&local_var_content).map_err(Error::from)
306    } else {
307        let local_var_entity: Option<ReadInternetServicesError> =
308            serde_json::from_str(&local_var_content).ok();
309        let local_var_error = ResponseContent {
310            status: local_var_status,
311            content: local_var_content,
312            entity: local_var_entity,
313        };
314        Err(Error::ResponseError(local_var_error))
315    }
316}
317
318/// Detaches an internet service from a Net.<br /> This action disables and detaches an internet service from a Net. The Net must not contain virtual machines (VMs) using public IPs nor internet-facing load balancers.
319pub fn unlink_internet_service(
320    configuration: &configuration::Configuration,
321    unlink_internet_service_request: Option<crate::models::UnlinkInternetServiceRequest>,
322) -> Result<crate::models::UnlinkInternetServiceResponse, Error<UnlinkInternetServiceError>> {
323    let local_var_configuration = configuration;
324
325    let local_var_client = &local_var_configuration.client;
326
327    let local_var_uri_str = format!(
328        "{}/UnlinkInternetService",
329        local_var_configuration.base_path
330    );
331    let mut local_var_req_builder =
332        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
333
334    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
335        let local_var_new_headers = match local_var_aws_v4_key.sign(
336            &local_var_uri_str,
337            "POST",
338            &serde_json::to_string(&unlink_internet_service_request)
339                .expect("param should serialize to string"),
340        ) {
341            Ok(new_headers) => new_headers,
342            Err(err) => return Err(Error::AWSV4SignatureError(err)),
343        };
344        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
345            local_var_req_builder =
346                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
347        }
348    }
349    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
350        local_var_req_builder =
351            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
352    }
353    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
354        let local_var_key = local_var_apikey.key.clone();
355        let local_var_value = match local_var_apikey.prefix {
356            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
357            None => local_var_key,
358        };
359        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
360    };
361    local_var_req_builder = local_var_req_builder.json(&unlink_internet_service_request);
362
363    let local_var_req = local_var_req_builder.build()?;
364    let local_var_resp = local_var_client.execute(local_var_req)?;
365
366    let local_var_status = local_var_resp.status();
367    let local_var_content = local_var_resp.text()?;
368
369    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
370        serde_json::from_str(&local_var_content).map_err(Error::from)
371    } else {
372        let local_var_entity: Option<UnlinkInternetServiceError> =
373            serde_json::from_str(&local_var_content).ok();
374        let local_var_error = ResponseContent {
375            status: local_var_status,
376            content: local_var_content,
377            entity: local_var_entity,
378        };
379        Err(Error::ResponseError(local_var_error))
380    }
381}