openstack_types/compute/v2/server/metadata/response/
create.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 POST `servers/{server_id}/metadata` operation
18
19use serde::{Deserialize, Serialize};
20use std::collections::BTreeMap;
21use structable::{StructTable, StructTableOptions};
22
23/// Response data as HashMap type
24#[derive(Deserialize, Serialize)]
25pub struct MetadataResponse(BTreeMap<String, String>);
26
27impl StructTable for MetadataResponse {
28    fn instance_headers<O: StructTableOptions>(&self, _options: &O) -> Option<Vec<String>> {
29        Some(self.0.keys().map(Into::into).collect())
30    }
31
32    fn data<O: StructTableOptions>(&self, _options: &O) -> Vec<Option<String>> {
33        Vec::from_iter(self.0.values().map(|v| Some(v.clone())))
34    }
35}
36
37impl StructTable for &MetadataResponse {
38    fn instance_headers<O: StructTableOptions>(&self, _options: &O) -> Option<Vec<String>> {
39        Some(self.0.keys().map(Into::into).collect())
40    }
41
42    fn data<O: StructTableOptions>(&self, _options: &O) -> Vec<Option<String>> {
43        Vec::from_iter(self.0.values().map(|v| Some(v.clone())))
44    }
45}