Skip to content

Commit 399ee3c

Browse files
authored
sdk cleanup (#1126)
1 parent b2c07a7 commit 399ee3c

6 files changed

Lines changed: 27 additions & 11 deletions

File tree

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ log = { workspace = true }
3838
md5 = { workspace = true }
3939
oauth2 = { workspace = true }
4040
open = { workspace = true }
41-
oxide = { workspace = true, features = ["clap"] }
41+
oxide = { workspace = true, features = ["clap", "extras"] }
4242
oxnet = { workspace = true }
4343
predicates = { workspace = true }
4444
ratatui = { workspace = true }

sdk/Cargo.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ readme = "README.md"
1010
[dependencies]
1111
base64 = { workspace = true }
1212
chrono = { workspace = true }
13-
clap = { workspace = true, optional = true }
1413
dirs = { workspace = true }
15-
flume = { workspace = true }
1614
futures = { workspace = true }
1715
progenitor-client = { workspace = true }
1816
rand = { workspace = true }
@@ -22,12 +20,18 @@ serde = { workspace = true }
2220
serde_json = { workspace = true }
2321
schemars = { workspace = true }
2422
thiserror = { workspace = true }
25-
tokio = { workspace = true }
2623
toml = { workspace = true }
2724
toml_edit = { workspace = true }
2825
tracing = { workspace = true }
2926
uuid = { workspace = true }
3027

28+
# Optional deps for the clap feature
29+
clap = { workspace = true, optional = true }
30+
31+
# Optional deps for the extras feature
32+
flume = { workspace = true, optional = true }
33+
tokio = { workspace = true, optional = true }
34+
3135
[dev-dependencies]
3236
tempfile = { workspace = true }
3337
test-common = { workspace = true }
@@ -36,4 +40,4 @@ tokio = { workspace = true }
3640
[features]
3741
default = []
3842
clap = ["dep:clap"]
39-
extras = []
43+
extras = ["dep:tokio", "dep:flume"]

sdk/src/auth.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::{Client, OxideAuthError};
1414
use reqwest::ClientBuilder;
1515
use serde::Deserialize;
1616

17+
/// Credentials for a particular profile.
1718
#[derive(Deserialize, Debug)]
1819
pub struct ProfileCredentials {
1920
pub token: String,
@@ -145,6 +146,7 @@ impl ClientConfig {
145146
}
146147
}
147148

149+
// Structure of the credentials file.
148150
#[derive(Deserialize, Debug, Default)]
149151
#[serde(default)]
150152
pub struct CredentialsFile {

sdk/src/extras/disk.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
// Copyright 2025 Oxide Computer Company
66

7+
//! Types in service of the [ClientExtraDiskExt] trait.
8+
79
use super::ClientExtraDiskExt;
810
use crate::Client;
911

@@ -13,6 +15,7 @@ impl ClientExtraDiskExt for Client {
1315
}
1416
}
1517

18+
/// Builder for disk extra operations.
1619
pub mod builder {
1720
use crate::extras::disk::types::{DiskImportError, DiskImportHandle, DiskInfo, ImageInfo};
1821
use crate::types::{Name, NameOrId};
@@ -164,6 +167,7 @@ pub mod builder {
164167
}
165168
}
166169

170+
/// Types for disk extra operations.
167171
pub mod types {
168172
use crate::types::{
169173
self, BlockSize, ByteCount, DiskCreate, DiskSource, DiskState, FinalizeDisk, ImageCreate,

sdk/src/extras/mod.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
// Copyright 2024 Oxide Computer Company
5+
// Copyright 2025 Oxide Computer Company
66

77
//! The `extra` feature adds additional, non-generated, compound interfaces to
8-
//! the [`Client`](super::generated_sdk::Client). It is intended for methods
9-
//! that are functional rather than for those that offer enhanced output or a
10-
//! simplified interface. (This is why the the CLI uses a disk import interface
11-
//! from here, but has a number of custom network subcommands that pretty-print
12-
//! or provide a simpler user interface for common use cases.)
8+
//! the [`Client`](crate::Client).
9+
//!
10+
//! It is intended for methods that are functional rather than for those that
11+
//! offer enhanced output or a simplified interface.
1312
//!
1413
//! These interfaces operate very similarly to the generated interfaces.
1514
15+
// Note: This is why the the CLI uses a disk import interface from here, but
16+
// has a number of custom network subcommands that pretty-print or provide a
17+
// simpler user interface for common use cases.
18+
1619
pub mod disk;
1720

21+
/// Higher level operations beyond the generated operations from
22+
/// [`ClientDisksExt`](crate::ClientDisksExt)
1823
pub trait ClientExtraDiskExt {
1924
/// A convenience wrapper around the SDK to simplify disk creation.
2025
/// Create a disk, optionally with a snapshot and image. The standard

sdk/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use tracing::{Level, Span};
2020
mod auth;
2121
#[cfg(feature = "clap")]
2222
mod clap_feature;
23+
#[cfg(feature = "extras")]
2324
pub mod extras;
2425
mod generated_sdk;
2526

0 commit comments

Comments
 (0)