runpod_sdk/model/volume.rs
1use serde::{Deserialize, Serialize};
2
3pub use super::common::NetworkVolume;
4
5/// List of network volumes.
6///
7/// A collection type representing multiple network volumes, typically returned
8/// from API endpoints that list volumes for an account or data center.
9pub type NetworkVolumes = Vec<NetworkVolume>;
10
11/// Input parameters for creating a new network volume.
12///
13/// This struct contains all the required configuration options for creating a network volume.
14/// All fields are mandatory as they define the fundamental characteristics of the volume
15/// that cannot be changed after creation (except size, which can only be increased).
16///
17/// # Validation Requirements
18///
19/// - **name**: Must be 1-255 characters long. Can contain letters, numbers, spaces, hyphens, and underscores
20/// - **size**: Must be between 1 and 4,000 GB. Choose based on your storage needs and budget
21/// - **data_center_id**: Must be a valid RunPod data center identifier (format: XX-XX-N)
22///
23/// # Examples
24///
25/// ```rust
26/// use runpod_sdk::model::NetworkVolumeCreateInput;
27///
28/// // Create a small development volume
29/// let dev_volume = NetworkVolumeCreateInput {
30/// name: "dev-workspace".to_string(),
31/// size: 10,
32/// data_center_id: "US-CA-1".to_string(),
33/// };
34///
35/// // Create a large production dataset volume
36/// let prod_volume = NetworkVolumeCreateInput {
37/// name: "production-ml-datasets".to_string(),
38/// size: 1000,
39/// data_center_id: "EU-RO-1".to_string(),
40/// };
41/// ```
42#[derive(Debug, Clone, Default, Serialize, Deserialize)]
43#[serde(rename_all = "camelCase")]
44pub struct NetworkVolumeCreateInput {
45 /// A user-defined name for the network volume.
46 ///
47 /// The name is used for identification and organization purposes.
48 /// It does not need to be unique across your account, allowing you to
49 /// use descriptive names that match your workflow or project structure.
50 ///
51 /// **Constraints:**
52 /// - Length: 1-255 characters
53 /// - Allowed characters: letters, numbers, spaces, hyphens, underscores
54 /// - Case-sensitive
55 ///
56 /// **Examples:** "ml-training-data", "user uploads", "backup_volume_2024"
57 pub name: String,
58
59 /// The amount of disk space, in gigabytes (GB), to allocate to the network volume.
60 ///
61 /// This determines the storage capacity of the volume and directly affects billing.
62 /// Choose a size that accounts for current needs plus reasonable growth, as expanding
63 /// volumes requires an update operation and may take time to complete.
64 ///
65 /// **Constraints:**
66 /// - Minimum: 1 GB
67 /// - Maximum: 4,000 GB (4 TB)
68 /// - Billing: Charged per GB-hour for the full allocated capacity
69 ///
70 /// **Performance notes:**
71 /// - Larger volumes may have better IOPS performance
72 /// - Size can be increased later but never decreased
73 ///
74 /// **Examples:** 10 (small dev), 100 (medium project), 1000 (large dataset)
75 pub size: u32,
76
77 /// The RunPod data center ID where the network volume will be created.
78 ///
79 /// Network volumes are bound to specific data centers and can only be attached
80 /// to Pods running in the same data center. Choose based on:
81 /// - Geographic proximity to your users
82 /// - Data sovereignty requirements
83 /// - Pricing differences between regions
84 /// - Availability of required GPU/CPU types
85 ///
86 /// **Format:** Two-letter country code, two-letter region code, and number (XX-XX-N)
87 ///
88 /// **Common data centers:**
89 /// - `US-CA-1`: California, USA (West Coast)
90 /// - `US-TX-1`: Texas, USA (Central)
91 /// - `EU-RO-1`: Romania, Europe
92 /// - `EU-SE-1`: Sweden, Europe
93 ///
94 /// **Note:** Available data centers and their identifiers can be retrieved
95 /// from the data centers API endpoint.
96 pub data_center_id: String,
97}
98
99/// Input parameters for updating an existing network volume.
100///
101/// This struct allows you to modify the name and/or size of an existing network volume.
102/// Both fields are optional, allowing you to update only the properties you want to change.
103///
104/// # Important Notes
105///
106/// - **Size expansion only**: You can increase the volume size but never decrease it
107/// - **Live expansion**: Size changes can be performed while Pods are using the volume
108/// - **Billing impact**: Size increases affect billing immediately
109/// - **No downtime**: Name changes are instantaneous with no service interruption
110///
111/// # Validation Requirements
112///
113/// - **name**: If provided, must be 1-255 characters long
114/// - **size**: If provided, must be larger than current size and ≤4,000 GB
115///
116/// # Examples
117///
118/// ```rust
119/// use runpod_sdk::model::NetworkVolumeUpdateInput;
120///
121/// // Only change the name
122/// let rename_only = NetworkVolumeUpdateInput {
123/// name: Some("renamed-volume".to_string()),
124/// size: None,
125/// };
126///
127/// // Only expand the size from current to 500GB
128/// let expand_only = NetworkVolumeUpdateInput {
129/// name: None,
130/// size: Some(500),
131/// };
132///
133/// // Change both name and size
134/// let full_update = NetworkVolumeUpdateInput {
135/// name: Some("production-storage-v2".to_string()),
136/// size: Some(1000),
137/// };
138///
139/// // No changes (useful for testing API connectivity)
140/// let no_change = NetworkVolumeUpdateInput::default();
141/// ```
142#[derive(Debug, Clone, Default, Serialize, Deserialize)]
143#[serde(rename_all = "camelCase")]
144pub struct NetworkVolumeUpdateInput {
145 /// Optional new name for the network volume.
146 ///
147 /// If provided, the volume will be renamed to this value. The name change
148 /// is applied immediately and does not affect volume availability or performance.
149 ///
150 /// **Constraints:**
151 /// - Length: 1-255 characters (if provided)
152 /// - Allowed characters: letters, numbers, spaces, hyphens, underscores
153 /// - Case-sensitive
154 ///
155 /// **Use cases:**
156 /// - Updating naming conventions across your infrastructure
157 /// - Adding version numbers or status indicators
158 /// - Improving organization and searchability
159 ///
160 /// **Note:** Set to `None` to keep the current name unchanged.
161 #[serde(skip_serializing_if = "Option::is_none")]
162 pub name: Option<String>,
163
164 /// Optional new size for the network volume in gigabytes (GB).
165 ///
166 /// If provided, the volume will be expanded to this new size. The expansion
167 /// operation preserves all existing data and can be performed while Pods are
168 /// actively using the volume.
169 ///
170 /// **Constraints:**
171 /// - Must be larger than the current volume size (expansion only)
172 /// - Maximum: 4,000 GB (4 TB)
173 /// - Minimum increment: 1 GB
174 ///
175 /// **Process:**
176 /// 1. API call returns immediately with success
177 /// 2. Volume expansion happens asynchronously in the background
178 /// 3. Additional capacity becomes available once expansion completes
179 /// 4. Billing for the new size begins immediately
180 ///
181 /// **Performance impact:**
182 /// - No downtime during expansion
183 /// - File system may need manual extension in some cases
184 /// - Larger volumes may have improved IOPS performance
185 ///
186 /// **Note:** Set to `None` to keep the current size unchanged.
187 #[serde(skip_serializing_if = "Option::is_none")]
188 pub size: Option<u32>,
189}