Skip to content

Commit

Permalink
feat(compute): add missing fields to public API
Browse files Browse the repository at this point in the history
Also comment out some fields I don't want to expose just yet.
  • Loading branch information
dtantsur committed Apr 5, 2024
1 parent 318cba3 commit e76c99d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
10 changes: 10 additions & 0 deletions src/compute/flavors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ impl Flavor {
Flavor::new(session, inner).await
}

/// Flavor description
pub fn description(&self) -> &Option<String> {
&self.inner.description
}

/// Get ephemeral disk size in GiB.
///
/// Returns `0` when ephemeral disk was not requested.
Expand Down Expand Up @@ -108,6 +113,11 @@ impl Flavor {
self.inner.ram
}

/// Get receive/transmit factor.
pub fn rxtx_factor(&self) -> f32 {
self.inner.rxtx_factor
}

/// Get root disk size in GiB.
pub fn root_size(&self) -> u64 {
self.inner.disk
Expand Down
5 changes: 5 additions & 0 deletions src/compute/keypairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ impl KeyPair {
#[doc = "Key pair name."]
name: ref String
}

transparent_property! {
#[doc = "Public key."]
public_key: ref String
}
}

#[async_trait]
Expand Down
4 changes: 2 additions & 2 deletions src/compute/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ pub struct Server {
pub status: ServerStatus,
#[serde(rename = "OS-EXT-STS:power_state", default)]
pub power_state: ServerPowerState,
pub tenant_id: String,
// pub tenant_id: String,
#[serde(rename = "updated")]
pub updated_at: DateTime<FixedOffset>,
pub user_id: String,
// pub user_id: String,
}

#[derive(Clone, Debug, Deserialize)]
Expand Down
7 changes: 2 additions & 5 deletions src/image/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
#![allow(missing_docs)]

use chrono::{DateTime, FixedOffset};
use reqwest::Url;
use serde::Deserialize;

use super::super::common;

protocol_enum! {
#[doc = "Possible image statuses."]
enum ImageStatus {
Expand Down Expand Up @@ -102,8 +99,8 @@ pub struct Image {
#[serde(default)]
pub container_format: Option<ImageContainerFormat>,
pub created_at: DateTime<FixedOffset>,
#[serde(deserialize_with = "common::protocol::deser_optional_url", default)]
pub direct_url: Option<Url>,
// #[serde(deserialize_with = "common::protocol::deser_optional_url", default)]
// pub direct_url: Option<Url>,
#[serde(default)]
pub disk_format: Option<ImageDiskFormat>,
pub id: String,
Expand Down
2 changes: 2 additions & 0 deletions src/network/networks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ impl Network {
status: protocol::NetworkStatus
}

// TODO(dtantsur): subnets

transparent_property! {
#[doc = "Last update data and time (if available)."]
updated_at: Option<DateTime<FixedOffset>>
Expand Down
6 changes: 3 additions & 3 deletions src/network/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ pub struct Network {
pub shared: bool,
#[serde(skip_serializing)]
pub status: NetworkStatus,
#[serde(skip_serializing)]
pub subnets: Vec<String>,
// #[serde(skip_serializing)]
// pub subnets: Vec<String>,
#[serde(default, skip_serializing)]
pub updated_at: Option<DateTime<FixedOffset>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand All @@ -221,7 +221,7 @@ impl Default for Network {
project_id: None,
shared: false,
status: NetworkStatus::Active,
subnets: Vec::new(),
// subnets: Vec::new(),
updated_at: None,
vlan_transparent: None,
}
Expand Down

0 comments on commit e76c99d

Please sign in to comment.