Skip to content

Commit

Permalink
feat: Generate TUI response structure (#946)
Browse files Browse the repository at this point in the history
Change-Id: I2b9f37ebb5e08e36b969aee148bc571ed587c7ae

Changes are triggered by https://review.opendev.org/938997
  • Loading branch information
gtema authored Feb 2, 2025
1 parent e297300 commit ca100b9
Show file tree
Hide file tree
Showing 68 changed files with 3,828 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::cloud_worker::common::CloudWorkerError;
use crate::cloud_worker::types::{ApiRequest, ExecuteApiRequest};

use crate::cloud_worker::ConfirmableRequest;
use crate::utils::StructTable;
use openstack_sdk::api::block_storage::v3::backup::delete::RequestBuilder;
use openstack_sdk::api::ignore;
use openstack_sdk::{api::QueryAsync, AsyncOpenStack};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ use crate::action::Action;
use crate::cloud_worker::common::CloudWorkerError;
use crate::cloud_worker::types::{ApiRequest, ExecuteApiRequest};

use crate::utils::OutputConfig;
use crate::utils::StructTable;
use openstack_sdk::api::block_storage::v3::backup::list_detailed::RequestBuilder;
use openstack_sdk::api::{paged, Pagination};
use openstack_sdk::{api::QueryAsync, AsyncOpenStack};
use serde_json::Value;
use structable_derive::StructTable;

#[derive(Builder, Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[builder(setter(strip_option))]
Expand Down Expand Up @@ -106,3 +110,146 @@ impl ExecuteApiRequest for BlockStorageBackupList {
Ok(())
}
}
/// BlockStorageBackup response representation
#[derive(Deserialize, Serialize, Clone, StructTable)]
struct BlockStorageBackup {
/// The name of the availability zone.
///
#[serde(default)]
#[structable(optional, title = "AVAILABILITY_ZONE", wide)]
availability_zone: Option<String>,

/// The container name or null.
///
#[serde(default)]
#[structable(optional, title = "CONTAINER", wide)]
container: Option<String>,

/// The date and time when the resource was created.
///
/// The date and time stamp format is
/// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601):
///
/// ```text
/// CCYY-MM-DDThh:mm:ss±hh:mm
///
/// ```
///
/// For example, `2015-08-27T09:49:58-05:00`.
///
/// The `±hh:mm` value, if included, is the time zone as an offset from
/// UTC.
///
#[serde(default)]
#[structable(optional, title = "CREATED_AT")]
created_at: Option<String>,

/// The time when the data on the volume was first saved. If it is a backup
/// from volume, it will be the same as `created_at` for a backup. If it is
/// a backup from a snapshot, it will be the same as `created_at` for the
/// snapshot.
///
#[serde(default)]
#[structable(optional, title = "DATA_TIMESTAMP", wide)]
data_timestamp: Option<String>,

/// The backup description or null.
///
#[serde(default)]
#[structable(optional, title = "DESCRIPTION", wide)]
description: Option<String>,

/// If the backup failed, the reason for the failure. Otherwise, null.
///
#[serde(default)]
#[structable(optional, title = "FAIL_REASON", wide)]
fail_reason: Option<String>,

/// If this value is `true`, there are other backups depending on this
/// backup.
///
#[serde(default)]
#[structable(optional, title = "HAS_DEPENDENT_BACKUPS", wide)]
has_dependent_backups: Option<bool>,

/// The UUID of the backup.
///
#[serde(default)]
#[structable(optional, title = "ID", wide)]
id: Option<String>,

/// Indicates whether the backup mode is incremental. If this value is
/// `true`, the backup mode is incremental. If this value is `false`, the
/// backup mode is full.
///
#[serde(default)]
#[structable(optional, title = "IS_INCREMENTAL", wide)]
is_incremental: Option<bool>,

/// The backup metadata key value pairs.
///
/// **New in version 3.43**
///
#[serde(default)]
#[structable(optional, title = "METADATA", wide)]
metadata: Option<Value>,

/// The backup name.
///
#[serde(default)]
#[structable(optional, title = "NAME")]
name: Option<String>,

/// The number of objects in the backup.
///
#[serde(default)]
#[structable(optional, title = "OBJECT_COUNT", wide)]
object_count: Option<i32>,

/// The size of the volume, in gibibytes (GiB).
///
#[serde(default)]
#[structable(optional, title = "SIZE", wide)]
size: Option<i64>,

/// The UUID of the source volume snapshot.
///
#[serde(default)]
#[structable(optional, title = "SNAPSHOT_ID", wide)]
snapshot_id: Option<String>,

/// The backup status. Refer to Backup statuses table for the possible
/// status value.
///
#[serde(default)]
#[structable(optional, title = "STATUS")]
status: Option<String>,

/// The date and time when the resource was updated.
///
/// The date and time stamp format is
/// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601):
///
/// ```text
/// CCYY-MM-DDThh:mm:ss±hh:mm
///
/// ```
///
/// For example, `2015-08-27T09:49:58-05:00`.
///
/// The `±hh:mm` value, if included, is the time zone as an offset from
/// UTC. In the previous example, the offset value is `-05:00`.
///
/// If the `updated_at` date and time stamp is not set, its value is
/// `null`.
///
#[serde(default)]
#[structable(optional, title = "UPDATED_AT")]
updated_at: Option<String>,

/// The UUID of the volume.
///
#[serde(default)]
#[structable(optional, title = "VOLUME_ID", wide)]
volume_id: Option<String>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::cloud_worker::common::CloudWorkerError;
use crate::cloud_worker::types::{ApiRequest, ExecuteApiRequest};

use crate::cloud_worker::ConfirmableRequest;
use crate::utils::StructTable;
use openstack_sdk::api::block_storage::v3::snapshot::delete::RequestBuilder;
use openstack_sdk::api::ignore;
use openstack_sdk::{api::QueryAsync, AsyncOpenStack};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ use crate::action::Action;
use crate::cloud_worker::common::CloudWorkerError;
use crate::cloud_worker::types::{ApiRequest, ExecuteApiRequest};

use crate::utils::OutputConfig;
use crate::utils::StructTable;
use openstack_sdk::api::block_storage::v3::snapshot::list_detailed::RequestBuilder;
use openstack_sdk::api::{paged, Pagination};
use openstack_sdk::{api::QueryAsync, AsyncOpenStack};
use serde_json::Value;
use structable_derive::StructTable;

#[derive(Builder, Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[builder(setter(strip_option))]
Expand Down Expand Up @@ -111,3 +115,127 @@ impl ExecuteApiRequest for BlockStorageSnapshotList {
Ok(())
}
}
/// BlockStorageSnapshot response representation
#[derive(Deserialize, Serialize, Clone, StructTable)]
struct BlockStorageSnapshot {
/// Whether this resource consumes quota or not. Resources that not counted
/// for quota usage are usually temporary internal resources created to
/// perform an operation.
///
/// **New in version 3.65**
///
#[serde(default)]
#[structable(optional, title = "CONSUMES_QUOTA", wide)]
consumes_quota: Option<bool>,

/// The total count of requested resource before pagination is applied.
///
/// **New in version 3.45**
///
#[serde(default)]
#[structable(optional, title = "COUNT", wide)]
count: Option<i32>,

/// The date and time when the resource was created.
///
/// The date and time stamp format is
/// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601):
///
/// ```text
/// CCYY-MM-DDThh:mm:ss±hh:mm
///
/// ```
///
/// For example, `2015-08-27T09:49:58-05:00`.
///
/// The `±hh:mm` value, if included, is the time zone as an offset from
/// UTC.
///
#[serde(default)]
#[structable(optional, title = "CREATED_AT")]
created_at: Option<String>,

/// A description for the snapshot.
///
#[serde(default)]
#[structable(optional, title = "DESCRIPTION", wide)]
description: Option<String>,

/// The ID of the group snapshot.
///
/// **New in version 3.14**
///
#[serde(default)]
#[structable(optional, title = "GROUP_SNAPSHOT_ID", wide)]
group_snapshot_id: Option<String>,

/// The snapshot UUID.
///
#[serde(default)]
#[structable(optional, title = "ID", wide)]
id: Option<String>,

/// One or more metadata key and value pairs for the snapshot, if any.
///
#[serde(default)]
#[structable(optional, title = "METADATA", wide)]
metadata: Option<Value>,

/// The name of the object.
///
#[serde(default)]
#[structable(optional, title = "NAME")]
name: Option<String>,

/// A percentage value for the build progress.
///
#[serde(default, rename = "os-extended-snapshot-attributes:progress")]
#[structable(optional, title = "OS-EXTENDED-SNAPSHOT-ATTRIBUTES:PROGRESS", wide)]
os_extended_snapshot_attributes_progress: Option<String>,

/// The UUID of the owning project.
///
#[serde(default, rename = "os-extended-snapshot-attributes:project_id")]
#[structable(optional, title = "OS-EXTENDED-SNAPSHOT-ATTRIBUTES:PROJECT_ID", wide)]
os_extended_snapshot_attributes_project_id: Option<String>,

/// The size of the volume, in gibibytes (GiB).
///
#[serde(default)]
#[structable(optional, title = "SIZE", wide)]
size: Option<i64>,

/// The status for the snapshot.
///
#[serde(default)]
#[structable(optional, title = "STATUS")]
status: Option<Value>,

/// The date and time when the resource was updated.
///
/// The date and time stamp format is
/// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601):
///
/// ```text
/// CCYY-MM-DDThh:mm:ss±hh:mm
///
/// ```
///
/// For example, `2015-08-27T09:49:58-05:00`.
///
/// The `±hh:mm` value, if included, is the time zone as an offset from
/// UTC. In the previous example, the offset value is `-05:00`.
///
/// If the `updated_at` date and time stamp is not set, its value is
/// `null`.
///
#[serde(default)]
#[structable(optional, title = "UPDATED_AT")]
updated_at: Option<String>,

/// If the snapshot was created from a volume, the volume ID.
///
#[serde(default)]
#[structable(optional, title = "VOLUME_ID", wide)]
volume_id: Option<String>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::cloud_worker::common::CloudWorkerError;
use crate::cloud_worker::types::{ApiRequest, ExecuteApiRequest};

use crate::cloud_worker::ConfirmableRequest;
use crate::utils::StructTable;
use openstack_sdk::api::block_storage::v3::volume::delete::RequestBuilder;
use openstack_sdk::api::ignore;
use openstack_sdk::{api::QueryAsync, AsyncOpenStack};
Expand Down
Loading

0 comments on commit ca100b9

Please sign in to comment.