volcengine_rust_sdk/volcengine/request/operation_config/
operation_name.rs

1/*
2 * @Author: Jerry.Yang
3 * @Date: 2024-11-07 14:39:42
4 * @LastEditors: Jerry.Yang
5 * @LastEditTime: 2025-02-06 16:48:05
6 * @Description: operation name
7 */
8use crate::volcengine::request::operation_config::operation_name_clb;
9use crate::volcengine::request::operation_config::operation_name_ecs;
10use crate::volcengine::request::operation_config::operation_name_iam;
11use crate::volcengine::request::operation_config::operation_name_rds;
12use crate::volcengine::request::operation_config::operation_name_redis;
13use crate::volcengine::request::operation_config::operation_name_vpc;
14
15/// Enum representing a unified set of possible operation names across multiple services.
16/// This enum encapsulates different operation names from various services such as IAM, ECS, VPC, RDS, Redis, and CLB.
17/// It provides a type - safe way to represent and manage different operations in a single structure.
18/// The `Debug` derive allows for easy debugging by providing a default implementation of the `fmt::Debug` trait,
19/// which enables printing the enum variants in a readable format.
20/// The `Clone` derive allows for creating copies of the enum values when needed.
21#[derive(Debug, Clone)]
22pub enum OperationName {
23    /// Represents operations related to the Identity and Access Management (IAM) service.
24    /// The inner value is of type `operation_name_iam::OperationNameIam`, which contains specific IAM operations.
25    IamOperation(operation_name_iam::OperationNameIam),
26    /// Represents operations related to the Elastic Compute Service (ECS).
27    /// The inner value is of type `operation_name_ecs::OperationNameEcs`, which contains specific ECS operations.
28    EcsOperation(operation_name_ecs::OperationNameEcs),
29    /// Represents operations related to the Virtual Private Cloud (VPC) service.
30    /// The inner value is of type `operation_name_vpc::OperationNameVpc`, which contains specific VPC operations.
31    VpcOperation(operation_name_vpc::OperationNameVpc),
32    /// Represents operations related to the Relational Database Service (RDS).
33    /// The inner value is of type `operation_name_rds::OperationNameRds`, which contains specific RDS operations.
34    RdsOperation(operation_name_rds::OperationNameRds),
35    /// Represents operations related to the Redis database service.
36    /// The inner value is of type `operation_name_redis::OperationNameRedis`, which contains specific Redis operations.
37    RedisOperation(operation_name_redis::OperationNameRedis),
38    /// Represents operations related to the Cloud Load Balancer (CLB) service.
39    /// The inner value is of type `operation_name_clb::OperationNameClb`, which contains specific CLB operations.
40    ClbOperation(operation_name_clb::OperationNameClb),
41}
42
43/// Implementation of the `ToString` trait for the `OperationName` enum.
44/// This allows converting an instance of `OperationName` into a string representation.
45/// It is useful when passing the operation name as a parameter in API calls or for logging purposes.
46impl ToString for OperationName {
47    /// Converts an `OperationName` instance into a string.
48    ///
49    /// Based on the variant of the `OperationName` enum, it calls the `to_string` method
50    /// of the corresponding inner operation name enum (e.g., `OperationNameEcs`, `OperationNameIam`).
51    ///
52    /// # Returns
53    /// - A `String` representing the operation name.
54    fn to_string(&self) -> String {
55        match self {
56            // Convert the ECS operation name to a string
57            OperationName::EcsOperation(operation_name_ecs) => operation_name_ecs.to_string(),
58            // Convert the IAM operation name to a string
59            OperationName::IamOperation(operation_name_iam) => operation_name_iam.to_string(),
60            // Convert the VPC operation name to a string
61            OperationName::VpcOperation(operation_name_vpc) => operation_name_vpc.to_string(),
62            // Convert the RDS operation name to a string
63            OperationName::RdsOperation(operation_name_rds) => operation_name_rds.to_string(),
64            // Convert the Redis operation name to a string
65            OperationName::RedisOperation(operation_name_redis) => operation_name_redis.to_string(),
66            // Convert the CLB operation name to a string
67            OperationName::ClbOperation(operation_name_clb) => operation_name_clb.to_string(),
68        }
69    }
70}