Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions openstack_cli/src/block_storage/v3/scheduler_stat/get_pool/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ pub struct GetPoolCommand {

/// Query parameters
#[derive(Args)]
struct QueryParameters {}
struct QueryParameters {
/// Indicates whether to show pool details or only pool names in the
/// response. Set to true to show pool details. Set to false to show only
/// pool names. Default is false.
#[arg(action=clap::ArgAction::Set, help_heading = "Query parameters", long)]
detail: Option<bool>,
}

/// Path parameters
#[derive(Args)]
Expand All @@ -69,14 +75,19 @@ impl GetPoolCommand {
);
op.validate_args(parsed_args)?;

let ep_builder = get::Request::builder();
let mut ep_builder = get::Request::builder();

// Set query parameters
if let Some(val) = &self.query.detail {
ep_builder.detail(*val);
}

let ep = ep_builder
.build()
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;

let data = ep.query_async(client).await?;
op.output_single::<GetPoolResponse>(data)?;
let data: Vec<serde_json::Value> = ep.query_async(client).await?;
op.output_list::<GetPoolResponse>(data)?;
// Show command specific hints
op.show_command_hint()?;
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ use crate::api::rest_endpoint_prelude::*;
#[derive(Builder, Debug, Clone)]
#[builder(setter(strip_option))]
pub struct Request {
/// Indicates whether to show pool details or only pool names in the
/// response. Set to true to show pool details. Set to false to show only
/// pool names. Default is false.
#[builder(default)]
detail: Option<bool>,

#[builder(setter(name = "_headers"), default, private)]
_headers: Option<HeaderMap>,
}
Expand Down Expand Up @@ -73,7 +79,10 @@ impl RestEndpoint for Request {
}

fn parameters(&self) -> QueryParams<'_> {
QueryParams::default()
let mut params = QueryParams::default();
params.push_opt("detail", self.detail);

params
}

