volcengine_rust_sdk/service/iam/api_get_security_config_model.rs
1/*
2 * @Author: Jerry.Yang
3 * @Date: 2024-10-25 15:10:33
4 * @LastEditors: Jerry.Yang
5 * @LastEditTime: 2025-02-05 18:30:43
6 * @Description: get login profile model
7 */
8use crate::volcengine::error::error;
9use crate::volcengine::request::request::RequestVolcengine;
10use crate::volcengine::request::{request, response};
11use std::collections::HashMap;
12use volcengine_sdk_protobuf::protobuf::iam_user;
13
14/// Implementation of the `ApiRequest` trait for the `GetSecurityConfigReq` struct.
15/// This implementation allows the `GetSecurityConfigReq` struct to be formatted into a hashmap
16/// and a request body for making API requests.
17impl request::ApiRequest for iam_user::GetSecurityConfigReq {
18 /// Converts the `GetSecurityConfigReq` instance into a hashmap of string key - value pairs.
19 /// This hashmap can be used to construct the query parameters or form data of an API request.
20 ///
21 /// # Returns
22 /// - A `HashMap<String, String>` containing the formatted request data.
23 fn to_hashmap(&self) -> HashMap<String, String> {
24 request::Request::format_request_to_hashmap(self)
25 }
26
27 /// Converts the `GetSecurityConfigReq` instance into a byte vector representing the request body.
28 /// In this case, an empty vector is returned as the body, indicating that there is no
29 /// specific body data for this request.
30 ///
31 /// # Returns
32 /// - A `Vec<u8>` representing the request body.
33 fn to_body(&self) -> Vec<u8> {
34 let result = Vec::new();
35 result
36 }
37}
38
39/// Implementation of the `ApiResponse` trait for the `GetSecurityConfigResp` struct.
40/// This implementation is responsible for converting an HTTP response into the `GetSecurityConfigResp` struct.
41impl response::ApiResponse for iam_user::GetSecurityConfigResp {
42 /// Converts an HTTP response into the `GetSecurityConfigResp` struct.
43 /// It first parses the JSON response body and then updates the current `GetSecurityConfigResp` instance
44 /// with the parsed data.
45 ///
46 /// # Arguments
47 /// - `&mut self`: A mutable reference to the `GetSecurityConfigResp` instance.
48 /// - `http_response`: A `reqwest::Response` containing the HTTP response data.
49 ///
50 /// # Returns
51 /// - On success, returns `Ok(())`.
52 /// - On error, returns an `Error` struct indicating the reason for the failure,
53 /// such as a parsing error.
54 async fn to_struct(&mut self, http_response: reqwest::Response) -> Result<(), error::Error> {
55 // Parse the JSON response body into a `GetSecurityConfigResp` struct.
56 // If the parsing fails, map the error to an `ErrParseResponse` error type.
57 let parsed_response: volcengine_sdk_protobuf::protobuf::iam_user::GetSecurityConfigResp =
58 http_response
59 .json()
60 .await
61 .map_err(|e| error::Error::ErrParseResponse(e))?;
62
63 // Update the current `GetSecurityConfigResp` instance with the parsed response data.
64 *self = parsed_response;
65
66 // Return `Ok(())` to indicate successful conversion of the HTTP response to the struct.
67 Ok(())
68 }
69}