Skip to main content

cloud_sdk/
lib.rs

1#![no_std]
2#![doc = include_str!("../README.md")]
3
4#[cfg(feature = "std")]
5extern crate std;
6
7pub mod action_polling;
8pub mod buffer;
9pub mod pagination;
10pub mod rate_limit;
11pub mod transport;
12
13/// Cloud provider namespace.
14#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub enum Provider {
16    /// Hetzner Cloud and DNS APIs.
17    Hetzner,
18}
19
20/// Provider API family.
21#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub enum ApiFamily {
23    /// Cloud infrastructure API.
24    Cloud,
25    /// DNS API.
26    Dns,
27    /// Security-related API resources.
28    Security,
29    /// Storage-related API resources.
30    Storage,
31    /// Provider-specific post-1.0 API surface.
32    Extended,
33}
34
35/// HTTP method for a provider operation.
36#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub enum Method {
38    /// GET request.
39    Get,
40    /// POST request.
41    Post,
42    /// PUT request.
43    Put,
44    /// DELETE request.
45    Delete,
46}
47
48impl Method {
49    /// Returns the HTTP method token.
50    #[must_use]
51    pub const fn as_str(self) -> &'static str {
52        match self {
53            Self::Get => "GET",
54            Self::Post => "POST",
55            Self::Put => "PUT",
56            Self::Delete => "DELETE",
57        }
58    }
59}
60
61#[cfg(test)]
62mod tests {
63    use super::{ApiFamily, Method, Provider};
64
65    #[test]
66    fn exposes_provider_neutral_domains() {
67        assert_eq!(Provider::Hetzner, Provider::Hetzner);
68        assert_eq!(ApiFamily::Cloud, ApiFamily::Cloud);
69        assert_eq!(Method::Get, Method::Get);
70        assert_eq!(Method::Post.as_str(), "POST");
71    }
72}