fn service_type(&self) -> ServiceType {
Expand Down
77 changes: 75 additions & 2 deletions openstack_types/data/block-storage/v3.71.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,8 @@ paths:
description: |-
List all active pools in scheduler.
operationId: scheduler-stats/get_pools:get
parameters:
- $ref: '#/components/parameters/detail'
responses:
'200':
content:
Expand Down Expand Up @@ -7712,6 +7714,14 @@ components:
type: string
x-openstack:
resource_link: identity/v3/project.id
detail:
description: Indicates whether to show pool details or only pool names in
the response. Set to true to show pool details. Set to false to show
only pool names. Default is false.
in: query
name: detail
schema:
type: boolean
extensions_project_id:
description: project_id parameter for /v3/{project_id}/extensions API
in: path
Expand Down Expand Up @@ -15838,8 +15848,71 @@ components:
description: Response of the :get operation
type: object
Scheduler_StatsGet_PoolsResponse:
description: Response of the project_id/scheduler-stats/get_pools:get
operation
properties:
pools:
description: |-
List of storage pools.
items:
properties:
capabilities:
description: |-
The capabilities for the back end. The value is
either `null` or a string value that indicates the capabilities
for each pool. For example, `total_capacity_gb` or `QoS_support`.
properties:
QoS_support:
description: |-
The quality of service (QoS) support.
type: boolean
driver_version:
description: |-
The driver version.
type: string
free_capacity_gb:
description: |-
The amount of free capacity for the back-end
volume, in GBs. A valid value is a string, such as `unknown`, or
a number (integer or floating point).
minimum: 0
type:
- integer
- string
reserved_percentage:
description: |-
The percentage of the total capacity that is
reserved for the internal use by the back end.
type: integer
storage_protocol:
description: |-
The storage back end for the back-end volume. For
example, `iSCSI` or `FC`.
type: string
total_capacity_gb:
description: |-
The total capacity for the back-end volume, in
GBs. A valid value is a string, such as `unknown`, or a
number (integer or floating point).
minimum: 0
type:
- integer
- string
updated:
description: |-
The date and time stamp when the extension was
last updated.
format: date-time
type: string
volume_backend_name:
description: |-
The name of the back-end volume.
type: string
type: object
name:
description: |-
The name of the backend pool.
type: string
type: object
type: array
type: object
SnapshotShowResponse:
additionalProperties: false
Expand Down
77 changes: 75 additions & 2 deletions openstack_types/data/block-storage/v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,8 @@ paths:
description: |-
List all active pools in scheduler.
operationId: scheduler-stats/get_pools:get
parameters:
- $ref: '#/components/parameters/detail'
responses:
'200':
content:
Expand Down Expand Up @@ -7712,6 +7714,14 @@ components:
type: string
x-openstack:
resource_link: identity/v3/project.id
detail:
description: Indicates whether to show pool details or only pool names in
the response. Set to true to show pool details. Set to false to show
only pool names. Default is false.
in: query
name: detail
schema:
type: boolean
extensions_project_id:
description: project_id parameter for /v3/{project_id}/extensions API
in: path
Expand Down Expand Up @@ -15838,8 +15848,71 @@ components:
description: Response of the :get operation
type: object
Scheduler_StatsGet_PoolsResponse:
description: Response of the project_id/scheduler-stats/get_pools:get
operation
properties:
pools:
description: |-
List of storage pools.
items:
properties:
capabilities:
description: |-
The capabilities for the back end. The value is
either `null` or a string value that indicates the capabilities
for each pool. For example, `total_capacity_gb` or `QoS_support`.
properties:
QoS_support:
description: |-
The quality of service (QoS) support.
type: boolean
driver_version:
description: |-
The driver version.
type: string
free_capacity_gb:
description: |-
The amount of free capacity for the back-end
volume, in GBs. A valid value is a string, such as `unknown`, or
a number (integer or floating point).
minimum: 0
type:
- integer
- string
reserved_percentage:
description: |-
The percentage of the total capacity that is
reserved for the internal use by the back end.
type: integer
storage_protocol:
description: |-
The storage back end for the back-end volume. For
example, `iSCSI` or `FC`.
type: string
total_capacity_gb:
description: |-
The total capacity for the back-end volume, in
GBs. A valid value is a string, such as `unknown`, or a
number (integer or floating point).
minimum: 0
type:
- integer
- string
updated:
description: |-
The date and time stamp when the extension was
last updated.
format: date-time
type: string
volume_backend_name:
description: |-
The name of the back-end volume.
type: string
type: object
name:
description: |-
The name of the backend pool.
type: string
type: object
type: array
type: object
SnapshotShowResponse:
additionalProperties: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,45 @@
//! Response type for the GET `scheduler-stats/get_pools` operation

use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::BTreeMap;
use structable::{StructTable, StructTableOptions};

/// Response data as HashMap type
#[derive(Deserialize, Serialize)]
pub struct GetPoolResponse(BTreeMap<String, Value>);

impl StructTable for GetPoolResponse {
fn instance_headers<O: StructTableOptions>(&self, _options: &O) -> Option<Vec<String>> {
Some(self.0.keys().map(Into::into).collect())
}

fn data<O: StructTableOptions>(&self, _options: &O) -> Vec<Option<String>> {
Vec::from_iter(self.0.values().map(|v| serde_json::to_string(&v).ok()))
}
/// GetPool response representation
#[derive(Clone, Deserialize, Serialize, StructTable)]
pub struct GetPoolResponse {
/// List of storage pools.
#[structable(serialize)]
pub pools: Vec<Pools>,
}

impl StructTable for &GetPoolResponse {
fn instance_headers<O: StructTableOptions>(&self, _options: &O) -> Option<Vec<String>> {
Some(self.0.keys().map(Into::into).collect())
}
/// The capabilities for the back end. The value is either `null` or a string
/// value that indicates the capabilities for each pool. For example,
/// `total_capacity_gb` or `QoS_support`.
/// `Capabilities` type
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Capabilities {
#[serde(default)]
pub driver_version: Option<String>,
#[serde(default, deserialize_with = "crate::common::deser_num_str_opt")]
pub free_capacity_gb: Option<i64>,
#[serde(default, rename = "QoS_support")]
pub qo_s_support: Option<bool>,
#[serde(default)]
pub reserved_percentage: Option<i32>,
#[serde(default)]
pub storage_protocol: Option<String>,
#[serde(default, deserialize_with = "crate::common::deser_num_str_opt")]
pub total_capacity_gb: Option<i64>,
#[serde(default)]
pub updated: Option<String>,
#[serde(default)]
pub volume_backend_name: Option<String>,
}

fn data<O: StructTableOptions>(&self, _options: &O) -> Vec<Option<String>> {
Vec::from_iter(self.0.values().map(|v| serde_json::to_string(&v).ok()))
}
/// `Pools` type
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Pools {
#[serde(default)]
pub capabilities: Option<Capabilities>,
#[serde(default)]
pub name: Option<String>,
}