-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathutils.dara
224 lines (192 loc) · 7.13 KB
/
utils.dara
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
@clientName("Utils")
@overwrite(false)
/**
* This is for OpenApi Util
*/
import Credential;
model GlobalParameters {
headers?: map[string]string,
queries?: map[string]string,
}
/**
* Model for initing client
*/
model Config {
accessKeyId?: string(description='accesskey id',default=''),
accessKeySecret?: string(description='accesskey secret',default=''),
securityToken?: string(description='security token',example='',default=''),
bearerToken?: string(description='bearer token',example='the-bearer-token',default=''),
protocol?: string(description='http protocol',example='http',default='http'),
method?: string(description='http method',example='GET',default=''),
regionId?: string(description='region id',example='cn-hangzhou',default=''),
readTimeout?: integer(description='read timeout',example='10',default=''),
connectTimeout?: integer(description='connect timeout',example='10',default=''),
httpProxy?: string(description='http proxy',example='http://localhost',default=''),
httpsProxy?: string(description='https proxy',example='https://localhost',default=''),
credential?: Credential(description='credential',example='',default=''),
endpoint?: string(description='endpoint',example='cs.aliyuncs.com',default=''),
noProxy?: string(description='proxy white list',example='http://localhost',default=''),
maxIdleConns?: integer(description='max idle conns',example='3',default=''),
network?: string(description='network for endpoint',example='public',default=''),
userAgent?: string(description='user agent',example='Alibabacloud/1',default=''),
suffix?: string(description='suffix for endpoint',example='aliyun',default=''),
socks5Proxy?: string(description='socks5 proxy',default=''),
socks5NetWork?: string(description='socks5 network',example='TCP',default=''),
endpointType?: string(description='endpoint type',example='internal',default=''),
openPlatformEndpoint?: string(description='OpenPlatform endpoint',example='openplatform.aliyuncs.com',default=''),
type?: string(description='credential type',example='access_key',default='',deprecated=true),
signatureVersion?: string(description='Signature Version',example='v1',default=''),
signatureAlgorithm?: string(description='Signature Algorithm',example='ACS3-HMAC-SHA256',default=''),
globalParameters?: GlobalParameters(description='Global Parameters'),
key?: string(description='privite key for client certificate', example='MIIEvQ',default=''),
cert?: string(description='client certificate', example='-----BEGIN CERTIFICATE-----\nxxx-----END CERTIFICATE-----',default=''),
ca?: string(description='server certificate', example='-----BEGIN CERTIFICATE-----\nxxx-----END CERTIFICATE-----',default=''),
disableHttp2?: boolean(description='disable HTTP/2', example='false'),
retryOptions?: $RetryOptions(description='retry options'),
}
model Params = {
action: string,
version: string,
protocol: string,
pathname: string,
method: string,
authType: string,
bodyType: string,
reqBodyType: string,
style?: string
}
model OpenApiRequest {
headers?: map[string]string,
query?: map[string]string,
body?: any,
stream?: readable,
hostMap?: map[string]string,
endpointOverride?: string,
}
/**
* Convert all params of body other than type of readable into content
* @param body source Model
* @param content target Model
* @return void
*/
static function convert(body: $Model, content: $Model): void;
/**
* If endpointType is internal, use internal endpoint
* If serverUse is true and endpointType is accelerate, use accelerate endpoint
* Default return endpoint
* @param serverUse whether use accelerate endpoint
* @param endpointType value must be internal or accelerate
* @return the final endpoint
*/
static function getEndpoint(endpoint: string, serverUse: boolean, endpointType: string): string;
/**
* Get throttling param
* @param the response headers
* @return time left
*/
static function getThrottlingTimeLeft(headers: map[string]string): long;
/**
* Hash the raw data with signatureAlgorithm
* @param raw hashing data
* @param signatureAlgorithm the autograph method
* @return hashed bytes
*/
static function hash(raw: bytes, signatureAlgorithm: string): bytes;
/**
* Get throttling param
* @param the response headers
* @return time left
*/
static function flatMap(params: map[string]any, prefix: string): map[string]string;
/**
* Generate a nonce string
* @return the nonce string
*/
static function getNonce(): string;
/**
* Get the string to be signed according to request
* @param request which contains signed messages
* @return the signed string
*/
static function getStringToSign(request: $Request): string;
/**
* Get signature according to stringToSign, secret
* @param stringToSign the signed string
* @param secret accesskey secret
* @return the signature
*/
static function getROASignature(stringToSign: string, secret: string): string;
/**
* Parse filter into a form string
* @param filter object
* @return the string
*/
static function toForm(filter: object): string;
/**
* Get timestamp
* @return the timestamp string
*/
static function getTimestamp(): string;
/**
* Get UTC string
* @return the UTC string
*/
static function getDateUTCString(): string;
/**
* Parse filter into a object which's type is map[string]string
* @param filter query param
* @return the object
*/
static function query(filter: object): map[string]string;
/**
* Get signature according to signedParams, method and secret
* @param signedParams params which need to be signed
* @param method http method e.g. GET
* @param secret AccessKeySecret
* @return the signature
*/
static function getRPCSignature(signedParams: map[string]string, method: string, secret: string): string;
/**
* Parse array into a string with specified style
* @param array the array
* @param prefix the prefix string
* @style specified style e.g. repeatList
* @return the string
*/
static function arrayToStringWithSpecifiedStyle(array: any, prefix: string, style: string): string;
/**
* Stringify the value of map
* @return the new stringified map
*/
static function stringifyMapValue(m: map[string]any): map[string]string;
/**
* Transform input as array.
*/
static function toArray(input: any): [ map[string]any ];
/**
* Parse map with flat style
*
* @param any the input
* @return any
*/
static function mapToFlatStyle(input: any): any;
/**
* Transform input as map.
*/
static function parseToMap(input: any): map[string]any;
/**
* Get the authorization
* @param request request params
* @param signatureAlgorithm the autograph method
* @param payload the hashed request
* @param accesskey the accesskey string
* @param accessKeySecret the accessKeySecret string
* @return authorization string
*/
static function getAuthorization(request: $Request, signatureAlgorithm: string, payload: string, accesskey: string, accessKeySecret: string): string;
static function getUserAgent(userAgent: string): string;
/**
* Get endpoint according to productId, regionId, endpointType, network and suffix
* @return endpoint
*/
static function getEndpointRules(product: string, regionId: string, endpointType: string, network: string, suffix: string) throws: string;