-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.ts
285 lines (257 loc) · 8.08 KB
/
configuration.ts
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/* tslint:disable */
/* eslint-disable */
/**
* IONOS DBaaS MariaDB REST API
* An enterprise-grade Database is provided as a Service (DBaaS) solution that can be managed through a browser-based \"Data Center Designer\" (DCD) tool or via an easy to use API. The API allows you to create additional MariaDB database clusters or modify existing ones. It is designed to allow users to leverage the same power and flexibility found within the DCD visual tool. Both tools are consistent with their concepts and lend well to making the experience smooth and intuitive.
*
* The version of the OpenAPI document: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* maximum number of retries for 502, 503, 504 or 429 statuses */
export const DEFAULT_MAX_RETRIES = 3;
/* maximum wait time between retries in milliseconds */
export const DEFAULT_MAX_WAIT_TIME = 10000;
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
formDataCtor?: new () => any;
debug?: boolean;
}
export class Configuration {
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
password?: string;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
* @type {string}
* @memberof Configuration
*/
basePath?: string;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
/**
* Default values for parameters such as pretty and depth
* @type {Object.<string, any>}
*/
defaultParamValues: Record<string, any>;
/**
* Maximum retries in case a request fails with
* 502, 503, 504 or 429.
*/
maxRetries: number;
/**
* Maximum wait time between retries, in milliseconds
*/
maxWaitTime: number;
/**
* Debug flag
*/
debug: boolean;
/**
* User Agent
*/
userAgent: string;
constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
this.defaultParamValues = {};
this.maxRetries = DEFAULT_MAX_RETRIES;
this.maxWaitTime = DEFAULT_MAX_WAIT_TIME;
this.debug = false;
this.setUserAgent('ionos-cloud-sdk-node-dbaas-mariadb/v1.0.1');
}
static fromEnv(): Configuration {
const configParams: ConfigurationParameters = {
username: process.env.IONOS_USERNAME,
password: process.env.IONOS_PASSWORD,
apiKey: process.env.IONOS_TOKEN,
}
configParams.basePath = process.env.IONOS_API_URL || configParams.basePath
configParams.debug = process.env.IONOS_DEBUG !== undefined
return new Configuration(configParams)
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
/**
* Set the default value of a parameter
* @param param - parameter name
* @param value - default value
* @return this
*/
public setDefaultParamValue(param: string, value: any): this {
this.defaultParamValues[param] = value;
return this;
}
/**
* Retrieve the default value of a parameter
* @param param - parameter
* @return any
*/
public getDefaultParamValue(param: string): any {
return this.defaultParamValues[param];
}
/**
* Set the default value for the 'pretty' param.
* @param value - default value
* @return this
*/
public setPretty(value: boolean): this {
this.setDefaultParamValue('pretty', value);
return this;
}
/**
* Set the default value for the 'depth' param.
* @param value - default value
* @return this
*/
public setDepth(value: number): this {
this.setDefaultParamValue('depth', value);
return this;
}
/**
* Get the default value for the 'pretty' param
* @return boolean | undefined
*/
public getPretty(): boolean | undefined {
return this.getDefaultParamValue('pretty');
}
/**
* Get the default value for the 'depth' param
* @return boolean | undefined
*/
public getDepth(): boolean | undefined {
return this.getDefaultParamValue('depth');
}
/**
* Set the maximum number of retries in case a request
* fails with 502, 503, 504 or 429.
* @param max - maximum number of retries
* @return this
*/
public setMaxRetries(max: number): this {
this.maxRetries = max;
return this;
}
/**
* Retrieve the maximum number of retries in case a request
* fails with 502, 503, 504 or 429.
* @return number
*/
public getMaxRetries(): number {
return this.maxRetries;
}
/**
* Set the maximum wait time between retries.
* @param value - number
* @return this
*/
public setMaxWaitTime(value: number): this {
this.maxWaitTime = value;
return this;
}
/**
* Retrieve the maximum wait time between retries.
* @return number
*/
public getMaxWaitTime(): number {
return this.maxWaitTime;
}
/**
* Enable/disable debug messages.
* @param debug - boolean
* @return this
*/
public setDebug(debug = true): this {
this.debug = debug;
return this;
}
/**
* Determine whether debug mode is enabled or not
* @return boolean
*/
public isDebug(): boolean {
return this.debug;
}
/**
* Set the user agent used in requests.
* @param userAgent - string
* @return this
*/
public setUserAgent(userAgent: string): this {
this.userAgent = userAgent;
this.baseOptions = this.baseOptions || {};
this.baseOptions.headers = this.baseOptions.headers || {};
this.baseOptions.headers['user-agent'] = this.userAgent;
return this;
}
/**
* Retrieve the user agent used in requests.
* @return string
*/
public getUserAgent(): string {
return this.userAgent;
}
}