openstack_types/block_storage/v3/consistencygroup/response/
set.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5//     http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12//
13// SPDX-License-Identifier: Apache-2.0
14//
15// WARNING: This file is automatically generated from OpenAPI schema using
16// `openstack-codegenerator`.
17//! Response type for the PUT `consistencygroups/{id}/update` operation
18
19use serde::{Deserialize, Serialize};
20use serde_json::Value;
21use std::collections::BTreeMap;
22use structable::{StructTable, StructTableOptions};
23
24/// Response data as HashMap type
25#[derive(Deserialize, Serialize)]
26pub struct ConsistencygroupResponse(BTreeMap<String, Value>);
27
28impl StructTable for ConsistencygroupResponse {
29    fn instance_headers<O: StructTableOptions>(&self, _options: &O) -> Option<Vec<String>> {
30        Some(self.0.keys().map(Into::into).collect())
31    }
32
33    fn data<O: StructTableOptions>(&self, _options: &O) -> Vec<Option<String>> {
34        Vec::from_iter(self.0.values().map(|v| serde_json::to_string(&v).ok()))
35    }
36}
37
38impl StructTable for &ConsistencygroupResponse {
39    fn instance_headers<O: StructTableOptions>(&self, _options: &O) -> Option<Vec<String>> {
40        Some(self.0.keys().map(Into::into).collect())
41    }
42
43    fn data<O: StructTableOptions>(&self, _options: &O) -> Vec<Option<String>> {
44        Vec::from_iter(self.0.values().map(|v| serde_json::to_string(&v).ok()))
45    }
46}