Skip to main content

outscale_api/apis/
net_peering_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 OUTSCALE 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.40.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 [`accept_net_peering`]
15#[derive(Debug, Clone, Serialize, Deserialize)]
16#[serde(untagged)]
17pub enum AcceptNetPeeringError {
18    Status400(crate::models::ErrorResponse),
19    Status401(crate::models::ErrorResponse),
20    Status409(crate::models::ErrorResponse),
21    Status500(crate::models::ErrorResponse),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`create_net_peering`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateNetPeeringError {
29    Status400(crate::models::ErrorResponse),
30    Status401(crate::models::ErrorResponse),
31    Status500(crate::models::ErrorResponse),
32    UnknownValue(serde_json::Value),
33}
34
35/// struct for typed errors of method [`delete_net_peering`]
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum DeleteNetPeeringError {
39    Status400(crate::models::ErrorResponse),
40    Status401(crate::models::ErrorResponse),
41    Status409(crate::models::ErrorResponse),
42    Status500(crate::models::ErrorResponse),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`read_net_peerings`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ReadNetPeeringsError {
50    Status400(crate::models::ErrorResponse),
51    Status401(crate::models::ErrorResponse),
52    Status500(crate::models::ErrorResponse),
53    UnknownValue(serde_json::Value),
54}
55
56/// struct for typed errors of method [`reject_net_peering`]
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum RejectNetPeeringError {
60    Status400(crate::models::ErrorResponse),
61    Status401(crate::models::ErrorResponse),
62    Status409(crate::models::ErrorResponse),
63    Status500(crate::models::ErrorResponse),
64    UnknownValue(serde_json::Value),
65}
66
67/// Accepts a Net peering request.<br /> To accept this request, you must be the owner of the peer Net. If you do not accept the request within 7 days, the state of the Net peering becomes `expired`.<br /><br />  **[NOTE]**<br /> A peering connection between two Nets works both ways. Therefore, when an A-to-B peering connection is accepted, any pending B-to-A peering connection is automatically rejected as redundant.
68pub fn accept_net_peering(
69    configuration: &configuration::Configuration,
70    accept_net_peering_request: Option<crate::models::AcceptNetPeeringRequest>,
71) -> Result<crate::models::AcceptNetPeeringResponse, Error<AcceptNetPeeringError>> {
72    let local_var_configuration = configuration;
73
74    let local_var_client = &local_var_configuration.client;
75
76    let local_var_uri_str = format!("{}/AcceptNetPeering", local_var_configuration.base_path);
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(&accept_net_peering_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(&accept_net_peering_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<AcceptNetPeeringError> =
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/// Requests a Net peering between a Net you own and a peer Net that belongs to you or another OUTSCALE account.<br /> This action creates a Net peering that remains in the `pending-acceptance` state until it is accepted by the owner of the peer Net. If the owner of the peer Net does not accept the request within 7 days, the state of the Net peering becomes `expired`. For more information, see [AcceptNetPeering](#acceptnetpeering).<br /><br />  **[IMPORTANT]**<br /> * The two Nets must not have overlapping IP ranges. Otherwise, the Net peering is in the `failed` state.<br /> * A peering connection between two Nets works both ways. If an A-to-B connection is already created and accepted, creating a B-to-A connection is not necessary and would be automatically rejected.  For more information, see [About Net Peerings](https://docs.outscale.com/en/userguide/About-Net-Peerings.html).
130pub fn create_net_peering(
131    configuration: &configuration::Configuration,
132    create_net_peering_request: Option<crate::models::CreateNetPeeringRequest>,
133) -> Result<crate::models::CreateNetPeeringResponse, Error<CreateNetPeeringError>> {
134    let local_var_configuration = configuration;
135
136    let local_var_client = &local_var_configuration.client;
137
138    let local_var_uri_str = format!("{}/CreateNetPeering", local_var_configuration.base_path);
139    let mut local_var_req_builder =
140        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
141
142    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
143        let local_var_new_headers = match local_var_aws_v4_key.sign(
144            &local_var_uri_str,
145            "POST",
146            &serde_json::to_string(&create_net_peering_request)
147                .expect("param should serialize to string"),
148        ) {
149            Ok(new_headers) => new_headers,
150            Err(err) => return Err(Error::AWSV4SignatureError(err)),
151        };
152        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
153            local_var_req_builder =
154                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
155        }
156    }
157    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
158        local_var_req_builder =
159            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
160    }
161    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
162        let local_var_key = local_var_apikey.key.clone();
163        let local_var_value = match local_var_apikey.prefix {
164            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
165            None => local_var_key,
166        };
167        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
168    };
169    local_var_req_builder = local_var_req_builder.json(&create_net_peering_request);
170
171    let local_var_req = local_var_req_builder.build()?;
172    let local_var_resp = local_var_client.execute(local_var_req)?;
173
174    let local_var_status = local_var_resp.status();
175    let local_var_content = local_var_resp.text()?;
176
177    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
178        serde_json::from_str(&local_var_content).map_err(Error::from)
179    } else {
180        let local_var_entity: Option<CreateNetPeeringError> =
181            serde_json::from_str(&local_var_content).ok();
182        let local_var_error = ResponseContent {
183            status: local_var_status,
184            content: local_var_content,
185            entity: local_var_entity,
186        };
187        Err(Error::ResponseError(local_var_error))
188    }
189}
190
191/// Deletes a Net peering.<br /> If the Net peering is in the `active` state, it can be deleted either by the owner of the requester Net or the owner of the peer Net.<br /> If it is in the `pending-acceptance` state, it can be deleted only by the owner of the requester Net.<br /> If it is in the `rejected`, `failed`, or `expired` states, it cannot be deleted.
192pub fn delete_net_peering(
193    configuration: &configuration::Configuration,
194    delete_net_peering_request: Option<crate::models::DeleteNetPeeringRequest>,
195) -> Result<crate::models::DeleteNetPeeringResponse, Error<DeleteNetPeeringError>> {
196    let local_var_configuration = configuration;
197
198    let local_var_client = &local_var_configuration.client;
199
200    let local_var_uri_str = format!("{}/DeleteNetPeering", local_var_configuration.base_path);
201    let mut local_var_req_builder =
202        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
203
204    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
205        let local_var_new_headers = match local_var_aws_v4_key.sign(
206            &local_var_uri_str,
207            "POST",
208            &serde_json::to_string(&delete_net_peering_request)
209                .expect("param should serialize to string"),
210        ) {
211            Ok(new_headers) => new_headers,
212            Err(err) => return Err(Error::AWSV4SignatureError(err)),
213        };
214        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
215            local_var_req_builder =
216                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
217        }
218    }
219    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
220        local_var_req_builder =
221            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
222    }
223    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
224        let local_var_key = local_var_apikey.key.clone();
225        let local_var_value = match local_var_apikey.prefix {
226            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
227            None => local_var_key,
228        };
229        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
230    };
231    local_var_req_builder = local_var_req_builder.json(&delete_net_peering_request);
232
233    let local_var_req = local_var_req_builder.build()?;
234    let local_var_resp = local_var_client.execute(local_var_req)?;
235
236    let local_var_status = local_var_resp.status();
237    let local_var_content = local_var_resp.text()?;
238
239    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
240        serde_json::from_str(&local_var_content).map_err(Error::from)
241    } else {
242        let local_var_entity: Option<DeleteNetPeeringError> =
243            serde_json::from_str(&local_var_content).ok();
244        let local_var_error = ResponseContent {
245            status: local_var_status,
246            content: local_var_content,
247            entity: local_var_entity,
248        };
249        Err(Error::ResponseError(local_var_error))
250    }
251}
252
253/// Lists one or more peering connections between two Nets.
254pub fn read_net_peerings(
255    configuration: &configuration::Configuration,
256    read_net_peerings_request: Option<crate::models::ReadNetPeeringsRequest>,
257) -> Result<crate::models::ReadNetPeeringsResponse, Error<ReadNetPeeringsError>> {
258    let local_var_configuration = configuration;
259
260    let local_var_client = &local_var_configuration.client;
261
262    let local_var_uri_str = format!("{}/ReadNetPeerings", local_var_configuration.base_path);
263    let mut local_var_req_builder =
264        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
265
266    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
267        let local_var_new_headers = match local_var_aws_v4_key.sign(
268            &local_var_uri_str,
269            "POST",
270            &serde_json::to_string(&read_net_peerings_request)
271                .expect("param should serialize to string"),
272        ) {
273            Ok(new_headers) => new_headers,
274            Err(err) => return Err(Error::AWSV4SignatureError(err)),
275        };
276        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
277            local_var_req_builder =
278                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
279        }
280    }
281    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
282        local_var_req_builder =
283            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
284    }
285    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
286        let local_var_key = local_var_apikey.key.clone();
287        let local_var_value = match local_var_apikey.prefix {
288            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
289            None => local_var_key,
290        };
291        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
292    };
293    local_var_req_builder = local_var_req_builder.json(&read_net_peerings_request);
294
295    let local_var_req = local_var_req_builder.build()?;
296    let local_var_resp = local_var_client.execute(local_var_req)?;
297
298    let local_var_status = local_var_resp.status();
299    let local_var_content = local_var_resp.text()?;
300
301    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
302        serde_json::from_str(&local_var_content).map_err(Error::from)
303    } else {
304        let local_var_entity: Option<ReadNetPeeringsError> =
305            serde_json::from_str(&local_var_content).ok();
306        let local_var_error = ResponseContent {
307            status: local_var_status,
308            content: local_var_content,
309            entity: local_var_entity,
310        };
311        Err(Error::ResponseError(local_var_error))
312    }
313}
314
315/// Rejects a Net peering request.<br /> The Net peering must be in the `pending-acceptance` state to be rejected. The rejected Net peering is then in the `rejected` state.
316pub fn reject_net_peering(
317    configuration: &configuration::Configuration,
318    reject_net_peering_request: Option<crate::models::RejectNetPeeringRequest>,
319) -> Result<crate::models::RejectNetPeeringResponse, Error<RejectNetPeeringError>> {
320    let local_var_configuration = configuration;
321
322    let local_var_client = &local_var_configuration.client;
323
324    let local_var_uri_str = format!("{}/RejectNetPeering", local_var_configuration.base_path);
325    let mut local_var_req_builder =
326        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
327
328    if let Some(ref local_var_aws_v4_key) = local_var_configuration.aws_v4_key {
329        let local_var_new_headers = match local_var_aws_v4_key.sign(
330            &local_var_uri_str,
331            "POST",
332            &serde_json::to_string(&reject_net_peering_request)
333                .expect("param should serialize to string"),
334        ) {
335            Ok(new_headers) => new_headers,
336            Err(err) => return Err(Error::AWSV4SignatureError(err)),
337        };
338        for (local_var_name, local_var_value) in local_var_new_headers.iter() {
339            local_var_req_builder =
340                local_var_req_builder.header(local_var_name.as_str(), local_var_value.as_str());
341        }
342    }
343    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
344        local_var_req_builder =
345            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
346    }
347    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
348        let local_var_key = local_var_apikey.key.clone();
349        let local_var_value = match local_var_apikey.prefix {
350            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
351            None => local_var_key,
352        };
353        local_var_req_builder = local_var_req_builder.header("Authorization", local_var_value);
354    };
355    local_var_req_builder = local_var_req_builder.json(&reject_net_peering_request);
356
357    let local_var_req = local_var_req_builder.build()?;
358    let local_var_resp = local_var_client.execute(local_var_req)?;
359
360    let local_var_status = local_var_resp.status();
361    let local_var_content = local_var_resp.text()?;
362
363    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
364        serde_json::from_str(&local_var_content).map_err(Error::from)
365    } else {
366        let local_var_entity: Option<RejectNetPeeringError> =
367            serde_json::from_str(&local_var_content).ok();
368        let local_var_error = ResponseContent {
369            status: local_var_status,
370            content: local_var_content,
371            entity: local_var_entity,
372        };
373        Err(Error::ResponseError(local_var_error))
374    }
375}