1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* @Author: Jerry.Yang
* @Date: 2024-10-18 11:31:37
* @LastEditors: Jerry.Yang
* @LastEditTime: 2025-02-05 14:12:17
* @Description: Endpoint and utilities for URL scheme handling
*/
/// Enum representing different service endpoints in the Volcengine API.
///
/// This enum defines various service-specific endpoints that are used to
/// determine the correct API URL for making requests. Each variant corresponds
/// to a specific Volcengine service and provides a logical mapping to
/// the appropriate endpoint.
///
/// This enum is typically used in conjunction with the `Url` struct
/// to generate fully qualified endpoint URLs dynamically based on
/// the selected service.
/// Represents the resolved endpoint details for a specific service in Volcengine.
///
/// This struct encapsulates information about the service's endpoint,
/// including its URL, signing details, and whether certain attributes were
/// derived dynamically. It is primarily used in API request signing and
/// endpoint resolution to ensure requests are correctly authenticated
/// and routed to the appropriate service.
///
/// ## Fields
/// - `url`
/// The fully qualified endpoint URL for the service.
/// This URL is used to send API requests.
///
/// - `signing_region`
/// The region identifier used for signing API requests.
/// Some services require regional-specific signing to authenticate requests.
///
/// - `signing_name`
/// The name of the service as required for request signing.
/// This ensures that API requests are authenticated correctly.
///
/// - `signing_name_derived`
/// A boolean flag indicating whether the signing name was automatically
/// derived from metadata, rather than being explicitly defined in the
/// service's API specification. This is useful for handling cases
/// where a service does not explicitly define its signing name.
///
/// - *Planned but commented out:* `signing_method`
/// Initially intended to specify the cryptographic method used for
/// signing requests (e.g., HMAC-SHA256). However, it is currently
/// not included in the struct.
///
/// ## Usage Example
/// ```rust
/// let endpoint = ResolvedEndpoint {
/// url: "https://ecs.volcengineapi.com".to_string(),
/// signing_region: "cn-beijing".to_string(),
/// signing_name: "ecs".to_string(),
/// signing_name_derived: false,
/// };
/// println!("Resolved endpoint: {}", endpoint.url);
/// ```
/// Struct for holding the resolved endpoint details for a service.
/// Implementation of the `Endpoint` enum, providing methods to interact with service endpoints.
///
/// This implementation defines functionality for retrieving the base URL associated
/// with each Volcengine service endpoint. These endpoints are used to send API requests
/// to the corresponding services, such as IAM, ECS, VPC, RDS, Redis, and CLB.
///
/// # Usage
/// The `Endpoint` enum represents different services, and calling `get_endpoint()`
/// on an instance returns the appropriate service URL.
///
/// ## Example
/// ```rust
/// let iam_service_url = Endpoint::IamEndpoint.get_endpoint();
/// println!("IAM Service URL: {}", iam_service_url); // Output: "iam.volcengineapi.com"
/// ```
///
/// # Shared Endpoints
/// Some services, such as `EcsEndpoint`, `VpcEndpoint`, and `ClbEndpoint`,
/// use the same base URL (`"open.volcengineapi.com"`). This is common for services
/// that share infrastructure.
///
/// # Methods
/// - `get_endpoint()`: Returns the corresponding base URL for the selected service.
///
/// Adds the appropriate scheme (HTTP or HTTPS) to the endpoint URL.
///
/// # Parameters
/// - `endpoint`: The endpoint URL to which the scheme should be added.
/// - `disable_ssl`: A boolean flag indicating whether to disable SSL (use HTTP instead of HTTPS).
///
/// # Returns
/// A `String` representing the full endpoint URL with the scheme added.