feat: update MCP config and TOOLS.md with calendar/contacts note
This commit is contained in:
19
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/README.md
generated
vendored
Normal file
19
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
English | [简体中文](README-CN.md)
|
||||
|
||||

|
||||
|
||||
# Alibaba Cloud OpenApi Client
|
||||
|
||||
## Issues
|
||||
|
||||
[Opening an Issue](https://github.com/aliyun/darabonba-openapi/issues/new), Issues not conforming to the guidelines may be closed immediately.
|
||||
|
||||
## References
|
||||
|
||||
- [Latest Release](https://github.com/aliyun/darabonba-openapi)
|
||||
|
||||
## License
|
||||
|
||||
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
531
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/dist/client.d.ts
generated
vendored
Normal file
531
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/dist/client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,531 @@
|
||||
/**
|
||||
* @remarks
|
||||
* This is for OpenApi SDK
|
||||
*/
|
||||
import * as $Util from '@alicloud/tea-util';
|
||||
import Credential from '@alicloud/credentials';
|
||||
import SPI, * as $SPI from '@alicloud/gateway-spi';
|
||||
import { Readable } from 'stream';
|
||||
import * as $tea from '@alicloud/tea-typescript';
|
||||
export declare class GlobalParameters extends $tea.Model {
|
||||
headers?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
queries?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
static names(): {
|
||||
[key: string]: string;
|
||||
};
|
||||
static types(): {
|
||||
[key: string]: any;
|
||||
};
|
||||
constructor(map?: {
|
||||
[key: string]: any;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Model for initing client
|
||||
*/
|
||||
export declare class Config extends $tea.Model {
|
||||
/**
|
||||
* @remarks
|
||||
* accesskey id
|
||||
*/
|
||||
accessKeyId?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* accesskey secret
|
||||
*/
|
||||
accessKeySecret?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* security token
|
||||
*
|
||||
* @example
|
||||
* a.txt
|
||||
*/
|
||||
securityToken?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* bearer token
|
||||
*
|
||||
* @example
|
||||
* the-bearer-token
|
||||
*/
|
||||
bearerToken?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* http protocol
|
||||
*
|
||||
* @example
|
||||
* http
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* http method
|
||||
*
|
||||
* @example
|
||||
* GET
|
||||
*/
|
||||
method?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* region id
|
||||
*
|
||||
* @example
|
||||
* cn-hangzhou
|
||||
*/
|
||||
regionId?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* read timeout
|
||||
*
|
||||
* @example
|
||||
* 10
|
||||
*/
|
||||
readTimeout?: number;
|
||||
/**
|
||||
* @remarks
|
||||
* connect timeout
|
||||
*
|
||||
* @example
|
||||
* 10
|
||||
*/
|
||||
connectTimeout?: number;
|
||||
/**
|
||||
* @remarks
|
||||
* http proxy
|
||||
*
|
||||
* @example
|
||||
* http://localhost
|
||||
*/
|
||||
httpProxy?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* https proxy
|
||||
*
|
||||
* @example
|
||||
* https://localhost
|
||||
*/
|
||||
httpsProxy?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* credential
|
||||
*/
|
||||
credential?: Credential;
|
||||
/**
|
||||
* @remarks
|
||||
* endpoint
|
||||
*
|
||||
* @example
|
||||
* cs.aliyuncs.com
|
||||
*/
|
||||
endpoint?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* proxy white list
|
||||
*
|
||||
* @example
|
||||
* http://localhost
|
||||
*/
|
||||
noProxy?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* max idle conns
|
||||
*
|
||||
* @example
|
||||
* 3
|
||||
*/
|
||||
maxIdleConns?: number;
|
||||
/**
|
||||
* @remarks
|
||||
* network for endpoint
|
||||
*
|
||||
* @example
|
||||
* public
|
||||
*/
|
||||
network?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* user agent
|
||||
*
|
||||
* @example
|
||||
* Alibabacloud/1
|
||||
*/
|
||||
userAgent?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* suffix for endpoint
|
||||
*
|
||||
* @example
|
||||
* aliyun
|
||||
*/
|
||||
suffix?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* socks5 proxy
|
||||
*/
|
||||
socks5Proxy?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* socks5 network
|
||||
*
|
||||
* @example
|
||||
* TCP
|
||||
*/
|
||||
socks5NetWork?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* endpoint type
|
||||
*
|
||||
* @example
|
||||
* internal
|
||||
*/
|
||||
endpointType?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* OpenPlatform endpoint
|
||||
*
|
||||
* @example
|
||||
* openplatform.aliyuncs.com
|
||||
*/
|
||||
openPlatformEndpoint?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* credential type
|
||||
*
|
||||
* @example
|
||||
* access_key
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* Signature Version
|
||||
*
|
||||
* @example
|
||||
* v1
|
||||
*/
|
||||
signatureVersion?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* Signature Algorithm
|
||||
*
|
||||
* @example
|
||||
* ACS3-HMAC-SHA256
|
||||
*/
|
||||
signatureAlgorithm?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* Global Parameters
|
||||
*/
|
||||
globalParameters?: GlobalParameters;
|
||||
/**
|
||||
* @remarks
|
||||
* privite key for client certificate
|
||||
*
|
||||
* @example
|
||||
* MIIEvQ
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* client certificate
|
||||
*
|
||||
* @example
|
||||
* -----BEGIN CERTIFICATE-----
|
||||
* xxx-----END CERTIFICATE-----
|
||||
*/
|
||||
cert?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* server certificate
|
||||
*
|
||||
* @example
|
||||
* -----BEGIN CERTIFICATE-----
|
||||
* xxx-----END CERTIFICATE-----
|
||||
*/
|
||||
ca?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* disable HTTP/2
|
||||
*
|
||||
* @example
|
||||
* false
|
||||
*/
|
||||
disableHttp2?: boolean;
|
||||
/**
|
||||
* @remarks
|
||||
* TLS Minimum Version
|
||||
*
|
||||
* @example
|
||||
* TLSv1, TLSv1.1, TLSv1.2, TLSv1.3
|
||||
*/
|
||||
tlsMinVersion?: string;
|
||||
static names(): {
|
||||
[key: string]: string;
|
||||
};
|
||||
static types(): {
|
||||
[key: string]: any;
|
||||
};
|
||||
constructor(map?: {
|
||||
[key: string]: any;
|
||||
});
|
||||
}
|
||||
export declare class OpenApiRequest extends $tea.Model {
|
||||
headers?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
query?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
body?: any;
|
||||
stream?: Readable;
|
||||
hostMap?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
endpointOverride?: string;
|
||||
static names(): {
|
||||
[key: string]: string;
|
||||
};
|
||||
static types(): {
|
||||
[key: string]: any;
|
||||
};
|
||||
constructor(map?: {
|
||||
[key: string]: any;
|
||||
});
|
||||
}
|
||||
export declare class Params extends $tea.Model {
|
||||
action: string;
|
||||
version: string;
|
||||
protocol: string;
|
||||
pathname: string;
|
||||
method: string;
|
||||
authType: string;
|
||||
bodyType: string;
|
||||
reqBodyType: string;
|
||||
style?: string;
|
||||
static names(): {
|
||||
[key: string]: string;
|
||||
};
|
||||
static types(): {
|
||||
[key: string]: any;
|
||||
};
|
||||
constructor(map?: {
|
||||
[key: string]: any;
|
||||
});
|
||||
}
|
||||
export default class Client {
|
||||
_endpoint: string;
|
||||
_regionId: string;
|
||||
_protocol: string;
|
||||
_method: string;
|
||||
_userAgent: string;
|
||||
_endpointRule: string;
|
||||
_endpointMap: {
|
||||
[key: string]: string;
|
||||
};
|
||||
_suffix: string;
|
||||
_readTimeout: number;
|
||||
_connectTimeout: number;
|
||||
_httpProxy: string;
|
||||
_httpsProxy: string;
|
||||
_socks5Proxy: string;
|
||||
_socks5NetWork: string;
|
||||
_noProxy: string;
|
||||
_network: string;
|
||||
_productId: string;
|
||||
_maxIdleConns: number;
|
||||
_endpointType: string;
|
||||
_openPlatformEndpoint: string;
|
||||
_credential: Credential;
|
||||
_signatureVersion: string;
|
||||
_signatureAlgorithm: string;
|
||||
_headers: {
|
||||
[key: string]: string;
|
||||
};
|
||||
_spi: SPI;
|
||||
_globalParameters: GlobalParameters;
|
||||
_key: string;
|
||||
_cert: string;
|
||||
_ca: string;
|
||||
_disableHttp2: boolean;
|
||||
_tlsMinVersion: string;
|
||||
_attributeMap: $SPI.AttributeMap;
|
||||
/**
|
||||
* @remarks
|
||||
* Init client with Config
|
||||
*
|
||||
* @param config - config contains the necessary information to create a client
|
||||
*/
|
||||
constructor(config: Config);
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
doRPCRequest(action: string, version: string, protocol: string, method: string, authType: string, bodyType: string, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param pathname - pathname of every api
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
doROARequest(action: string, version: string, protocol: string, method: string, authType: string, pathname: string, bodyType: string, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network with form body
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param pathname - pathname of every api
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
doROARequestWithForm(action: string, version: string, protocol: string, method: string, authType: string, pathname: string, bodyType: string, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
doRequest(params: Params, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
execute(params: Params, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
callApi(params: Params, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
/**
|
||||
* @remarks
|
||||
* Get user agent
|
||||
* @returns user agent
|
||||
*/
|
||||
getUserAgent(): string;
|
||||
/**
|
||||
* @remarks
|
||||
* Get accesskey id by using credential
|
||||
* @returns accesskey id
|
||||
*/
|
||||
getAccessKeyId(): Promise<string>;
|
||||
/**
|
||||
* @remarks
|
||||
* Get accesskey secret by using credential
|
||||
* @returns accesskey secret
|
||||
*/
|
||||
getAccessKeySecret(): Promise<string>;
|
||||
/**
|
||||
* @remarks
|
||||
* Get security token by using credential
|
||||
* @returns security token
|
||||
*/
|
||||
getSecurityToken(): Promise<string>;
|
||||
/**
|
||||
* @remarks
|
||||
* Get bearer token by credential
|
||||
* @returns bearer token
|
||||
*/
|
||||
getBearerToken(): Promise<string>;
|
||||
/**
|
||||
* @remarks
|
||||
* Get credential type by credential
|
||||
* @returns credential type e.g. access_key
|
||||
*/
|
||||
getType(): Promise<string>;
|
||||
/**
|
||||
* @remarks
|
||||
* If inputValue is not null, return it or return defaultValue
|
||||
*
|
||||
* @param inputValue - users input value
|
||||
* @param defaultValue - default value
|
||||
* @returns the final result
|
||||
*/
|
||||
static defaultAny(inputValue: any, defaultValue: any): any;
|
||||
/**
|
||||
* @remarks
|
||||
* If the endpointRule and config.endpoint are empty, throw error
|
||||
*
|
||||
* @param config - config contains the necessary information to create a client
|
||||
*/
|
||||
checkConfig(config: Config): void;
|
||||
/**
|
||||
* @remarks
|
||||
* set gateway client
|
||||
*
|
||||
* @param spi - .
|
||||
*/
|
||||
setGatewayClient(spi: SPI): void;
|
||||
/**
|
||||
* @remarks
|
||||
* set RPC header for debug
|
||||
*
|
||||
* @param headers - headers for debug, this header can be used only once.
|
||||
*/
|
||||
setRpcHeaders(headers: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
/**
|
||||
* @remarks
|
||||
* get RPC header for debug
|
||||
*/
|
||||
getRpcHeaders(): {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
1404
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/dist/client.js
generated
vendored
Normal file
1404
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/dist/client.js
generated
vendored
Normal file
@@ -0,0 +1,1404 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Params = exports.OpenApiRequest = exports.Config = exports.GlobalParameters = void 0;
|
||||
// This file is auto-generated, don't edit it
|
||||
/**
|
||||
* @remarks
|
||||
* This is for OpenApi SDK
|
||||
*/
|
||||
const tea_util_1 = __importDefault(require("@alicloud/tea-util"));
|
||||
const credentials_1 = __importStar(require("@alicloud/credentials")), $Credential = credentials_1;
|
||||
const openapi_util_1 = __importDefault(require("@alicloud/openapi-util"));
|
||||
const $SPI = __importStar(require("@alicloud/gateway-spi"));
|
||||
const tea_xml_1 = __importDefault(require("@alicloud/tea-xml"));
|
||||
const $tea = __importStar(require("@alicloud/tea-typescript"));
|
||||
class GlobalParameters extends $tea.Model {
|
||||
static names() {
|
||||
return {
|
||||
headers: 'headers',
|
||||
queries: 'queries',
|
||||
};
|
||||
}
|
||||
static types() {
|
||||
return {
|
||||
headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
queries: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
};
|
||||
}
|
||||
constructor(map) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
exports.GlobalParameters = GlobalParameters;
|
||||
/**
|
||||
* @remarks
|
||||
* Model for initing client
|
||||
*/
|
||||
class Config extends $tea.Model {
|
||||
static names() {
|
||||
return {
|
||||
accessKeyId: 'accessKeyId',
|
||||
accessKeySecret: 'accessKeySecret',
|
||||
securityToken: 'securityToken',
|
||||
bearerToken: 'bearerToken',
|
||||
protocol: 'protocol',
|
||||
method: 'method',
|
||||
regionId: 'regionId',
|
||||
readTimeout: 'readTimeout',
|
||||
connectTimeout: 'connectTimeout',
|
||||
httpProxy: 'httpProxy',
|
||||
httpsProxy: 'httpsProxy',
|
||||
credential: 'credential',
|
||||
endpoint: 'endpoint',
|
||||
noProxy: 'noProxy',
|
||||
maxIdleConns: 'maxIdleConns',
|
||||
network: 'network',
|
||||
userAgent: 'userAgent',
|
||||
suffix: 'suffix',
|
||||
socks5Proxy: 'socks5Proxy',
|
||||
socks5NetWork: 'socks5NetWork',
|
||||
endpointType: 'endpointType',
|
||||
openPlatformEndpoint: 'openPlatformEndpoint',
|
||||
type: 'type',
|
||||
signatureVersion: 'signatureVersion',
|
||||
signatureAlgorithm: 'signatureAlgorithm',
|
||||
globalParameters: 'globalParameters',
|
||||
key: 'key',
|
||||
cert: 'cert',
|
||||
ca: 'ca',
|
||||
disableHttp2: 'disableHttp2',
|
||||
tlsMinVersion: 'tlsMinVersion',
|
||||
};
|
||||
}
|
||||
static types() {
|
||||
return {
|
||||
accessKeyId: 'string',
|
||||
accessKeySecret: 'string',
|
||||
securityToken: 'string',
|
||||
bearerToken: 'string',
|
||||
protocol: 'string',
|
||||
method: 'string',
|
||||
regionId: 'string',
|
||||
readTimeout: 'number',
|
||||
connectTimeout: 'number',
|
||||
httpProxy: 'string',
|
||||
httpsProxy: 'string',
|
||||
credential: credentials_1.default,
|
||||
endpoint: 'string',
|
||||
noProxy: 'string',
|
||||
maxIdleConns: 'number',
|
||||
network: 'string',
|
||||
userAgent: 'string',
|
||||
suffix: 'string',
|
||||
socks5Proxy: 'string',
|
||||
socks5NetWork: 'string',
|
||||
endpointType: 'string',
|
||||
openPlatformEndpoint: 'string',
|
||||
type: 'string',
|
||||
signatureVersion: 'string',
|
||||
signatureAlgorithm: 'string',
|
||||
globalParameters: GlobalParameters,
|
||||
key: 'string',
|
||||
cert: 'string',
|
||||
ca: 'string',
|
||||
disableHttp2: 'boolean',
|
||||
tlsMinVersion: 'string',
|
||||
};
|
||||
}
|
||||
constructor(map) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
exports.Config = Config;
|
||||
class OpenApiRequest extends $tea.Model {
|
||||
static names() {
|
||||
return {
|
||||
headers: 'headers',
|
||||
query: 'query',
|
||||
body: 'body',
|
||||
stream: 'stream',
|
||||
hostMap: 'hostMap',
|
||||
endpointOverride: 'endpointOverride',
|
||||
};
|
||||
}
|
||||
static types() {
|
||||
return {
|
||||
headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
query: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
body: 'any',
|
||||
stream: 'Readable',
|
||||
hostMap: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
endpointOverride: 'string',
|
||||
};
|
||||
}
|
||||
constructor(map) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
exports.OpenApiRequest = OpenApiRequest;
|
||||
class Params extends $tea.Model {
|
||||
static names() {
|
||||
return {
|
||||
action: 'action',
|
||||
version: 'version',
|
||||
protocol: 'protocol',
|
||||
pathname: 'pathname',
|
||||
method: 'method',
|
||||
authType: 'authType',
|
||||
bodyType: 'bodyType',
|
||||
reqBodyType: 'reqBodyType',
|
||||
style: 'style',
|
||||
};
|
||||
}
|
||||
static types() {
|
||||
return {
|
||||
action: 'string',
|
||||
version: 'string',
|
||||
protocol: 'string',
|
||||
pathname: 'string',
|
||||
method: 'string',
|
||||
authType: 'string',
|
||||
bodyType: 'string',
|
||||
reqBodyType: 'string',
|
||||
style: 'string',
|
||||
};
|
||||
}
|
||||
constructor(map) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
exports.Params = Params;
|
||||
class Client {
|
||||
/**
|
||||
* @remarks
|
||||
* Init client with Config
|
||||
*
|
||||
* @param config - config contains the necessary information to create a client
|
||||
*/
|
||||
constructor(config) {
|
||||
if (tea_util_1.default.isUnset(config)) {
|
||||
throw $tea.newError({
|
||||
code: "ParameterMissing",
|
||||
message: "'config' can not be unset",
|
||||
});
|
||||
}
|
||||
if (!tea_util_1.default.empty(config.accessKeyId) && !tea_util_1.default.empty(config.accessKeySecret)) {
|
||||
if (!tea_util_1.default.empty(config.securityToken)) {
|
||||
config.type = "sts";
|
||||
}
|
||||
else {
|
||||
config.type = "access_key";
|
||||
}
|
||||
let credentialConfig = new $Credential.Config({
|
||||
accessKeyId: config.accessKeyId,
|
||||
type: config.type,
|
||||
accessKeySecret: config.accessKeySecret,
|
||||
});
|
||||
credentialConfig.securityToken = config.securityToken;
|
||||
this._credential = new credentials_1.default(credentialConfig);
|
||||
}
|
||||
else if (!tea_util_1.default.empty(config.bearerToken)) {
|
||||
let cc = new $Credential.Config({
|
||||
type: "bearer",
|
||||
bearerToken: config.bearerToken,
|
||||
});
|
||||
this._credential = new credentials_1.default(cc);
|
||||
}
|
||||
else if (!tea_util_1.default.isUnset(config.credential)) {
|
||||
this._credential = config.credential;
|
||||
}
|
||||
this._endpoint = config.endpoint;
|
||||
this._endpointType = config.endpointType;
|
||||
this._network = config.network;
|
||||
this._suffix = config.suffix;
|
||||
this._protocol = config.protocol;
|
||||
this._method = config.method;
|
||||
this._regionId = config.regionId;
|
||||
this._userAgent = config.userAgent;
|
||||
this._readTimeout = config.readTimeout;
|
||||
this._connectTimeout = config.connectTimeout;
|
||||
this._httpProxy = config.httpProxy;
|
||||
this._httpsProxy = config.httpsProxy;
|
||||
this._noProxy = config.noProxy;
|
||||
this._socks5Proxy = config.socks5Proxy;
|
||||
this._socks5NetWork = config.socks5NetWork;
|
||||
this._maxIdleConns = config.maxIdleConns;
|
||||
this._signatureVersion = config.signatureVersion;
|
||||
this._signatureAlgorithm = config.signatureAlgorithm;
|
||||
this._globalParameters = config.globalParameters;
|
||||
this._key = config.key;
|
||||
this._cert = config.cert;
|
||||
this._ca = config.ca;
|
||||
this._disableHttp2 = config.disableHttp2;
|
||||
this._tlsMinVersion = config.tlsMinVersion;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async doRPCRequest(action, version, protocol, method, authType, bodyType, request, runtime) {
|
||||
let _runtime = {
|
||||
timeouted: "retry",
|
||||
key: tea_util_1.default.defaultString(runtime.key, this._key),
|
||||
cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
|
||||
ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
};
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
request_.protocol = tea_util_1.default.defaultString(this._protocol, protocol);
|
||||
request_.method = method;
|
||||
request_.pathname = "/";
|
||||
let globalQueries = {};
|
||||
let globalHeaders = {};
|
||||
if (!tea_util_1.default.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!tea_util_1.default.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
}
|
||||
let extendsHeaders = {};
|
||||
let extendsQueries = {};
|
||||
if (!tea_util_1.default.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
}
|
||||
request_.query = Object.assign(Object.assign(Object.assign({ Action: action, Format: "json", Version: version, Timestamp: openapi_util_1.default.getTimestamp(), SignatureNonce: tea_util_1.default.getNonce() }, globalQueries), extendsQueries), request.query);
|
||||
let headers = this.getRpcHeaders();
|
||||
if (tea_util_1.default.isUnset(headers)) {
|
||||
// endpoint is setted in product client
|
||||
request_.headers = Object.assign(Object.assign(Object.assign({ host: this._endpoint, 'x-acs-version': version, 'x-acs-action': action, 'user-agent': this.getUserAgent() }, globalHeaders), extendsHeaders), request.headers);
|
||||
}
|
||||
else {
|
||||
request_.headers = Object.assign(Object.assign(Object.assign(Object.assign({ host: this._endpoint, 'x-acs-version': version, 'x-acs-action': action, 'user-agent': this.getUserAgent() }, globalHeaders), extendsHeaders), request.headers), headers);
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(request.body)) {
|
||||
let m = tea_util_1.default.assertAsMap(request.body);
|
||||
let tmp = tea_util_1.default.anyifyMapValue(openapi_util_1.default.query(m));
|
||||
request_.body = new $tea.BytesReadable(tea_util_1.default.toFormString(tmp));
|
||||
request_.headers["content-type"] = "application/x-www-form-urlencoded";
|
||||
}
|
||||
if (!tea_util_1.default.equalString(authType, "Anonymous")) {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
throw $tea.newError({
|
||||
code: `InvalidCredentials`,
|
||||
message: `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`,
|
||||
});
|
||||
}
|
||||
let credentialModel = await this._credential.getCredential();
|
||||
if (!tea_util_1.default.empty(credentialModel.providerName)) {
|
||||
request_.headers["x-acs-credentials-provider"] = credentialModel.providerName;
|
||||
}
|
||||
let credentialType = credentialModel.type;
|
||||
if (tea_util_1.default.equalString(credentialType, "bearer")) {
|
||||
let bearerToken = credentialModel.bearerToken;
|
||||
request_.query["BearerToken"] = bearerToken;
|
||||
request_.query["SignatureType"] = "BEARERTOKEN";
|
||||
}
|
||||
else if (tea_util_1.default.equalString(credentialType, "id_token")) {
|
||||
let idToken = credentialModel.securityToken;
|
||||
request_.headers["x-acs-zero-trust-idtoken"] = idToken;
|
||||
}
|
||||
else {
|
||||
let accessKeyId = credentialModel.accessKeyId;
|
||||
let accessKeySecret = credentialModel.accessKeySecret;
|
||||
let securityToken = credentialModel.securityToken;
|
||||
if (!tea_util_1.default.empty(securityToken)) {
|
||||
request_.query["SecurityToken"] = securityToken;
|
||||
}
|
||||
request_.query["SignatureMethod"] = "HMAC-SHA1";
|
||||
request_.query["SignatureVersion"] = "1.0";
|
||||
request_.query["AccessKeyId"] = accessKeyId;
|
||||
let t = null;
|
||||
if (!tea_util_1.default.isUnset(request.body)) {
|
||||
t = tea_util_1.default.assertAsMap(request.body);
|
||||
}
|
||||
let signedParam = Object.assign(Object.assign({}, request_.query), openapi_util_1.default.query(t));
|
||||
request_.query["Signature"] = openapi_util_1.default.getRPCSignature(signedParam, request_.method, accessKeySecret);
|
||||
}
|
||||
}
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
if (tea_util_1.default.is4xx(response_.statusCode) || tea_util_1.default.is5xx(response_.statusCode)) {
|
||||
let _res = await tea_util_1.default.readAsJSON(response_.body);
|
||||
let err = tea_util_1.default.assertAsMap(_res);
|
||||
let requestId = Client.defaultAny(err["RequestId"], err["requestId"]);
|
||||
err["statusCode"] = response_.statusCode;
|
||||
throw $tea.newError({
|
||||
code: `${Client.defaultAny(err["Code"], err["code"])}`,
|
||||
message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${requestId}`,
|
||||
data: err,
|
||||
description: `${Client.defaultAny(err["Description"], err["description"])}`,
|
||||
accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
|
||||
});
|
||||
}
|
||||
if (tea_util_1.default.equalString(bodyType, "binary")) {
|
||||
let resp = {
|
||||
body: response_.body,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
return resp;
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "byte")) {
|
||||
let byt = await tea_util_1.default.readAsBytes(response_.body);
|
||||
return {
|
||||
body: byt,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "string")) {
|
||||
let str = await tea_util_1.default.readAsString(response_.body);
|
||||
return {
|
||||
body: str,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "json")) {
|
||||
let obj = await tea_util_1.default.readAsJSON(response_.body);
|
||||
let res = tea_util_1.default.assertAsMap(obj);
|
||||
return {
|
||||
body: res,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "array")) {
|
||||
let arr = await tea_util_1.default.readAsJSON(response_.body);
|
||||
return {
|
||||
body: arr,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param pathname - pathname of every api
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async doROARequest(action, version, protocol, method, authType, pathname, bodyType, request, runtime) {
|
||||
let _runtime = {
|
||||
timeouted: "retry",
|
||||
key: tea_util_1.default.defaultString(runtime.key, this._key),
|
||||
cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
|
||||
ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
};
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
request_.protocol = tea_util_1.default.defaultString(this._protocol, protocol);
|
||||
request_.method = method;
|
||||
request_.pathname = pathname;
|
||||
let globalQueries = {};
|
||||
let globalHeaders = {};
|
||||
if (!tea_util_1.default.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!tea_util_1.default.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
}
|
||||
let extendsHeaders = {};
|
||||
let extendsQueries = {};
|
||||
if (!tea_util_1.default.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
}
|
||||
request_.headers = Object.assign(Object.assign(Object.assign({ date: tea_util_1.default.getDateUTCString(), host: this._endpoint, accept: "application/json", 'x-acs-signature-nonce': tea_util_1.default.getNonce(), 'x-acs-signature-method': "HMAC-SHA1", 'x-acs-signature-version': "1.0", 'x-acs-version': version, 'x-acs-action': action, 'user-agent': tea_util_1.default.getUserAgent(this._userAgent) }, globalHeaders), extendsHeaders), request.headers);
|
||||
if (!tea_util_1.default.isUnset(request.body)) {
|
||||
request_.body = new $tea.BytesReadable(tea_util_1.default.toJSONString(request.body));
|
||||
request_.headers["content-type"] = "application/json; charset=utf-8";
|
||||
}
|
||||
request_.query = Object.assign(Object.assign({}, globalQueries), extendsQueries);
|
||||
if (!tea_util_1.default.isUnset(request.query)) {
|
||||
request_.query = Object.assign(Object.assign({}, request_.query), request.query);
|
||||
}
|
||||
if (!tea_util_1.default.equalString(authType, "Anonymous")) {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
throw $tea.newError({
|
||||
code: `InvalidCredentials`,
|
||||
message: `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`,
|
||||
});
|
||||
}
|
||||
let credentialModel = await this._credential.getCredential();
|
||||
if (!tea_util_1.default.empty(credentialModel.providerName)) {
|
||||
request_.headers["x-acs-credentials-provider"] = credentialModel.providerName;
|
||||
}
|
||||
let credentialType = credentialModel.type;
|
||||
if (tea_util_1.default.equalString(credentialType, "bearer")) {
|
||||
let bearerToken = credentialModel.bearerToken;
|
||||
request_.headers["x-acs-bearer-token"] = bearerToken;
|
||||
request_.headers["x-acs-signature-type"] = "BEARERTOKEN";
|
||||
}
|
||||
else if (tea_util_1.default.equalString(credentialType, "id_token")) {
|
||||
let idToken = credentialModel.securityToken;
|
||||
request_.headers["x-acs-zero-trust-idtoken"] = idToken;
|
||||
}
|
||||
else {
|
||||
let accessKeyId = credentialModel.accessKeyId;
|
||||
let accessKeySecret = credentialModel.accessKeySecret;
|
||||
let securityToken = credentialModel.securityToken;
|
||||
if (!tea_util_1.default.empty(securityToken)) {
|
||||
request_.headers["x-acs-accesskey-id"] = accessKeyId;
|
||||
request_.headers["x-acs-security-token"] = securityToken;
|
||||
}
|
||||
let stringToSign = openapi_util_1.default.getStringToSign(request_);
|
||||
request_.headers["authorization"] = `acs ${accessKeyId}:${openapi_util_1.default.getROASignature(stringToSign, accessKeySecret)}`;
|
||||
}
|
||||
}
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
if (tea_util_1.default.equalNumber(response_.statusCode, 204)) {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
};
|
||||
}
|
||||
if (tea_util_1.default.is4xx(response_.statusCode) || tea_util_1.default.is5xx(response_.statusCode)) {
|
||||
let _res = await tea_util_1.default.readAsJSON(response_.body);
|
||||
let err = tea_util_1.default.assertAsMap(_res);
|
||||
let requestId = Client.defaultAny(err["RequestId"], err["requestId"]);
|
||||
requestId = Client.defaultAny(requestId, err["requestid"]);
|
||||
err["statusCode"] = response_.statusCode;
|
||||
throw $tea.newError({
|
||||
code: `${Client.defaultAny(err["Code"], err["code"])}`,
|
||||
message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${requestId}`,
|
||||
data: err,
|
||||
description: `${Client.defaultAny(err["Description"], err["description"])}`,
|
||||
accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
|
||||
});
|
||||
}
|
||||
if (tea_util_1.default.equalString(bodyType, "binary")) {
|
||||
let resp = {
|
||||
body: response_.body,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
return resp;
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "byte")) {
|
||||
let byt = await tea_util_1.default.readAsBytes(response_.body);
|
||||
return {
|
||||
body: byt,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "string")) {
|
||||
let str = await tea_util_1.default.readAsString(response_.body);
|
||||
return {
|
||||
body: str,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "json")) {
|
||||
let obj = await tea_util_1.default.readAsJSON(response_.body);
|
||||
let res = tea_util_1.default.assertAsMap(obj);
|
||||
return {
|
||||
body: res,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "array")) {
|
||||
let arr = await tea_util_1.default.readAsJSON(response_.body);
|
||||
return {
|
||||
body: arr,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network with form body
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param pathname - pathname of every api
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async doROARequestWithForm(action, version, protocol, method, authType, pathname, bodyType, request, runtime) {
|
||||
let _runtime = {
|
||||
timeouted: "retry",
|
||||
key: tea_util_1.default.defaultString(runtime.key, this._key),
|
||||
cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
|
||||
ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
};
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
request_.protocol = tea_util_1.default.defaultString(this._protocol, protocol);
|
||||
request_.method = method;
|
||||
request_.pathname = pathname;
|
||||
let globalQueries = {};
|
||||
let globalHeaders = {};
|
||||
if (!tea_util_1.default.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!tea_util_1.default.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
}
|
||||
let extendsHeaders = {};
|
||||
let extendsQueries = {};
|
||||
if (!tea_util_1.default.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
}
|
||||
request_.headers = Object.assign(Object.assign(Object.assign({ date: tea_util_1.default.getDateUTCString(), host: this._endpoint, accept: "application/json", 'x-acs-signature-nonce': tea_util_1.default.getNonce(), 'x-acs-signature-method': "HMAC-SHA1", 'x-acs-signature-version': "1.0", 'x-acs-version': version, 'x-acs-action': action, 'user-agent': tea_util_1.default.getUserAgent(this._userAgent) }, globalHeaders), extendsHeaders), request.headers);
|
||||
if (!tea_util_1.default.isUnset(request.body)) {
|
||||
let m = tea_util_1.default.assertAsMap(request.body);
|
||||
request_.body = new $tea.BytesReadable(openapi_util_1.default.toForm(m));
|
||||
request_.headers["content-type"] = "application/x-www-form-urlencoded";
|
||||
}
|
||||
request_.query = Object.assign(Object.assign({}, globalQueries), extendsQueries);
|
||||
if (!tea_util_1.default.isUnset(request.query)) {
|
||||
request_.query = Object.assign(Object.assign({}, request_.query), request.query);
|
||||
}
|
||||
if (!tea_util_1.default.equalString(authType, "Anonymous")) {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
throw $tea.newError({
|
||||
code: `InvalidCredentials`,
|
||||
message: `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`,
|
||||
});
|
||||
}
|
||||
let credentialModel = await this._credential.getCredential();
|
||||
if (!tea_util_1.default.empty(credentialModel.providerName)) {
|
||||
request_.headers["x-acs-credentials-provider"] = credentialModel.providerName;
|
||||
}
|
||||
let credentialType = credentialModel.type;
|
||||
if (tea_util_1.default.equalString(credentialType, "bearer")) {
|
||||
let bearerToken = credentialModel.bearerToken;
|
||||
request_.headers["x-acs-bearer-token"] = bearerToken;
|
||||
request_.headers["x-acs-signature-type"] = "BEARERTOKEN";
|
||||
}
|
||||
else if (tea_util_1.default.equalString(credentialType, "id_token")) {
|
||||
let idToken = credentialModel.securityToken;
|
||||
request_.headers["x-acs-zero-trust-idtoken"] = idToken;
|
||||
}
|
||||
else {
|
||||
let accessKeyId = credentialModel.accessKeyId;
|
||||
let accessKeySecret = credentialModel.accessKeySecret;
|
||||
let securityToken = credentialModel.securityToken;
|
||||
if (!tea_util_1.default.empty(securityToken)) {
|
||||
request_.headers["x-acs-accesskey-id"] = accessKeyId;
|
||||
request_.headers["x-acs-security-token"] = securityToken;
|
||||
}
|
||||
let stringToSign = openapi_util_1.default.getStringToSign(request_);
|
||||
request_.headers["authorization"] = `acs ${accessKeyId}:${openapi_util_1.default.getROASignature(stringToSign, accessKeySecret)}`;
|
||||
}
|
||||
}
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
if (tea_util_1.default.equalNumber(response_.statusCode, 204)) {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
};
|
||||
}
|
||||
if (tea_util_1.default.is4xx(response_.statusCode) || tea_util_1.default.is5xx(response_.statusCode)) {
|
||||
let _res = await tea_util_1.default.readAsJSON(response_.body);
|
||||
let err = tea_util_1.default.assertAsMap(_res);
|
||||
err["statusCode"] = response_.statusCode;
|
||||
throw $tea.newError({
|
||||
code: `${Client.defaultAny(err["Code"], err["code"])}`,
|
||||
message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${Client.defaultAny(err["RequestId"], err["requestId"])}`,
|
||||
data: err,
|
||||
description: `${Client.defaultAny(err["Description"], err["description"])}`,
|
||||
accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
|
||||
});
|
||||
}
|
||||
if (tea_util_1.default.equalString(bodyType, "binary")) {
|
||||
let resp = {
|
||||
body: response_.body,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
return resp;
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "byte")) {
|
||||
let byt = await tea_util_1.default.readAsBytes(response_.body);
|
||||
return {
|
||||
body: byt,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "string")) {
|
||||
let str = await tea_util_1.default.readAsString(response_.body);
|
||||
return {
|
||||
body: str,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "json")) {
|
||||
let obj = await tea_util_1.default.readAsJSON(response_.body);
|
||||
let res = tea_util_1.default.assertAsMap(obj);
|
||||
return {
|
||||
body: res,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(bodyType, "array")) {
|
||||
let arr = await tea_util_1.default.readAsJSON(response_.body);
|
||||
return {
|
||||
body: arr,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async doRequest(params, request, runtime) {
|
||||
let _runtime = {
|
||||
timeouted: "retry",
|
||||
key: tea_util_1.default.defaultString(runtime.key, this._key),
|
||||
cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
|
||||
ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
};
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
request_.protocol = tea_util_1.default.defaultString(this._protocol, params.protocol);
|
||||
request_.method = params.method;
|
||||
request_.pathname = params.pathname;
|
||||
let globalQueries = {};
|
||||
let globalHeaders = {};
|
||||
if (!tea_util_1.default.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!tea_util_1.default.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
}
|
||||
let extendsHeaders = {};
|
||||
let extendsQueries = {};
|
||||
if (!tea_util_1.default.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
}
|
||||
request_.query = Object.assign(Object.assign(Object.assign({}, globalQueries), extendsQueries), request.query);
|
||||
// endpoint is setted in product client
|
||||
request_.headers = Object.assign(Object.assign(Object.assign({ host: this._endpoint, 'x-acs-version': params.version, 'x-acs-action': params.action, 'user-agent': this.getUserAgent(), 'x-acs-date': openapi_util_1.default.getTimestamp(), 'x-acs-signature-nonce': tea_util_1.default.getNonce(), accept: "application/json" }, globalHeaders), extendsHeaders), request.headers);
|
||||
if (tea_util_1.default.equalString(params.style, "RPC")) {
|
||||
let headers = this.getRpcHeaders();
|
||||
if (!tea_util_1.default.isUnset(headers)) {
|
||||
request_.headers = Object.assign(Object.assign({}, request_.headers), headers);
|
||||
}
|
||||
}
|
||||
let signatureAlgorithm = tea_util_1.default.defaultString(this._signatureAlgorithm, "ACS3-HMAC-SHA256");
|
||||
let hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(tea_util_1.default.toBytes(""), signatureAlgorithm));
|
||||
if (!tea_util_1.default.isUnset(request.stream)) {
|
||||
let tmp = await tea_util_1.default.readAsBytes(request.stream);
|
||||
hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(tmp, signatureAlgorithm));
|
||||
request_.body = new $tea.BytesReadable(tmp);
|
||||
request_.headers["content-type"] = "application/octet-stream";
|
||||
}
|
||||
else {
|
||||
if (!tea_util_1.default.isUnset(request.body)) {
|
||||
if (tea_util_1.default.equalString(params.reqBodyType, "byte")) {
|
||||
let byteObj = tea_util_1.default.assertAsBytes(request.body);
|
||||
hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(byteObj, signatureAlgorithm));
|
||||
request_.body = new $tea.BytesReadable(byteObj);
|
||||
}
|
||||
else if (tea_util_1.default.equalString(params.reqBodyType, "json")) {
|
||||
let jsonObj = tea_util_1.default.toJSONString(request.body);
|
||||
hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(tea_util_1.default.toBytes(jsonObj), signatureAlgorithm));
|
||||
request_.body = new $tea.BytesReadable(jsonObj);
|
||||
request_.headers["content-type"] = "application/json; charset=utf-8";
|
||||
}
|
||||
else {
|
||||
let m = tea_util_1.default.assertAsMap(request.body);
|
||||
let formObj = openapi_util_1.default.toForm(m);
|
||||
hashedRequestPayload = openapi_util_1.default.hexEncode(openapi_util_1.default.hash(tea_util_1.default.toBytes(formObj), signatureAlgorithm));
|
||||
request_.body = new $tea.BytesReadable(formObj);
|
||||
request_.headers["content-type"] = "application/x-www-form-urlencoded";
|
||||
}
|
||||
}
|
||||
}
|
||||
request_.headers["x-acs-content-sha256"] = hashedRequestPayload;
|
||||
if (!tea_util_1.default.equalString(params.authType, "Anonymous")) {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
throw $tea.newError({
|
||||
code: `InvalidCredentials`,
|
||||
message: `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`,
|
||||
});
|
||||
}
|
||||
let credentialModel = await this._credential.getCredential();
|
||||
if (!tea_util_1.default.empty(credentialModel.providerName)) {
|
||||
request_.headers["x-acs-credentials-provider"] = credentialModel.providerName;
|
||||
}
|
||||
let authType = credentialModel.type;
|
||||
if (tea_util_1.default.equalString(authType, "bearer")) {
|
||||
let bearerToken = credentialModel.bearerToken;
|
||||
request_.headers["x-acs-bearer-token"] = bearerToken;
|
||||
if (tea_util_1.default.equalString(params.style, "RPC")) {
|
||||
request_.query["SignatureType"] = "BEARERTOKEN";
|
||||
}
|
||||
else {
|
||||
request_.headers["x-acs-signature-type"] = "BEARERTOKEN";
|
||||
}
|
||||
}
|
||||
else if (tea_util_1.default.equalString(authType, "id_token")) {
|
||||
let idToken = credentialModel.securityToken;
|
||||
request_.headers["x-acs-zero-trust-idtoken"] = idToken;
|
||||
}
|
||||
else {
|
||||
let accessKeyId = credentialModel.accessKeyId;
|
||||
let accessKeySecret = credentialModel.accessKeySecret;
|
||||
let securityToken = credentialModel.securityToken;
|
||||
if (!tea_util_1.default.empty(securityToken)) {
|
||||
request_.headers["x-acs-accesskey-id"] = accessKeyId;
|
||||
request_.headers["x-acs-security-token"] = securityToken;
|
||||
}
|
||||
request_.headers["Authorization"] = openapi_util_1.default.getAuthorization(request_, signatureAlgorithm, hashedRequestPayload, accessKeyId, accessKeySecret);
|
||||
}
|
||||
}
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
if (tea_util_1.default.is4xx(response_.statusCode) || tea_util_1.default.is5xx(response_.statusCode)) {
|
||||
let err = {};
|
||||
if (!tea_util_1.default.isUnset(response_.headers["content-type"]) && tea_util_1.default.equalString(response_.headers["content-type"], "text/xml;charset=utf-8")) {
|
||||
let _str = await tea_util_1.default.readAsString(response_.body);
|
||||
let respMap = tea_xml_1.default.parseXml(_str, null);
|
||||
err = tea_util_1.default.assertAsMap(respMap["Error"]);
|
||||
}
|
||||
else {
|
||||
let _res = await tea_util_1.default.readAsJSON(response_.body);
|
||||
err = tea_util_1.default.assertAsMap(_res);
|
||||
}
|
||||
err["statusCode"] = response_.statusCode;
|
||||
throw $tea.newError({
|
||||
code: `${Client.defaultAny(err["Code"], err["code"])}`,
|
||||
message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${Client.defaultAny(err["RequestId"], err["requestId"])}`,
|
||||
data: err,
|
||||
description: `${Client.defaultAny(err["Description"], err["description"])}`,
|
||||
accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
|
||||
});
|
||||
}
|
||||
if (tea_util_1.default.equalString(params.bodyType, "binary")) {
|
||||
let resp = {
|
||||
body: response_.body,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
return resp;
|
||||
}
|
||||
else if (tea_util_1.default.equalString(params.bodyType, "byte")) {
|
||||
let byt = await tea_util_1.default.readAsBytes(response_.body);
|
||||
return {
|
||||
body: byt,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(params.bodyType, "string")) {
|
||||
let str = await tea_util_1.default.readAsString(response_.body);
|
||||
return {
|
||||
body: str,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(params.bodyType, "json")) {
|
||||
let obj = await tea_util_1.default.readAsJSON(response_.body);
|
||||
let res = tea_util_1.default.assertAsMap(obj);
|
||||
return {
|
||||
body: res,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else if (tea_util_1.default.equalString(params.bodyType, "array")) {
|
||||
let arr = await tea_util_1.default.readAsJSON(response_.body);
|
||||
return {
|
||||
body: arr,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
else {
|
||||
let anything = await tea_util_1.default.readAsString(response_.body);
|
||||
return {
|
||||
body: anything,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async execute(params, request, runtime) {
|
||||
let _runtime = {
|
||||
timeouted: "retry",
|
||||
key: tea_util_1.default.defaultString(runtime.key, this._key),
|
||||
cert: tea_util_1.default.defaultString(runtime.cert, this._cert),
|
||||
ca: tea_util_1.default.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: tea_util_1.default.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: tea_util_1.default.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: tea_util_1.default.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: tea_util_1.default.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: tea_util_1.default.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: tea_util_1.default.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: tea_util_1.default.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: tea_util_1.default.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: tea_util_1.default.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: tea_util_1.default.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: tea_util_1.default.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
disableHttp2: Client.defaultAny(this._disableHttp2, false),
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
};
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
// spi = new Gateway();//Gateway implements SPI,这一步在产品 SDK 中实例化
|
||||
let headers = this.getRpcHeaders();
|
||||
let globalQueries = {};
|
||||
let globalHeaders = {};
|
||||
if (!tea_util_1.default.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!tea_util_1.default.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
}
|
||||
let extendsHeaders = {};
|
||||
let extendsQueries = {};
|
||||
if (!tea_util_1.default.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
if (!tea_util_1.default.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
}
|
||||
let requestContext = new $SPI.InterceptorContextRequest({
|
||||
headers: Object.assign(Object.assign(Object.assign(Object.assign({}, globalHeaders), extendsHeaders), request.headers), headers),
|
||||
query: Object.assign(Object.assign(Object.assign({}, globalQueries), extendsQueries), request.query),
|
||||
body: request.body,
|
||||
stream: request.stream,
|
||||
hostMap: request.hostMap,
|
||||
pathname: params.pathname,
|
||||
productId: this._productId,
|
||||
action: params.action,
|
||||
version: params.version,
|
||||
protocol: tea_util_1.default.defaultString(this._protocol, params.protocol),
|
||||
method: tea_util_1.default.defaultString(this._method, params.method),
|
||||
authType: params.authType,
|
||||
bodyType: params.bodyType,
|
||||
reqBodyType: params.reqBodyType,
|
||||
style: params.style,
|
||||
credential: this._credential,
|
||||
signatureVersion: this._signatureVersion,
|
||||
signatureAlgorithm: this._signatureAlgorithm,
|
||||
userAgent: this.getUserAgent(),
|
||||
});
|
||||
let configurationContext = new $SPI.InterceptorContextConfiguration({
|
||||
regionId: this._regionId,
|
||||
endpoint: tea_util_1.default.defaultString(request.endpointOverride, this._endpoint),
|
||||
endpointRule: this._endpointRule,
|
||||
endpointMap: this._endpointMap,
|
||||
endpointType: this._endpointType,
|
||||
network: this._network,
|
||||
suffix: this._suffix,
|
||||
});
|
||||
let interceptorContext = new $SPI.InterceptorContext({});
|
||||
interceptorContext.request = requestContext;
|
||||
interceptorContext.configuration = configurationContext;
|
||||
let attributeMap = new $SPI.AttributeMap({});
|
||||
if (!tea_util_1.default.isUnset(this._attributeMap)) {
|
||||
attributeMap = this._attributeMap;
|
||||
}
|
||||
// 1. spi.modifyConfiguration(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
|
||||
await this._spi.modifyConfiguration(interceptorContext, attributeMap);
|
||||
// 2. spi.modifyRequest(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
|
||||
await this._spi.modifyRequest(interceptorContext, attributeMap);
|
||||
request_.protocol = interceptorContext.request.protocol;
|
||||
request_.method = interceptorContext.request.method;
|
||||
request_.pathname = interceptorContext.request.pathname;
|
||||
request_.query = interceptorContext.request.query;
|
||||
request_.body = interceptorContext.request.stream;
|
||||
request_.headers = interceptorContext.request.headers;
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
let responseContext = new $SPI.InterceptorContextResponse({
|
||||
statusCode: response_.statusCode,
|
||||
headers: response_.headers,
|
||||
body: response_.body,
|
||||
});
|
||||
interceptorContext.response = responseContext;
|
||||
// 3. spi.modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
|
||||
await this._spi.modifyResponse(interceptorContext, attributeMap);
|
||||
return {
|
||||
headers: interceptorContext.response.headers,
|
||||
statusCode: interceptorContext.response.statusCode,
|
||||
body: interceptorContext.response.deserializedBody,
|
||||
};
|
||||
}
|
||||
catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
async callApi(params, request, runtime) {
|
||||
if (tea_util_1.default.isUnset(params)) {
|
||||
throw $tea.newError({
|
||||
code: "ParameterMissing",
|
||||
message: "'params' can not be unset",
|
||||
});
|
||||
}
|
||||
if (tea_util_1.default.isUnset(this._signatureVersion) || !tea_util_1.default.equalString(this._signatureVersion, "v4")) {
|
||||
if (tea_util_1.default.isUnset(this._signatureAlgorithm) || !tea_util_1.default.equalString(this._signatureAlgorithm, "v2")) {
|
||||
return await this.doRequest(params, request, runtime);
|
||||
}
|
||||
else if (tea_util_1.default.equalString(params.style, "ROA") && tea_util_1.default.equalString(params.reqBodyType, "json")) {
|
||||
return await this.doROARequest(params.action, params.version, params.protocol, params.method, params.authType, params.pathname, params.bodyType, request, runtime);
|
||||
}
|
||||
else if (tea_util_1.default.equalString(params.style, "ROA")) {
|
||||
return await this.doROARequestWithForm(params.action, params.version, params.protocol, params.method, params.authType, params.pathname, params.bodyType, request, runtime);
|
||||
}
|
||||
else {
|
||||
return await this.doRPCRequest(params.action, params.version, params.protocol, params.method, params.authType, params.bodyType, request, runtime);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return await this.execute(params, request, runtime);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Get user agent
|
||||
* @returns user agent
|
||||
*/
|
||||
getUserAgent() {
|
||||
let userAgent = tea_util_1.default.getUserAgent(this._userAgent);
|
||||
return userAgent;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Get accesskey id by using credential
|
||||
* @returns accesskey id
|
||||
*/
|
||||
async getAccessKeyId() {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
let accessKeyId = await this._credential.getAccessKeyId();
|
||||
return accessKeyId;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Get accesskey secret by using credential
|
||||
* @returns accesskey secret
|
||||
*/
|
||||
async getAccessKeySecret() {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
let secret = await this._credential.getAccessKeySecret();
|
||||
return secret;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Get security token by using credential
|
||||
* @returns security token
|
||||
*/
|
||||
async getSecurityToken() {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
let token = await this._credential.getSecurityToken();
|
||||
return token;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Get bearer token by credential
|
||||
* @returns bearer token
|
||||
*/
|
||||
async getBearerToken() {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
let token = this._credential.getBearerToken();
|
||||
return token;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* Get credential type by credential
|
||||
* @returns credential type e.g. access_key
|
||||
*/
|
||||
async getType() {
|
||||
if (tea_util_1.default.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
let authType = this._credential.getType();
|
||||
return authType;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* If inputValue is not null, return it or return defaultValue
|
||||
*
|
||||
* @param inputValue - users input value
|
||||
* @param defaultValue - default value
|
||||
* @returns the final result
|
||||
*/
|
||||
static defaultAny(inputValue, defaultValue) {
|
||||
if (tea_util_1.default.isUnset(inputValue)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return inputValue;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* If the endpointRule and config.endpoint are empty, throw error
|
||||
*
|
||||
* @param config - config contains the necessary information to create a client
|
||||
*/
|
||||
checkConfig(config) {
|
||||
if (tea_util_1.default.empty(this._endpointRule) && tea_util_1.default.empty(config.endpoint)) {
|
||||
throw $tea.newError({
|
||||
code: "ParameterMissing",
|
||||
message: "'config.endpoint' can not be empty",
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* set gateway client
|
||||
*
|
||||
* @param spi - .
|
||||
*/
|
||||
setGatewayClient(spi) {
|
||||
this._spi = spi;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* set RPC header for debug
|
||||
*
|
||||
* @param headers - headers for debug, this header can be used only once.
|
||||
*/
|
||||
setRpcHeaders(headers) {
|
||||
this._headers = headers;
|
||||
}
|
||||
/**
|
||||
* @remarks
|
||||
* get RPC header for debug
|
||||
*/
|
||||
getRpcHeaders() {
|
||||
let headers = this._headers;
|
||||
this._headers = null;
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
exports.default = Client;
|
||||
//# sourceMappingURL=client.js.map
|
||||
1
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/dist/client.js.map
generated
vendored
Normal file
1
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/dist/client.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
20
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/ChangeLog.txt
generated
vendored
Normal file
20
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/ChangeLog.txt
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
2024-07-08 Version 1.4.9
|
||||
1. Support extends query parameters
|
||||
|
||||
2024-05-13 Version 1.4.8
|
||||
1. Support extends parameters
|
||||
|
||||
2023-06-28 Version: 1.4.7
|
||||
1. Support static method `assertAsReadable()`
|
||||
|
||||
2023-06-26 Version: 1.4.6
|
||||
1. Support static method `assertAsInteger()`
|
||||
|
||||
2022-11-16 Version: 1.4.5
|
||||
1. Support ca params for server and client
|
||||
|
||||
2020-03-03 Version: 1.2.3
|
||||
1. Release version 1.2.3
|
||||
|
||||
2020-02-10 Version: 1.0.0
|
||||
1. Release version 1.0.0
|
||||
29
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/README.md
generated
vendored
Normal file
29
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/README.md
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
English | [简体中文](README-CN.md)
|
||||

|
||||
|
||||
## Alibaba Cloud Tea Util SDK for TypeScript/Node.js
|
||||
|
||||
## Prerequisite
|
||||
|
||||
Node.js >= 8.x
|
||||
|
||||
## Installation
|
||||
If you use `npm` to manage your dependence, you can use the following command to install it and write into package.json dependences:
|
||||
|
||||
```sh
|
||||
$ npm install @alicloud/tea-util -S
|
||||
```
|
||||
|
||||
## Issues
|
||||
[Opening an Issue](https://github.com/aliyun/tea-util/issues/new), Issues not conforming to the guidelines may be closed immediately.
|
||||
|
||||
## Changelog
|
||||
Detailed changes for each release are documented in the [release notes](./ChangeLog.txt).
|
||||
|
||||
## References
|
||||
* [Latest Release](https://github.com/aliyun/tea-util/tree/master/ts)
|
||||
|
||||
## License
|
||||
[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
108
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/dist/client.d.ts
generated
vendored
Normal file
108
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/dist/client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
/// <reference types="node" />
|
||||
import { Readable } from 'stream';
|
||||
import * as $tea from '@alicloud/tea-typescript';
|
||||
export declare class ExtendsParameters extends $tea.Model {
|
||||
headers?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
queries?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
static names(): {
|
||||
[key: string]: string;
|
||||
};
|
||||
static types(): {
|
||||
[key: string]: any;
|
||||
};
|
||||
constructor(map?: {
|
||||
[key: string]: any;
|
||||
});
|
||||
}
|
||||
export declare class RuntimeOptions extends $tea.Model {
|
||||
autoretry?: boolean;
|
||||
ignoreSSL?: boolean;
|
||||
key?: string;
|
||||
cert?: string;
|
||||
ca?: string;
|
||||
maxAttempts?: number;
|
||||
backoffPolicy?: string;
|
||||
backoffPeriod?: number;
|
||||
readTimeout?: number;
|
||||
connectTimeout?: number;
|
||||
httpProxy?: string;
|
||||
httpsProxy?: string;
|
||||
noProxy?: string;
|
||||
maxIdleConns?: number;
|
||||
keepAlive?: boolean;
|
||||
extendsParameters?: ExtendsParameters;
|
||||
static names(): {
|
||||
[key: string]: string;
|
||||
};
|
||||
static types(): {
|
||||
[key: string]: any;
|
||||
};
|
||||
constructor(map?: {
|
||||
[key: string]: any;
|
||||
});
|
||||
}
|
||||
export default class Client {
|
||||
static toString(buff: Buffer): string;
|
||||
static parseJSON(text: string): any;
|
||||
static readAsBytes(stream: Readable): Promise<Buffer>;
|
||||
static readAsString(stream: Readable): Promise<string>;
|
||||
static readAsJSON(stream: Readable): Promise<any>;
|
||||
static getNonce(): string;
|
||||
static getDateUTCString(): string;
|
||||
static defaultString(real: string, defaultValue: string): string;
|
||||
static defaultNumber(real: number, defaultValue: number): number;
|
||||
static toFormString(val: {
|
||||
[key: string]: any;
|
||||
}): string;
|
||||
static toJSONString(val: any): string;
|
||||
static toBytes(val: string): Buffer;
|
||||
static empty(val: string): boolean;
|
||||
static equalString(val1: string, val2: string): boolean;
|
||||
static equalNumber(val1: number, val2: number): boolean;
|
||||
static isUnset(value: any): boolean;
|
||||
static stringifyMapValue(m: {
|
||||
[key: string]: any;
|
||||
}): {
|
||||
[key: string]: string;
|
||||
};
|
||||
static anyifyMapValue(m: {
|
||||
[key: string]: string;
|
||||
}): {
|
||||
[key: string]: any;
|
||||
};
|
||||
static assertAsBoolean(value: any): boolean;
|
||||
static assertAsString(value: any): string;
|
||||
static assertAsNumber(value: any): number;
|
||||
/**
|
||||
* Assert a value, if it is a integer, return it, otherwise throws
|
||||
* @return the integer value
|
||||
*/
|
||||
static assertAsInteger(value: any): number;
|
||||
static assertAsMap(value: any): {
|
||||
[key: string]: any;
|
||||
};
|
||||
static assertAsArray(value: any): any[];
|
||||
static assertAsBytes(value: any): Buffer;
|
||||
static getUserAgent(userAgent: string): string;
|
||||
static is2xx(code: number): boolean;
|
||||
static is3xx(code: number): boolean;
|
||||
static is4xx(code: number): boolean;
|
||||
static is5xx(code: number): boolean;
|
||||
static validateModel(m: $tea.Model): void;
|
||||
static toMap(inputModel: $tea.Model): {
|
||||
[key: string]: any;
|
||||
};
|
||||
static sleep(millisecond: number): Promise<void>;
|
||||
static toArray(input: any): {
|
||||
[key: string]: any;
|
||||
}[];
|
||||
/**
|
||||
* Assert a value, if it is a readable, return it, otherwise throws
|
||||
* @return the readable value
|
||||
*/
|
||||
static assertAsReadable(value: any): Readable;
|
||||
}
|
||||
301
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/dist/client.js
generated
vendored
Normal file
301
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/dist/client.js
generated
vendored
Normal file
@@ -0,0 +1,301 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RuntimeOptions = exports.ExtendsParameters = void 0;
|
||||
const stream_1 = require("stream");
|
||||
const $tea = __importStar(require("@alicloud/tea-typescript"));
|
||||
const kitx = __importStar(require("kitx"));
|
||||
const querystring_1 = __importDefault(require("querystring"));
|
||||
const os_1 = require("os");
|
||||
const DEFAULT_USER_AGENT = `AlibabaCloud (${os_1.platform()}; ${os_1.arch()}) Node.js/${process.version} Core/1.0.1 TeaDSL/1`;
|
||||
class ExtendsParameters extends $tea.Model {
|
||||
constructor(map) {
|
||||
super(map);
|
||||
}
|
||||
static names() {
|
||||
return {
|
||||
headers: 'headers',
|
||||
queries: 'queries',
|
||||
};
|
||||
}
|
||||
static types() {
|
||||
return {
|
||||
headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
queries: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.ExtendsParameters = ExtendsParameters;
|
||||
class RuntimeOptions extends $tea.Model {
|
||||
constructor(map) {
|
||||
super(map);
|
||||
}
|
||||
static names() {
|
||||
return {
|
||||
autoretry: 'autoretry',
|
||||
ignoreSSL: 'ignoreSSL',
|
||||
key: 'key',
|
||||
cert: 'cert',
|
||||
ca: 'ca',
|
||||
maxAttempts: 'max_attempts',
|
||||
backoffPolicy: 'backoff_policy',
|
||||
backoffPeriod: 'backoff_period',
|
||||
readTimeout: 'readTimeout',
|
||||
connectTimeout: 'connectTimeout',
|
||||
httpProxy: 'httpProxy',
|
||||
httpsProxy: 'httpsProxy',
|
||||
noProxy: 'noProxy',
|
||||
maxIdleConns: 'maxIdleConns',
|
||||
keepAlive: 'keepAlive',
|
||||
extendsParameters: 'extendsParameters',
|
||||
};
|
||||
}
|
||||
static types() {
|
||||
return {
|
||||
autoretry: 'boolean',
|
||||
ignoreSSL: 'boolean',
|
||||
key: 'string',
|
||||
cert: 'string',
|
||||
ca: 'string',
|
||||
maxAttempts: 'number',
|
||||
backoffPolicy: 'string',
|
||||
backoffPeriod: 'number',
|
||||
readTimeout: 'number',
|
||||
connectTimeout: 'number',
|
||||
httpProxy: 'string',
|
||||
httpsProxy: 'string',
|
||||
noProxy: 'string',
|
||||
maxIdleConns: 'number',
|
||||
keepAlive: 'boolean',
|
||||
extendsParameters: ExtendsParameters,
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.RuntimeOptions = RuntimeOptions;
|
||||
function read(readable) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let onData, onError, onEnd;
|
||||
var cleanup = function () {
|
||||
// cleanup
|
||||
readable.removeListener('error', onError);
|
||||
readable.removeListener('data', onData);
|
||||
readable.removeListener('end', onEnd);
|
||||
};
|
||||
var bufs = [];
|
||||
var size = 0;
|
||||
onData = function (buf) {
|
||||
bufs.push(buf);
|
||||
size += buf.length;
|
||||
};
|
||||
onError = function (err) {
|
||||
cleanup();
|
||||
reject(err);
|
||||
};
|
||||
onEnd = function () {
|
||||
cleanup();
|
||||
resolve(Buffer.concat(bufs, size));
|
||||
};
|
||||
readable.on('error', onError);
|
||||
readable.on('data', onData);
|
||||
readable.on('end', onEnd);
|
||||
});
|
||||
}
|
||||
class Client {
|
||||
static toString(buff) {
|
||||
return buff.toString();
|
||||
}
|
||||
static parseJSON(text) {
|
||||
return JSON.parse(text);
|
||||
}
|
||||
static async readAsBytes(stream) {
|
||||
return await read(stream);
|
||||
}
|
||||
static async readAsString(stream) {
|
||||
let buff = await Client.readAsBytes(stream);
|
||||
return Client.toString(buff);
|
||||
}
|
||||
static async readAsJSON(stream) {
|
||||
return Client.parseJSON(await Client.readAsString(stream));
|
||||
}
|
||||
static getNonce() {
|
||||
return kitx.makeNonce();
|
||||
}
|
||||
static getDateUTCString() {
|
||||
const now = new Date();
|
||||
return now.toUTCString();
|
||||
}
|
||||
static defaultString(real, defaultValue) {
|
||||
return real || defaultValue;
|
||||
}
|
||||
static defaultNumber(real, defaultValue) {
|
||||
return real || defaultValue;
|
||||
}
|
||||
static toFormString(val) {
|
||||
return querystring_1.default.stringify(val);
|
||||
}
|
||||
static toJSONString(val) {
|
||||
if (typeof val === 'string') {
|
||||
return val;
|
||||
}
|
||||
return JSON.stringify(val);
|
||||
}
|
||||
static toBytes(val) {
|
||||
return Buffer.from(val);
|
||||
}
|
||||
static empty(val) {
|
||||
return !val;
|
||||
}
|
||||
static equalString(val1, val2) {
|
||||
return val1 === val2;
|
||||
}
|
||||
static equalNumber(val1, val2) {
|
||||
return val1 === val2;
|
||||
}
|
||||
static isUnset(value) {
|
||||
if (typeof value === 'undefined') {
|
||||
return true;
|
||||
}
|
||||
if (value === null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static stringifyMapValue(m) {
|
||||
if (!m) {
|
||||
return m;
|
||||
}
|
||||
const result = {};
|
||||
for (const [key, value] of Object.entries(m)) {
|
||||
if (typeof value === 'undefined' || value === null) {
|
||||
continue;
|
||||
}
|
||||
result[key] = String(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
static anyifyMapValue(m) {
|
||||
return m;
|
||||
}
|
||||
static assertAsBoolean(value) {
|
||||
if (typeof value === 'boolean') {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a boolean`);
|
||||
}
|
||||
static assertAsString(value) {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a string`);
|
||||
}
|
||||
static assertAsNumber(value) {
|
||||
if (typeof value === 'number') {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a number`);
|
||||
}
|
||||
/**
|
||||
* Assert a value, if it is a integer, return it, otherwise throws
|
||||
* @return the integer value
|
||||
*/
|
||||
static assertAsInteger(value) {
|
||||
if (Number.isInteger(value)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a int number`);
|
||||
}
|
||||
static assertAsMap(value) {
|
||||
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a object`);
|
||||
}
|
||||
static assertAsArray(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not array`);
|
||||
}
|
||||
static assertAsBytes(value) {
|
||||
if (Buffer.isBuffer(value)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not bytes`);
|
||||
}
|
||||
static getUserAgent(userAgent) {
|
||||
if (!userAgent || !userAgent.length) {
|
||||
return DEFAULT_USER_AGENT;
|
||||
}
|
||||
return DEFAULT_USER_AGENT + " " + userAgent;
|
||||
}
|
||||
static is2xx(code) {
|
||||
return code >= 200 && code < 300;
|
||||
}
|
||||
static is3xx(code) {
|
||||
return code >= 300 && code < 400;
|
||||
}
|
||||
static is4xx(code) {
|
||||
return code >= 400 && code < 500;
|
||||
}
|
||||
static is5xx(code) {
|
||||
return code >= 500 && code < 600;
|
||||
}
|
||||
static validateModel(m) {
|
||||
}
|
||||
static toMap(inputModel) {
|
||||
return $tea.toMap(inputModel);
|
||||
}
|
||||
static async sleep(millisecond) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, millisecond);
|
||||
});
|
||||
}
|
||||
static toArray(input) {
|
||||
if (!(input instanceof Array)) {
|
||||
return null;
|
||||
}
|
||||
let ret = [];
|
||||
input.forEach((model) => {
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
ret.push($tea.toMap(model));
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* Assert a value, if it is a readable, return it, otherwise throws
|
||||
* @return the readable value
|
||||
*/
|
||||
static assertAsReadable(value) {
|
||||
if (value instanceof stream_1.Readable) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a readable`);
|
||||
}
|
||||
}
|
||||
exports.default = Client;
|
||||
//# sourceMappingURL=client.js.map
|
||||
1
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/dist/client.js.map
generated
vendored
Normal file
1
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/dist/client.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
32
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/package.json
generated
vendored
Normal file
32
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/package.json
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@alicloud/tea-util",
|
||||
"version": "1.4.9",
|
||||
"description": "",
|
||||
"main": "dist/client.js",
|
||||
"scripts": {
|
||||
"test": "mocha -r ts-node/register -r source-map-support/register test/**/*.spec.ts",
|
||||
"test-cov": "nyc -e .ts -r=html -r=text -r=lcov npm run test",
|
||||
"build": "tsc",
|
||||
"prepublishOnly": "tsc"
|
||||
},
|
||||
"author": "Jackson Tian",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^7.0.1",
|
||||
"@types/node": "^12.12.26",
|
||||
"mocha": "^7.0.1",
|
||||
"nyc": "^15.0.0",
|
||||
"source-map-support": "^0.5.16",
|
||||
"ts-node": "^8.6.2",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alicloud/tea-typescript": "^1.5.1",
|
||||
"kitx": "^2.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"repository": "git@github.com:aliyun/tea-util.git"
|
||||
}
|
||||
343
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/src/client.ts
generated
vendored
Normal file
343
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/node_modules/@alicloud/tea-util/src/client.ts
generated
vendored
Normal file
@@ -0,0 +1,343 @@
|
||||
import { Readable } from 'stream';
|
||||
import * as $tea from '@alicloud/tea-typescript';
|
||||
import * as kitx from 'kitx';
|
||||
import querystring from 'querystring';
|
||||
import { platform, arch } from 'os';
|
||||
const DEFAULT_USER_AGENT = `AlibabaCloud (${platform()}; ${arch()}) Node.js/${process.version} Core/1.0.1 TeaDSL/1`;
|
||||
|
||||
export class ExtendsParameters extends $tea.Model {
|
||||
headers?: { [key: string]: string };
|
||||
queries?: { [key: string]: string };
|
||||
static names(): { [key: string]: string } {
|
||||
return {
|
||||
headers: 'headers',
|
||||
queries: 'queries',
|
||||
};
|
||||
}
|
||||
|
||||
static types(): { [key: string]: any } {
|
||||
return {
|
||||
headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
queries: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
};
|
||||
}
|
||||
|
||||
constructor(map?: { [key: string]: any }) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
|
||||
export class RuntimeOptions extends $tea.Model {
|
||||
autoretry?: boolean;
|
||||
ignoreSSL?: boolean;
|
||||
key?: string;
|
||||
cert?: string;
|
||||
ca?: string;
|
||||
maxAttempts?: number;
|
||||
backoffPolicy?: string;
|
||||
backoffPeriod?: number;
|
||||
readTimeout?: number;
|
||||
connectTimeout?: number;
|
||||
httpProxy?: string;
|
||||
httpsProxy?: string;
|
||||
noProxy?: string;
|
||||
maxIdleConns?: number;
|
||||
keepAlive?: boolean;
|
||||
extendsParameters?: ExtendsParameters;
|
||||
static names(): { [key: string]: string } {
|
||||
return {
|
||||
autoretry: 'autoretry',
|
||||
ignoreSSL: 'ignoreSSL',
|
||||
key: 'key',
|
||||
cert: 'cert',
|
||||
ca: 'ca',
|
||||
maxAttempts: 'max_attempts',
|
||||
backoffPolicy: 'backoff_policy',
|
||||
backoffPeriod: 'backoff_period',
|
||||
readTimeout: 'readTimeout',
|
||||
connectTimeout: 'connectTimeout',
|
||||
httpProxy: 'httpProxy',
|
||||
httpsProxy: 'httpsProxy',
|
||||
noProxy: 'noProxy',
|
||||
maxIdleConns: 'maxIdleConns',
|
||||
keepAlive: 'keepAlive',
|
||||
extendsParameters: 'extendsParameters',
|
||||
};
|
||||
}
|
||||
|
||||
static types(): { [key: string]: any } {
|
||||
return {
|
||||
autoretry: 'boolean',
|
||||
ignoreSSL: 'boolean',
|
||||
key: 'string',
|
||||
cert: 'string',
|
||||
ca: 'string',
|
||||
maxAttempts: 'number',
|
||||
backoffPolicy: 'string',
|
||||
backoffPeriod: 'number',
|
||||
readTimeout: 'number',
|
||||
connectTimeout: 'number',
|
||||
httpProxy: 'string',
|
||||
httpsProxy: 'string',
|
||||
noProxy: 'string',
|
||||
maxIdleConns: 'number',
|
||||
keepAlive: 'boolean',
|
||||
extendsParameters: ExtendsParameters,
|
||||
};
|
||||
}
|
||||
|
||||
constructor(map?: { [key: string]: any }) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
|
||||
function read(readable: Readable): Promise<Buffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let onData, onError, onEnd;
|
||||
var cleanup = function () {
|
||||
// cleanup
|
||||
readable.removeListener('error', onError);
|
||||
readable.removeListener('data', onData);
|
||||
readable.removeListener('end', onEnd);
|
||||
};
|
||||
|
||||
var bufs = [];
|
||||
var size = 0;
|
||||
|
||||
onData = function (buf) {
|
||||
bufs.push(buf);
|
||||
size += buf.length;
|
||||
};
|
||||
|
||||
onError = function (err) {
|
||||
cleanup();
|
||||
reject(err);
|
||||
};
|
||||
|
||||
onEnd = function () {
|
||||
cleanup();
|
||||
resolve(Buffer.concat(bufs, size));
|
||||
};
|
||||
|
||||
readable.on('error', onError);
|
||||
readable.on('data', onData);
|
||||
readable.on('end', onEnd);
|
||||
});
|
||||
}
|
||||
|
||||
export default class Client {
|
||||
|
||||
static toString(buff: Buffer): string {
|
||||
return buff.toString();
|
||||
}
|
||||
|
||||
static parseJSON(text: string): any {
|
||||
return JSON.parse(text);
|
||||
}
|
||||
|
||||
static async readAsBytes(stream: Readable): Promise<Buffer> {
|
||||
return await read(stream);
|
||||
}
|
||||
|
||||
static async readAsString(stream: Readable): Promise<string> {
|
||||
let buff = await Client.readAsBytes(stream);
|
||||
return Client.toString(buff);
|
||||
}
|
||||
|
||||
static async readAsJSON(stream: Readable): Promise<any> {
|
||||
return Client.parseJSON(await Client.readAsString(stream));
|
||||
}
|
||||
|
||||
static getNonce(): string {
|
||||
return kitx.makeNonce();
|
||||
}
|
||||
|
||||
static getDateUTCString(): string {
|
||||
const now = new Date();
|
||||
return now.toUTCString();
|
||||
}
|
||||
|
||||
static defaultString(real: string, defaultValue: string): string {
|
||||
return real || defaultValue;
|
||||
}
|
||||
|
||||
static defaultNumber(real: number, defaultValue: number): number {
|
||||
return real || defaultValue;
|
||||
}
|
||||
|
||||
static toFormString(val: { [key: string]: any }): string {
|
||||
return querystring.stringify(val);
|
||||
}
|
||||
|
||||
static toJSONString(val: any): string {
|
||||
if (typeof val === 'string') {
|
||||
return val;
|
||||
}
|
||||
return JSON.stringify(val);
|
||||
}
|
||||
|
||||
static toBytes(val: string): Buffer {
|
||||
return Buffer.from(val);
|
||||
}
|
||||
|
||||
static empty(val: string): boolean {
|
||||
return !val;
|
||||
}
|
||||
|
||||
static equalString(val1: string, val2: string): boolean {
|
||||
return val1 === val2;
|
||||
}
|
||||
|
||||
static equalNumber(val1: number, val2: number): boolean {
|
||||
return val1 === val2;
|
||||
}
|
||||
|
||||
static isUnset(value: any): boolean {
|
||||
if (typeof value === 'undefined') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static stringifyMapValue(m: { [key: string]: any }): { [key: string]: string } {
|
||||
if (!m) {
|
||||
return m;
|
||||
}
|
||||
|
||||
const result: { [key: string]: string } = {};
|
||||
for (const [key, value] of Object.entries(m)) {
|
||||
if (typeof value === 'undefined' || value === null) {
|
||||
continue;
|
||||
}
|
||||
result[key] = String(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static anyifyMapValue(m: { [key: string]: string }): { [key: string]: any } {
|
||||
return m;
|
||||
}
|
||||
|
||||
static assertAsBoolean(value: any): boolean {
|
||||
if (typeof value === 'boolean') {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a boolean`);
|
||||
}
|
||||
|
||||
static assertAsString(value: any): string {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a string`);
|
||||
}
|
||||
|
||||
static assertAsNumber(value: any): number {
|
||||
if (typeof value === 'number') {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a number`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a value, if it is a integer, return it, otherwise throws
|
||||
* @return the integer value
|
||||
*/
|
||||
static assertAsInteger(value: any): number {
|
||||
if (Number.isInteger(value)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a int number`);
|
||||
}
|
||||
|
||||
static assertAsMap(value: any): { [key: string]: any } {
|
||||
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
||||
return value as { [key: string]: any };
|
||||
}
|
||||
throw new Error(`The value is not a object`);
|
||||
}
|
||||
|
||||
static assertAsArray(value: any): any[] {
|
||||
if (Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not array`);
|
||||
}
|
||||
|
||||
static assertAsBytes(value: any): Buffer {
|
||||
if (Buffer.isBuffer(value)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not bytes`);
|
||||
}
|
||||
|
||||
static getUserAgent(userAgent: string): string {
|
||||
if (!userAgent || !userAgent.length) {
|
||||
return DEFAULT_USER_AGENT;
|
||||
}
|
||||
return DEFAULT_USER_AGENT + " " + userAgent;
|
||||
}
|
||||
|
||||
static is2xx(code: number): boolean {
|
||||
return code >= 200 && code < 300;
|
||||
}
|
||||
|
||||
static is3xx(code: number): boolean {
|
||||
return code >= 300 && code < 400;
|
||||
}
|
||||
|
||||
static is4xx(code: number): boolean {
|
||||
return code >= 400 && code < 500;
|
||||
}
|
||||
|
||||
static is5xx(code: number): boolean {
|
||||
return code >= 500 && code < 600;
|
||||
}
|
||||
static validateModel(m: $tea.Model): void {
|
||||
|
||||
}
|
||||
|
||||
static toMap(inputModel: $tea.Model): { [key: string]: any } {
|
||||
return $tea.toMap(inputModel);
|
||||
}
|
||||
|
||||
static async sleep(millisecond: number): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve();
|
||||
}, millisecond)
|
||||
})
|
||||
}
|
||||
|
||||
static toArray(input: any): { [key: string]: any }[] {
|
||||
if (!(input instanceof Array)) {
|
||||
return null;
|
||||
}
|
||||
let ret = [];
|
||||
input.forEach((model) => {
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
ret.push($tea.toMap(model));
|
||||
})
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a value, if it is a readable, return it, otherwise throws
|
||||
* @return the readable value
|
||||
*/
|
||||
static assertAsReadable(value: any): Readable {
|
||||
if (value instanceof Readable) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`The value is not a readable`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
37
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/package.json
generated
vendored
Normal file
37
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@alicloud/openapi-client",
|
||||
"version": "0.4.15",
|
||||
"description": "",
|
||||
"main": "dist/client.js",
|
||||
"scripts": {
|
||||
"test": "mocha -r ts-node/register -r source-map-support/register test/**/*.spec.ts --timeout=10000",
|
||||
"test-cov": "nyc -e .ts -r=html -r=text -r=lcov npm run test",
|
||||
"build": "tsc",
|
||||
"prepublishOnly": "tsc"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/mocha": "^5.2.7",
|
||||
"mocha": "^6.2.0",
|
||||
"@types/node": "^18.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"source-map-support": "^0.5.16",
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "^5.6.0",
|
||||
"@alicloud/gateway-pop": "0.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alicloud/tea-typescript": "^1.7.1",
|
||||
"@alicloud/tea-util": "1.4.9",
|
||||
"@alicloud/credentials": "^2.4.2",
|
||||
"@alicloud/openapi-util": "^0.3.2",
|
||||
"@alicloud/gateway-spi": "^0.0.8",
|
||||
"@alicloud/tea-xml": "0.0.3"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"repository": "git@github.com:aliyun/darabonba-openapi.git"
|
||||
}
|
||||
1835
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/src/client.ts
generated
vendored
Normal file
1835
.agents/skills/dingtalk-api/node_modules/@alicloud/openapi-client/src/client.ts
generated
vendored
Normal file
@@ -0,0 +1,1835 @@
|
||||
// This file is auto-generated, don't edit it
|
||||
/**
|
||||
* @remarks
|
||||
* This is for OpenApi SDK
|
||||
*/
|
||||
import Util, * as $Util from '@alicloud/tea-util';
|
||||
import Credential, * as $Credential from '@alicloud/credentials';
|
||||
import OpenApiUtil from '@alicloud/openapi-util';
|
||||
import SPI, * as $SPI from '@alicloud/gateway-spi';
|
||||
import XML from '@alicloud/tea-xml';
|
||||
import { Readable } from 'stream';
|
||||
import * as $tea from '@alicloud/tea-typescript';
|
||||
|
||||
export class GlobalParameters extends $tea.Model {
|
||||
headers?: { [key: string]: string };
|
||||
queries?: { [key: string]: string };
|
||||
static names(): { [key: string]: string } {
|
||||
return {
|
||||
headers: 'headers',
|
||||
queries: 'queries',
|
||||
};
|
||||
}
|
||||
|
||||
static types(): { [key: string]: any } {
|
||||
return {
|
||||
headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
queries: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
};
|
||||
}
|
||||
|
||||
constructor(map?: { [key: string]: any }) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Model for initing client
|
||||
*/
|
||||
export class Config extends $tea.Model {
|
||||
/**
|
||||
* @remarks
|
||||
* accesskey id
|
||||
*/
|
||||
accessKeyId?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* accesskey secret
|
||||
*/
|
||||
accessKeySecret?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* security token
|
||||
*
|
||||
* @example
|
||||
* a.txt
|
||||
*/
|
||||
securityToken?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* bearer token
|
||||
*
|
||||
* @example
|
||||
* the-bearer-token
|
||||
*/
|
||||
bearerToken?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* http protocol
|
||||
*
|
||||
* @example
|
||||
* http
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* http method
|
||||
*
|
||||
* @example
|
||||
* GET
|
||||
*/
|
||||
method?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* region id
|
||||
*
|
||||
* @example
|
||||
* cn-hangzhou
|
||||
*/
|
||||
regionId?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* read timeout
|
||||
*
|
||||
* @example
|
||||
* 10
|
||||
*/
|
||||
readTimeout?: number;
|
||||
/**
|
||||
* @remarks
|
||||
* connect timeout
|
||||
*
|
||||
* @example
|
||||
* 10
|
||||
*/
|
||||
connectTimeout?: number;
|
||||
/**
|
||||
* @remarks
|
||||
* http proxy
|
||||
*
|
||||
* @example
|
||||
* http://localhost
|
||||
*/
|
||||
httpProxy?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* https proxy
|
||||
*
|
||||
* @example
|
||||
* https://localhost
|
||||
*/
|
||||
httpsProxy?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* credential
|
||||
*/
|
||||
credential?: Credential;
|
||||
/**
|
||||
* @remarks
|
||||
* endpoint
|
||||
*
|
||||
* @example
|
||||
* cs.aliyuncs.com
|
||||
*/
|
||||
endpoint?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* proxy white list
|
||||
*
|
||||
* @example
|
||||
* http://localhost
|
||||
*/
|
||||
noProxy?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* max idle conns
|
||||
*
|
||||
* @example
|
||||
* 3
|
||||
*/
|
||||
maxIdleConns?: number;
|
||||
/**
|
||||
* @remarks
|
||||
* network for endpoint
|
||||
*
|
||||
* @example
|
||||
* public
|
||||
*/
|
||||
network?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* user agent
|
||||
*
|
||||
* @example
|
||||
* Alibabacloud/1
|
||||
*/
|
||||
userAgent?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* suffix for endpoint
|
||||
*
|
||||
* @example
|
||||
* aliyun
|
||||
*/
|
||||
suffix?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* socks5 proxy
|
||||
*/
|
||||
socks5Proxy?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* socks5 network
|
||||
*
|
||||
* @example
|
||||
* TCP
|
||||
*/
|
||||
socks5NetWork?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* endpoint type
|
||||
*
|
||||
* @example
|
||||
* internal
|
||||
*/
|
||||
endpointType?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* OpenPlatform endpoint
|
||||
*
|
||||
* @example
|
||||
* openplatform.aliyuncs.com
|
||||
*/
|
||||
openPlatformEndpoint?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* credential type
|
||||
*
|
||||
* @example
|
||||
* access_key
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* Signature Version
|
||||
*
|
||||
* @example
|
||||
* v1
|
||||
*/
|
||||
signatureVersion?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* Signature Algorithm
|
||||
*
|
||||
* @example
|
||||
* ACS3-HMAC-SHA256
|
||||
*/
|
||||
signatureAlgorithm?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* Global Parameters
|
||||
*/
|
||||
globalParameters?: GlobalParameters;
|
||||
/**
|
||||
* @remarks
|
||||
* privite key for client certificate
|
||||
*
|
||||
* @example
|
||||
* MIIEvQ
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* client certificate
|
||||
*
|
||||
* @example
|
||||
* -----BEGIN CERTIFICATE-----
|
||||
* xxx-----END CERTIFICATE-----
|
||||
*/
|
||||
cert?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* server certificate
|
||||
*
|
||||
* @example
|
||||
* -----BEGIN CERTIFICATE-----
|
||||
* xxx-----END CERTIFICATE-----
|
||||
*/
|
||||
ca?: string;
|
||||
/**
|
||||
* @remarks
|
||||
* disable HTTP/2
|
||||
*
|
||||
* @example
|
||||
* false
|
||||
*/
|
||||
disableHttp2?: boolean;
|
||||
/**
|
||||
* @remarks
|
||||
* TLS Minimum Version
|
||||
*
|
||||
* @example
|
||||
* TLSv1, TLSv1.1, TLSv1.2, TLSv1.3
|
||||
*/
|
||||
tlsMinVersion?: string;
|
||||
static names(): { [key: string]: string } {
|
||||
return {
|
||||
accessKeyId: 'accessKeyId',
|
||||
accessKeySecret: 'accessKeySecret',
|
||||
securityToken: 'securityToken',
|
||||
bearerToken: 'bearerToken',
|
||||
protocol: 'protocol',
|
||||
method: 'method',
|
||||
regionId: 'regionId',
|
||||
readTimeout: 'readTimeout',
|
||||
connectTimeout: 'connectTimeout',
|
||||
httpProxy: 'httpProxy',
|
||||
httpsProxy: 'httpsProxy',
|
||||
credential: 'credential',
|
||||
endpoint: 'endpoint',
|
||||
noProxy: 'noProxy',
|
||||
maxIdleConns: 'maxIdleConns',
|
||||
network: 'network',
|
||||
userAgent: 'userAgent',
|
||||
suffix: 'suffix',
|
||||
socks5Proxy: 'socks5Proxy',
|
||||
socks5NetWork: 'socks5NetWork',
|
||||
endpointType: 'endpointType',
|
||||
openPlatformEndpoint: 'openPlatformEndpoint',
|
||||
type: 'type',
|
||||
signatureVersion: 'signatureVersion',
|
||||
signatureAlgorithm: 'signatureAlgorithm',
|
||||
globalParameters: 'globalParameters',
|
||||
key: 'key',
|
||||
cert: 'cert',
|
||||
ca: 'ca',
|
||||
disableHttp2: 'disableHttp2',
|
||||
tlsMinVersion: 'tlsMinVersion',
|
||||
};
|
||||
}
|
||||
|
||||
static types(): { [key: string]: any } {
|
||||
return {
|
||||
accessKeyId: 'string',
|
||||
accessKeySecret: 'string',
|
||||
securityToken: 'string',
|
||||
bearerToken: 'string',
|
||||
protocol: 'string',
|
||||
method: 'string',
|
||||
regionId: 'string',
|
||||
readTimeout: 'number',
|
||||
connectTimeout: 'number',
|
||||
httpProxy: 'string',
|
||||
httpsProxy: 'string',
|
||||
credential: Credential,
|
||||
endpoint: 'string',
|
||||
noProxy: 'string',
|
||||
maxIdleConns: 'number',
|
||||
network: 'string',
|
||||
userAgent: 'string',
|
||||
suffix: 'string',
|
||||
socks5Proxy: 'string',
|
||||
socks5NetWork: 'string',
|
||||
endpointType: 'string',
|
||||
openPlatformEndpoint: 'string',
|
||||
type: 'string',
|
||||
signatureVersion: 'string',
|
||||
signatureAlgorithm: 'string',
|
||||
globalParameters: GlobalParameters,
|
||||
key: 'string',
|
||||
cert: 'string',
|
||||
ca: 'string',
|
||||
disableHttp2: 'boolean',
|
||||
tlsMinVersion: 'string',
|
||||
};
|
||||
}
|
||||
|
||||
constructor(map?: { [key: string]: any }) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenApiRequest extends $tea.Model {
|
||||
headers?: { [key: string]: string };
|
||||
query?: { [key: string]: string };
|
||||
body?: any;
|
||||
stream?: Readable;
|
||||
hostMap?: { [key: string]: string };
|
||||
endpointOverride?: string;
|
||||
static names(): { [key: string]: string } {
|
||||
return {
|
||||
headers: 'headers',
|
||||
query: 'query',
|
||||
body: 'body',
|
||||
stream: 'stream',
|
||||
hostMap: 'hostMap',
|
||||
endpointOverride: 'endpointOverride',
|
||||
};
|
||||
}
|
||||
|
||||
static types(): { [key: string]: any } {
|
||||
return {
|
||||
headers: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
query: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
body: 'any',
|
||||
stream: 'Readable',
|
||||
hostMap: { 'type': 'map', 'keyType': 'string', 'valueType': 'string' },
|
||||
endpointOverride: 'string',
|
||||
};
|
||||
}
|
||||
|
||||
constructor(map?: { [key: string]: any }) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
|
||||
export class Params extends $tea.Model {
|
||||
action: string;
|
||||
version: string;
|
||||
protocol: string;
|
||||
pathname: string;
|
||||
method: string;
|
||||
authType: string;
|
||||
bodyType: string;
|
||||
reqBodyType: string;
|
||||
style?: string;
|
||||
static names(): { [key: string]: string } {
|
||||
return {
|
||||
action: 'action',
|
||||
version: 'version',
|
||||
protocol: 'protocol',
|
||||
pathname: 'pathname',
|
||||
method: 'method',
|
||||
authType: 'authType',
|
||||
bodyType: 'bodyType',
|
||||
reqBodyType: 'reqBodyType',
|
||||
style: 'style',
|
||||
};
|
||||
}
|
||||
|
||||
static types(): { [key: string]: any } {
|
||||
return {
|
||||
action: 'string',
|
||||
version: 'string',
|
||||
protocol: 'string',
|
||||
pathname: 'string',
|
||||
method: 'string',
|
||||
authType: 'string',
|
||||
bodyType: 'string',
|
||||
reqBodyType: 'string',
|
||||
style: 'string',
|
||||
};
|
||||
}
|
||||
|
||||
constructor(map?: { [key: string]: any }) {
|
||||
super(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default class Client {
|
||||
_endpoint: string;
|
||||
_regionId: string;
|
||||
_protocol: string;
|
||||
_method: string;
|
||||
_userAgent: string;
|
||||
_endpointRule: string;
|
||||
_endpointMap: {[key: string ]: string};
|
||||
_suffix: string;
|
||||
_readTimeout: number;
|
||||
_connectTimeout: number;
|
||||
_httpProxy: string;
|
||||
_httpsProxy: string;
|
||||
_socks5Proxy: string;
|
||||
_socks5NetWork: string;
|
||||
_noProxy: string;
|
||||
_network: string;
|
||||
_productId: string;
|
||||
_maxIdleConns: number;
|
||||
_endpointType: string;
|
||||
_openPlatformEndpoint: string;
|
||||
_credential: Credential;
|
||||
_signatureVersion: string;
|
||||
_signatureAlgorithm: string;
|
||||
_headers: {[key: string ]: string};
|
||||
_spi: SPI;
|
||||
_globalParameters: GlobalParameters;
|
||||
_key: string;
|
||||
_cert: string;
|
||||
_ca: string;
|
||||
_disableHttp2: boolean;
|
||||
_tlsMinVersion: string;
|
||||
_attributeMap: $SPI.AttributeMap;
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Init client with Config
|
||||
*
|
||||
* @param config - config contains the necessary information to create a client
|
||||
*/
|
||||
constructor(config: Config) {
|
||||
if (Util.isUnset(config)) {
|
||||
throw $tea.newError({
|
||||
code: "ParameterMissing",
|
||||
message: "'config' can not be unset",
|
||||
});
|
||||
}
|
||||
|
||||
if (!Util.empty(config.accessKeyId) && !Util.empty(config.accessKeySecret)) {
|
||||
if (!Util.empty(config.securityToken)) {
|
||||
config.type = "sts";
|
||||
} else {
|
||||
config.type = "access_key";
|
||||
}
|
||||
|
||||
let credentialConfig = new $Credential.Config({
|
||||
accessKeyId: config.accessKeyId,
|
||||
type: config.type,
|
||||
accessKeySecret: config.accessKeySecret,
|
||||
});
|
||||
credentialConfig.securityToken = config.securityToken;
|
||||
this._credential = new Credential(credentialConfig);
|
||||
} else if (!Util.empty(config.bearerToken)) {
|
||||
let cc = new $Credential.Config({
|
||||
type: "bearer",
|
||||
bearerToken: config.bearerToken,
|
||||
});
|
||||
this._credential = new Credential(cc);
|
||||
} else if (!Util.isUnset(config.credential)) {
|
||||
this._credential = config.credential;
|
||||
}
|
||||
|
||||
this._endpoint = config.endpoint;
|
||||
this._endpointType = config.endpointType;
|
||||
this._network = config.network;
|
||||
this._suffix = config.suffix;
|
||||
this._protocol = config.protocol;
|
||||
this._method = config.method;
|
||||
this._regionId = config.regionId;
|
||||
this._userAgent = config.userAgent;
|
||||
this._readTimeout = config.readTimeout;
|
||||
this._connectTimeout = config.connectTimeout;
|
||||
this._httpProxy = config.httpProxy;
|
||||
this._httpsProxy = config.httpsProxy;
|
||||
this._noProxy = config.noProxy;
|
||||
this._socks5Proxy = config.socks5Proxy;
|
||||
this._socks5NetWork = config.socks5NetWork;
|
||||
this._maxIdleConns = config.maxIdleConns;
|
||||
this._signatureVersion = config.signatureVersion;
|
||||
this._signatureAlgorithm = config.signatureAlgorithm;
|
||||
this._globalParameters = config.globalParameters;
|
||||
this._key = config.key;
|
||||
this._cert = config.cert;
|
||||
this._ca = config.ca;
|
||||
this._disableHttp2 = config.disableHttp2;
|
||||
this._tlsMinVersion = config.tlsMinVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async doRPCRequest(action: string, version: string, protocol: string, method: string, authType: string, bodyType: string, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{[key: string]: any}> {
|
||||
let _runtime: { [key: string]: any } = {
|
||||
timeouted: "retry",
|
||||
key: Util.defaultString(runtime.key, this._key),
|
||||
cert: Util.defaultString(runtime.cert, this._cert),
|
||||
ca: Util.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: Util.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: Util.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: Util.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: Util.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: Util.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: Util.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: Util.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: Util.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: Util.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: Util.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: Util.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
}
|
||||
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
request_.protocol = Util.defaultString(this._protocol, protocol);
|
||||
request_.method = method;
|
||||
request_.pathname = "/";
|
||||
let globalQueries : {[key: string ]: string} = { };
|
||||
let globalHeaders : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!Util.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let extendsHeaders : {[key: string ]: string} = { };
|
||||
let extendsQueries : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!Util.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
request_.query = {
|
||||
Action: action,
|
||||
Format: "json",
|
||||
Version: version,
|
||||
Timestamp: OpenApiUtil.getTimestamp(),
|
||||
SignatureNonce: Util.getNonce(),
|
||||
...globalQueries,
|
||||
...extendsQueries,
|
||||
...request.query,
|
||||
};
|
||||
let headers = this.getRpcHeaders();
|
||||
if (Util.isUnset(headers)) {
|
||||
// endpoint is setted in product client
|
||||
request_.headers = {
|
||||
host: this._endpoint,
|
||||
'x-acs-version': version,
|
||||
'x-acs-action': action,
|
||||
'user-agent': this.getUserAgent(),
|
||||
...globalHeaders,
|
||||
...extendsHeaders,
|
||||
...request.headers,
|
||||
};
|
||||
} else {
|
||||
request_.headers = {
|
||||
host: this._endpoint,
|
||||
'x-acs-version': version,
|
||||
'x-acs-action': action,
|
||||
'user-agent': this.getUserAgent(),
|
||||
...globalHeaders,
|
||||
...extendsHeaders,
|
||||
...request.headers,
|
||||
...headers,
|
||||
};
|
||||
}
|
||||
|
||||
if (!Util.isUnset(request.body)) {
|
||||
let m = Util.assertAsMap(request.body);
|
||||
let tmp = Util.anyifyMapValue(OpenApiUtil.query(m));
|
||||
request_.body = new $tea.BytesReadable(Util.toFormString(tmp));
|
||||
request_.headers["content-type"] = "application/x-www-form-urlencoded";
|
||||
}
|
||||
|
||||
if (!Util.equalString(authType, "Anonymous")) {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
throw $tea.newError({
|
||||
code: `InvalidCredentials`,
|
||||
message: `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`,
|
||||
});
|
||||
}
|
||||
|
||||
let credentialModel = await this._credential.getCredential();
|
||||
if (!Util.empty(credentialModel.providerName)) {
|
||||
request_.headers["x-acs-credentials-provider"] = credentialModel.providerName;
|
||||
}
|
||||
|
||||
let credentialType = credentialModel.type;
|
||||
if (Util.equalString(credentialType, "bearer")) {
|
||||
let bearerToken = credentialModel.bearerToken;
|
||||
request_.query["BearerToken"] = bearerToken;
|
||||
request_.query["SignatureType"] = "BEARERTOKEN";
|
||||
} else if (Util.equalString(credentialType, "id_token")) {
|
||||
let idToken = credentialModel.securityToken;
|
||||
request_.headers["x-acs-zero-trust-idtoken"] = idToken;
|
||||
} else {
|
||||
let accessKeyId = credentialModel.accessKeyId;
|
||||
let accessKeySecret = credentialModel.accessKeySecret;
|
||||
let securityToken = credentialModel.securityToken;
|
||||
if (!Util.empty(securityToken)) {
|
||||
request_.query["SecurityToken"] = securityToken;
|
||||
}
|
||||
|
||||
request_.query["SignatureMethod"] = "HMAC-SHA1";
|
||||
request_.query["SignatureVersion"] = "1.0";
|
||||
request_.query["AccessKeyId"] = accessKeyId;
|
||||
let t : {[key: string ]: any} = null;
|
||||
if (!Util.isUnset(request.body)) {
|
||||
t = Util.assertAsMap(request.body);
|
||||
}
|
||||
|
||||
let signedParam = {
|
||||
...request_.query,
|
||||
...OpenApiUtil.query(t),
|
||||
};
|
||||
request_.query["Signature"] = OpenApiUtil.getRPCSignature(signedParam, request_.method, accessKeySecret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
|
||||
if (Util.is4xx(response_.statusCode) || Util.is5xx(response_.statusCode)) {
|
||||
let _res = await Util.readAsJSON(response_.body);
|
||||
let err = Util.assertAsMap(_res);
|
||||
let requestId = Client.defaultAny(err["RequestId"], err["requestId"]);
|
||||
err["statusCode"] = response_.statusCode;
|
||||
throw $tea.newError({
|
||||
code: `${Client.defaultAny(err["Code"], err["code"])}`,
|
||||
message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${requestId}`,
|
||||
data: err,
|
||||
description: `${Client.defaultAny(err["Description"], err["description"])}`,
|
||||
accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
|
||||
});
|
||||
}
|
||||
|
||||
if (Util.equalString(bodyType, "binary")) {
|
||||
let resp = {
|
||||
body: response_.body,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
return resp;
|
||||
} else if (Util.equalString(bodyType, "byte")) {
|
||||
let byt = await Util.readAsBytes(response_.body);
|
||||
return {
|
||||
body: byt,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "string")) {
|
||||
let str = await Util.readAsString(response_.body);
|
||||
return {
|
||||
body: str,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "json")) {
|
||||
let obj = await Util.readAsJSON(response_.body);
|
||||
let res = Util.assertAsMap(obj);
|
||||
return {
|
||||
body: res,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "array")) {
|
||||
let arr = await Util.readAsJSON(response_.body);
|
||||
return {
|
||||
body: arr,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
|
||||
} catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param pathname - pathname of every api
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async doROARequest(action: string, version: string, protocol: string, method: string, authType: string, pathname: string, bodyType: string, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{[key: string]: any}> {
|
||||
let _runtime: { [key: string]: any } = {
|
||||
timeouted: "retry",
|
||||
key: Util.defaultString(runtime.key, this._key),
|
||||
cert: Util.defaultString(runtime.cert, this._cert),
|
||||
ca: Util.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: Util.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: Util.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: Util.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: Util.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: Util.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: Util.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: Util.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: Util.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: Util.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: Util.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: Util.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
}
|
||||
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
request_.protocol = Util.defaultString(this._protocol, protocol);
|
||||
request_.method = method;
|
||||
request_.pathname = pathname;
|
||||
let globalQueries : {[key: string ]: string} = { };
|
||||
let globalHeaders : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!Util.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let extendsHeaders : {[key: string ]: string} = { };
|
||||
let extendsQueries : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!Util.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
request_.headers = {
|
||||
date: Util.getDateUTCString(),
|
||||
host: this._endpoint,
|
||||
accept: "application/json",
|
||||
'x-acs-signature-nonce': Util.getNonce(),
|
||||
'x-acs-signature-method': "HMAC-SHA1",
|
||||
'x-acs-signature-version': "1.0",
|
||||
'x-acs-version': version,
|
||||
'x-acs-action': action,
|
||||
'user-agent': Util.getUserAgent(this._userAgent),
|
||||
...globalHeaders,
|
||||
...extendsHeaders,
|
||||
...request.headers,
|
||||
};
|
||||
if (!Util.isUnset(request.body)) {
|
||||
request_.body = new $tea.BytesReadable(Util.toJSONString(request.body));
|
||||
request_.headers["content-type"] = "application/json; charset=utf-8";
|
||||
}
|
||||
|
||||
request_.query = {
|
||||
...globalQueries,
|
||||
...extendsQueries,
|
||||
};
|
||||
if (!Util.isUnset(request.query)) {
|
||||
request_.query = {
|
||||
...request_.query,
|
||||
...request.query,
|
||||
};
|
||||
}
|
||||
|
||||
if (!Util.equalString(authType, "Anonymous")) {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
throw $tea.newError({
|
||||
code: `InvalidCredentials`,
|
||||
message: `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`,
|
||||
});
|
||||
}
|
||||
|
||||
let credentialModel = await this._credential.getCredential();
|
||||
if (!Util.empty(credentialModel.providerName)) {
|
||||
request_.headers["x-acs-credentials-provider"] = credentialModel.providerName;
|
||||
}
|
||||
|
||||
let credentialType = credentialModel.type;
|
||||
if (Util.equalString(credentialType, "bearer")) {
|
||||
let bearerToken = credentialModel.bearerToken;
|
||||
request_.headers["x-acs-bearer-token"] = bearerToken;
|
||||
request_.headers["x-acs-signature-type"] = "BEARERTOKEN";
|
||||
} else if (Util.equalString(credentialType, "id_token")) {
|
||||
let idToken = credentialModel.securityToken;
|
||||
request_.headers["x-acs-zero-trust-idtoken"] = idToken;
|
||||
} else {
|
||||
let accessKeyId = credentialModel.accessKeyId;
|
||||
let accessKeySecret = credentialModel.accessKeySecret;
|
||||
let securityToken = credentialModel.securityToken;
|
||||
if (!Util.empty(securityToken)) {
|
||||
request_.headers["x-acs-accesskey-id"] = accessKeyId;
|
||||
request_.headers["x-acs-security-token"] = securityToken;
|
||||
}
|
||||
|
||||
let stringToSign = OpenApiUtil.getStringToSign(request_);
|
||||
request_.headers["authorization"] = `acs ${accessKeyId}:${OpenApiUtil.getROASignature(stringToSign, accessKeySecret)}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
|
||||
if (Util.equalNumber(response_.statusCode, 204)) {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
};
|
||||
}
|
||||
|
||||
if (Util.is4xx(response_.statusCode) || Util.is5xx(response_.statusCode)) {
|
||||
let _res = await Util.readAsJSON(response_.body);
|
||||
let err = Util.assertAsMap(_res);
|
||||
let requestId = Client.defaultAny(err["RequestId"], err["requestId"]);
|
||||
requestId = Client.defaultAny(requestId, err["requestid"]);
|
||||
err["statusCode"] = response_.statusCode;
|
||||
throw $tea.newError({
|
||||
code: `${Client.defaultAny(err["Code"], err["code"])}`,
|
||||
message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${requestId}`,
|
||||
data: err,
|
||||
description: `${Client.defaultAny(err["Description"], err["description"])}`,
|
||||
accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
|
||||
});
|
||||
}
|
||||
|
||||
if (Util.equalString(bodyType, "binary")) {
|
||||
let resp = {
|
||||
body: response_.body,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
return resp;
|
||||
} else if (Util.equalString(bodyType, "byte")) {
|
||||
let byt = await Util.readAsBytes(response_.body);
|
||||
return {
|
||||
body: byt,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "string")) {
|
||||
let str = await Util.readAsString(response_.body);
|
||||
return {
|
||||
body: str,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "json")) {
|
||||
let obj = await Util.readAsJSON(response_.body);
|
||||
let res = Util.assertAsMap(obj);
|
||||
return {
|
||||
body: res,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "array")) {
|
||||
let arr = await Util.readAsJSON(response_.body);
|
||||
return {
|
||||
body: arr,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
|
||||
} catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network with form body
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param pathname - pathname of every api
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async doROARequestWithForm(action: string, version: string, protocol: string, method: string, authType: string, pathname: string, bodyType: string, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{[key: string]: any}> {
|
||||
let _runtime: { [key: string]: any } = {
|
||||
timeouted: "retry",
|
||||
key: Util.defaultString(runtime.key, this._key),
|
||||
cert: Util.defaultString(runtime.cert, this._cert),
|
||||
ca: Util.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: Util.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: Util.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: Util.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: Util.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: Util.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: Util.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: Util.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: Util.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: Util.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: Util.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: Util.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
}
|
||||
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
request_.protocol = Util.defaultString(this._protocol, protocol);
|
||||
request_.method = method;
|
||||
request_.pathname = pathname;
|
||||
let globalQueries : {[key: string ]: string} = { };
|
||||
let globalHeaders : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!Util.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let extendsHeaders : {[key: string ]: string} = { };
|
||||
let extendsQueries : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!Util.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
request_.headers = {
|
||||
date: Util.getDateUTCString(),
|
||||
host: this._endpoint,
|
||||
accept: "application/json",
|
||||
'x-acs-signature-nonce': Util.getNonce(),
|
||||
'x-acs-signature-method': "HMAC-SHA1",
|
||||
'x-acs-signature-version': "1.0",
|
||||
'x-acs-version': version,
|
||||
'x-acs-action': action,
|
||||
'user-agent': Util.getUserAgent(this._userAgent),
|
||||
...globalHeaders,
|
||||
...extendsHeaders,
|
||||
...request.headers,
|
||||
};
|
||||
if (!Util.isUnset(request.body)) {
|
||||
let m = Util.assertAsMap(request.body);
|
||||
request_.body = new $tea.BytesReadable(OpenApiUtil.toForm(m));
|
||||
request_.headers["content-type"] = "application/x-www-form-urlencoded";
|
||||
}
|
||||
|
||||
request_.query = {
|
||||
...globalQueries,
|
||||
...extendsQueries,
|
||||
};
|
||||
if (!Util.isUnset(request.query)) {
|
||||
request_.query = {
|
||||
...request_.query,
|
||||
...request.query,
|
||||
};
|
||||
}
|
||||
|
||||
if (!Util.equalString(authType, "Anonymous")) {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
throw $tea.newError({
|
||||
code: `InvalidCredentials`,
|
||||
message: `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`,
|
||||
});
|
||||
}
|
||||
|
||||
let credentialModel = await this._credential.getCredential();
|
||||
if (!Util.empty(credentialModel.providerName)) {
|
||||
request_.headers["x-acs-credentials-provider"] = credentialModel.providerName;
|
||||
}
|
||||
|
||||
let credentialType = credentialModel.type;
|
||||
if (Util.equalString(credentialType, "bearer")) {
|
||||
let bearerToken = credentialModel.bearerToken;
|
||||
request_.headers["x-acs-bearer-token"] = bearerToken;
|
||||
request_.headers["x-acs-signature-type"] = "BEARERTOKEN";
|
||||
} else if (Util.equalString(credentialType, "id_token")) {
|
||||
let idToken = credentialModel.securityToken;
|
||||
request_.headers["x-acs-zero-trust-idtoken"] = idToken;
|
||||
} else {
|
||||
let accessKeyId = credentialModel.accessKeyId;
|
||||
let accessKeySecret = credentialModel.accessKeySecret;
|
||||
let securityToken = credentialModel.securityToken;
|
||||
if (!Util.empty(securityToken)) {
|
||||
request_.headers["x-acs-accesskey-id"] = accessKeyId;
|
||||
request_.headers["x-acs-security-token"] = securityToken;
|
||||
}
|
||||
|
||||
let stringToSign = OpenApiUtil.getStringToSign(request_);
|
||||
request_.headers["authorization"] = `acs ${accessKeyId}:${OpenApiUtil.getROASignature(stringToSign, accessKeySecret)}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
|
||||
if (Util.equalNumber(response_.statusCode, 204)) {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
};
|
||||
}
|
||||
|
||||
if (Util.is4xx(response_.statusCode) || Util.is5xx(response_.statusCode)) {
|
||||
let _res = await Util.readAsJSON(response_.body);
|
||||
let err = Util.assertAsMap(_res);
|
||||
err["statusCode"] = response_.statusCode;
|
||||
throw $tea.newError({
|
||||
code: `${Client.defaultAny(err["Code"], err["code"])}`,
|
||||
message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${Client.defaultAny(err["RequestId"], err["requestId"])}`,
|
||||
data: err,
|
||||
description: `${Client.defaultAny(err["Description"], err["description"])}`,
|
||||
accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
|
||||
});
|
||||
}
|
||||
|
||||
if (Util.equalString(bodyType, "binary")) {
|
||||
let resp = {
|
||||
body: response_.body,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
return resp;
|
||||
} else if (Util.equalString(bodyType, "byte")) {
|
||||
let byt = await Util.readAsBytes(response_.body);
|
||||
return {
|
||||
body: byt,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "string")) {
|
||||
let str = await Util.readAsString(response_.body);
|
||||
return {
|
||||
body: str,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "json")) {
|
||||
let obj = await Util.readAsJSON(response_.body);
|
||||
let res = Util.assertAsMap(obj);
|
||||
return {
|
||||
body: res,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(bodyType, "array")) {
|
||||
let arr = await Util.readAsJSON(response_.body);
|
||||
return {
|
||||
body: arr,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
|
||||
} catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async doRequest(params: Params, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{[key: string]: any}> {
|
||||
let _runtime: { [key: string]: any } = {
|
||||
timeouted: "retry",
|
||||
key: Util.defaultString(runtime.key, this._key),
|
||||
cert: Util.defaultString(runtime.cert, this._cert),
|
||||
ca: Util.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: Util.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: Util.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: Util.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: Util.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: Util.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: Util.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: Util.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: Util.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: Util.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: Util.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: Util.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
}
|
||||
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
request_.protocol = Util.defaultString(this._protocol, params.protocol);
|
||||
request_.method = params.method;
|
||||
request_.pathname = params.pathname;
|
||||
let globalQueries : {[key: string ]: string} = { };
|
||||
let globalHeaders : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!Util.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let extendsHeaders : {[key: string ]: string} = { };
|
||||
let extendsQueries : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!Util.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
request_.query = {
|
||||
...globalQueries,
|
||||
...extendsQueries,
|
||||
...request.query,
|
||||
};
|
||||
// endpoint is setted in product client
|
||||
request_.headers = {
|
||||
host: this._endpoint,
|
||||
'x-acs-version': params.version,
|
||||
'x-acs-action': params.action,
|
||||
'user-agent': this.getUserAgent(),
|
||||
'x-acs-date': OpenApiUtil.getTimestamp(),
|
||||
'x-acs-signature-nonce': Util.getNonce(),
|
||||
accept: "application/json",
|
||||
...globalHeaders,
|
||||
...extendsHeaders,
|
||||
...request.headers,
|
||||
};
|
||||
if (Util.equalString(params.style, "RPC")) {
|
||||
let headers = this.getRpcHeaders();
|
||||
if (!Util.isUnset(headers)) {
|
||||
request_.headers = {
|
||||
...request_.headers,
|
||||
...headers,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let signatureAlgorithm = Util.defaultString(this._signatureAlgorithm, "ACS3-HMAC-SHA256");
|
||||
let hashedRequestPayload = OpenApiUtil.hexEncode(OpenApiUtil.hash(Util.toBytes(""), signatureAlgorithm));
|
||||
if (!Util.isUnset(request.stream)) {
|
||||
let tmp = await Util.readAsBytes(request.stream);
|
||||
hashedRequestPayload = OpenApiUtil.hexEncode(OpenApiUtil.hash(tmp, signatureAlgorithm));
|
||||
request_.body = new $tea.BytesReadable(tmp);
|
||||
request_.headers["content-type"] = "application/octet-stream";
|
||||
} else {
|
||||
if (!Util.isUnset(request.body)) {
|
||||
if (Util.equalString(params.reqBodyType, "byte")) {
|
||||
let byteObj = Util.assertAsBytes(request.body);
|
||||
hashedRequestPayload = OpenApiUtil.hexEncode(OpenApiUtil.hash(byteObj, signatureAlgorithm));
|
||||
request_.body = new $tea.BytesReadable(byteObj);
|
||||
} else if (Util.equalString(params.reqBodyType, "json")) {
|
||||
let jsonObj = Util.toJSONString(request.body);
|
||||
hashedRequestPayload = OpenApiUtil.hexEncode(OpenApiUtil.hash(Util.toBytes(jsonObj), signatureAlgorithm));
|
||||
request_.body = new $tea.BytesReadable(jsonObj);
|
||||
request_.headers["content-type"] = "application/json; charset=utf-8";
|
||||
} else {
|
||||
let m = Util.assertAsMap(request.body);
|
||||
let formObj = OpenApiUtil.toForm(m);
|
||||
hashedRequestPayload = OpenApiUtil.hexEncode(OpenApiUtil.hash(Util.toBytes(formObj), signatureAlgorithm));
|
||||
request_.body = new $tea.BytesReadable(formObj);
|
||||
request_.headers["content-type"] = "application/x-www-form-urlencoded";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
request_.headers["x-acs-content-sha256"] = hashedRequestPayload;
|
||||
if (!Util.equalString(params.authType, "Anonymous")) {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
throw $tea.newError({
|
||||
code: `InvalidCredentials`,
|
||||
message: `Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details.`,
|
||||
});
|
||||
}
|
||||
|
||||
let credentialModel = await this._credential.getCredential();
|
||||
if (!Util.empty(credentialModel.providerName)) {
|
||||
request_.headers["x-acs-credentials-provider"] = credentialModel.providerName;
|
||||
}
|
||||
|
||||
let authType = credentialModel.type;
|
||||
if (Util.equalString(authType, "bearer")) {
|
||||
let bearerToken = credentialModel.bearerToken;
|
||||
request_.headers["x-acs-bearer-token"] = bearerToken;
|
||||
if (Util.equalString(params.style, "RPC")) {
|
||||
request_.query["SignatureType"] = "BEARERTOKEN";
|
||||
} else {
|
||||
request_.headers["x-acs-signature-type"] = "BEARERTOKEN";
|
||||
}
|
||||
|
||||
} else if (Util.equalString(authType, "id_token")) {
|
||||
let idToken = credentialModel.securityToken;
|
||||
request_.headers["x-acs-zero-trust-idtoken"] = idToken;
|
||||
} else {
|
||||
let accessKeyId = credentialModel.accessKeyId;
|
||||
let accessKeySecret = credentialModel.accessKeySecret;
|
||||
let securityToken = credentialModel.securityToken;
|
||||
if (!Util.empty(securityToken)) {
|
||||
request_.headers["x-acs-accesskey-id"] = accessKeyId;
|
||||
request_.headers["x-acs-security-token"] = securityToken;
|
||||
}
|
||||
|
||||
request_.headers["Authorization"] = OpenApiUtil.getAuthorization(request_, signatureAlgorithm, hashedRequestPayload, accessKeyId, accessKeySecret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
|
||||
if (Util.is4xx(response_.statusCode) || Util.is5xx(response_.statusCode)) {
|
||||
let err : {[key: string ]: any} = { };
|
||||
if (!Util.isUnset(response_.headers["content-type"]) && Util.equalString(response_.headers["content-type"], "text/xml;charset=utf-8")) {
|
||||
let _str = await Util.readAsString(response_.body);
|
||||
let respMap = XML.parseXml(_str, null);
|
||||
err = Util.assertAsMap(respMap["Error"]);
|
||||
} else {
|
||||
let _res = await Util.readAsJSON(response_.body);
|
||||
err = Util.assertAsMap(_res);
|
||||
}
|
||||
|
||||
err["statusCode"] = response_.statusCode;
|
||||
throw $tea.newError({
|
||||
code: `${Client.defaultAny(err["Code"], err["code"])}`,
|
||||
message: `code: ${response_.statusCode}, ${Client.defaultAny(err["Message"], err["message"])} request id: ${Client.defaultAny(err["RequestId"], err["requestId"])}`,
|
||||
data: err,
|
||||
description: `${Client.defaultAny(err["Description"], err["description"])}`,
|
||||
accessDeniedDetail: Client.defaultAny(err["AccessDeniedDetail"], err["accessDeniedDetail"]),
|
||||
});
|
||||
}
|
||||
|
||||
if (Util.equalString(params.bodyType, "binary")) {
|
||||
let resp = {
|
||||
body: response_.body,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
return resp;
|
||||
} else if (Util.equalString(params.bodyType, "byte")) {
|
||||
let byt = await Util.readAsBytes(response_.body);
|
||||
return {
|
||||
body: byt,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(params.bodyType, "string")) {
|
||||
let str = await Util.readAsString(response_.body);
|
||||
return {
|
||||
body: str,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(params.bodyType, "json")) {
|
||||
let obj = await Util.readAsJSON(response_.body);
|
||||
let res = Util.assertAsMap(obj);
|
||||
return {
|
||||
body: res,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else if (Util.equalString(params.bodyType, "array")) {
|
||||
let arr = await Util.readAsJSON(response_.body);
|
||||
return {
|
||||
body: arr,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
} else {
|
||||
let anything = await Util.readAsString(response_.body);
|
||||
return {
|
||||
body: anything,
|
||||
headers: response_.headers,
|
||||
statusCode: response_.statusCode,
|
||||
};
|
||||
}
|
||||
|
||||
} catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Encapsulate the request and invoke the network
|
||||
*
|
||||
* @param action - api name
|
||||
* @param version - product version
|
||||
* @param protocol - http or https
|
||||
* @param method - e.g. GET
|
||||
* @param authType - authorization type e.g. AK
|
||||
* @param bodyType - response body type e.g. String
|
||||
* @param request - object of OpenApiRequest
|
||||
* @param runtime - which controls some details of call api, such as retry times
|
||||
* @returns the response
|
||||
*/
|
||||
async execute(params: Params, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{[key: string]: any}> {
|
||||
let _runtime: { [key: string]: any } = {
|
||||
timeouted: "retry",
|
||||
key: Util.defaultString(runtime.key, this._key),
|
||||
cert: Util.defaultString(runtime.cert, this._cert),
|
||||
ca: Util.defaultString(runtime.ca, this._ca),
|
||||
readTimeout: Util.defaultNumber(runtime.readTimeout, this._readTimeout),
|
||||
connectTimeout: Util.defaultNumber(runtime.connectTimeout, this._connectTimeout),
|
||||
httpProxy: Util.defaultString(runtime.httpProxy, this._httpProxy),
|
||||
httpsProxy: Util.defaultString(runtime.httpsProxy, this._httpsProxy),
|
||||
noProxy: Util.defaultString(runtime.noProxy, this._noProxy),
|
||||
socks5Proxy: Util.defaultString(runtime.socks5Proxy, this._socks5Proxy),
|
||||
socks5NetWork: Util.defaultString(runtime.socks5NetWork, this._socks5NetWork),
|
||||
maxIdleConns: Util.defaultNumber(runtime.maxIdleConns, this._maxIdleConns),
|
||||
retry: {
|
||||
retryable: runtime.autoretry,
|
||||
maxAttempts: Util.defaultNumber(runtime.maxAttempts, 3),
|
||||
},
|
||||
backoff: {
|
||||
policy: Util.defaultString(runtime.backoffPolicy, "no"),
|
||||
period: Util.defaultNumber(runtime.backoffPeriod, 1),
|
||||
},
|
||||
ignoreSSL: runtime.ignoreSSL,
|
||||
disableHttp2: Client.defaultAny(this._disableHttp2, false),
|
||||
tlsMinVersion: this._tlsMinVersion,
|
||||
}
|
||||
|
||||
let _lastRequest = null;
|
||||
let _now = Date.now();
|
||||
let _retryTimes = 0;
|
||||
while ($tea.allowRetry(_runtime['retry'], _retryTimes, _now)) {
|
||||
if (_retryTimes > 0) {
|
||||
let _backoffTime = $tea.getBackoffTime(_runtime['backoff'], _retryTimes);
|
||||
if (_backoffTime > 0) {
|
||||
await $tea.sleep(_backoffTime);
|
||||
}
|
||||
}
|
||||
|
||||
_retryTimes = _retryTimes + 1;
|
||||
try {
|
||||
let request_ = new $tea.Request();
|
||||
// spi = new Gateway();//Gateway implements SPI,这一步在产品 SDK 中实例化
|
||||
let headers = this.getRpcHeaders();
|
||||
let globalQueries : {[key: string ]: string} = { };
|
||||
let globalHeaders : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(this._globalParameters)) {
|
||||
let globalParams = this._globalParameters;
|
||||
if (!Util.isUnset(globalParams.queries)) {
|
||||
globalQueries = globalParams.queries;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(globalParams.headers)) {
|
||||
globalHeaders = globalParams.headers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let extendsHeaders : {[key: string ]: string} = { };
|
||||
let extendsQueries : {[key: string ]: string} = { };
|
||||
if (!Util.isUnset(runtime.extendsParameters)) {
|
||||
let extendsParameters = runtime.extendsParameters;
|
||||
if (!Util.isUnset(extendsParameters.headers)) {
|
||||
extendsHeaders = extendsParameters.headers;
|
||||
}
|
||||
|
||||
if (!Util.isUnset(extendsParameters.queries)) {
|
||||
extendsQueries = extendsParameters.queries;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let requestContext = new $SPI.InterceptorContextRequest({
|
||||
headers: {
|
||||
...globalHeaders,
|
||||
...extendsHeaders,
|
||||
...request.headers,
|
||||
...headers,
|
||||
},
|
||||
query: {
|
||||
...globalQueries,
|
||||
...extendsQueries,
|
||||
...request.query,
|
||||
},
|
||||
body: request.body,
|
||||
stream: request.stream,
|
||||
hostMap: request.hostMap,
|
||||
pathname: params.pathname,
|
||||
productId: this._productId,
|
||||
action: params.action,
|
||||
version: params.version,
|
||||
protocol: Util.defaultString(this._protocol, params.protocol),
|
||||
method: Util.defaultString(this._method, params.method),
|
||||
authType: params.authType,
|
||||
bodyType: params.bodyType,
|
||||
reqBodyType: params.reqBodyType,
|
||||
style: params.style,
|
||||
credential: this._credential,
|
||||
signatureVersion: this._signatureVersion,
|
||||
signatureAlgorithm: this._signatureAlgorithm,
|
||||
userAgent: this.getUserAgent(),
|
||||
});
|
||||
let configurationContext = new $SPI.InterceptorContextConfiguration({
|
||||
regionId: this._regionId,
|
||||
endpoint: Util.defaultString(request.endpointOverride, this._endpoint),
|
||||
endpointRule: this._endpointRule,
|
||||
endpointMap: this._endpointMap,
|
||||
endpointType: this._endpointType,
|
||||
network: this._network,
|
||||
suffix: this._suffix,
|
||||
});
|
||||
let interceptorContext = new $SPI.InterceptorContext({ });
|
||||
interceptorContext.request = requestContext;
|
||||
interceptorContext.configuration = configurationContext;
|
||||
let attributeMap = new $SPI.AttributeMap({ });
|
||||
if (!Util.isUnset(this._attributeMap)) {
|
||||
attributeMap = this._attributeMap;
|
||||
}
|
||||
|
||||
// 1. spi.modifyConfiguration(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
|
||||
await this._spi.modifyConfiguration(interceptorContext, attributeMap);
|
||||
// 2. spi.modifyRequest(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
|
||||
await this._spi.modifyRequest(interceptorContext, attributeMap);
|
||||
request_.protocol = interceptorContext.request.protocol;
|
||||
request_.method = interceptorContext.request.method;
|
||||
request_.pathname = interceptorContext.request.pathname;
|
||||
request_.query = interceptorContext.request.query;
|
||||
request_.body = interceptorContext.request.stream;
|
||||
request_.headers = interceptorContext.request.headers;
|
||||
_lastRequest = request_;
|
||||
let response_ = await $tea.doAction(request_, _runtime);
|
||||
|
||||
let responseContext = new $SPI.InterceptorContextResponse({
|
||||
statusCode: response_.statusCode,
|
||||
headers: response_.headers,
|
||||
body: response_.body,
|
||||
});
|
||||
interceptorContext.response = responseContext;
|
||||
// 3. spi.modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap);
|
||||
await this._spi.modifyResponse(interceptorContext, attributeMap);
|
||||
return {
|
||||
headers: interceptorContext.response.headers,
|
||||
statusCode: interceptorContext.response.statusCode,
|
||||
body: interceptorContext.response.deserializedBody,
|
||||
};
|
||||
} catch (ex) {
|
||||
if ($tea.isRetryable(ex)) {
|
||||
continue;
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
throw $tea.newUnretryableError(_lastRequest);
|
||||
}
|
||||
|
||||
async callApi(params: Params, request: OpenApiRequest, runtime: $Util.RuntimeOptions): Promise<{[key: string]: any}> {
|
||||
if (Util.isUnset(params)) {
|
||||
throw $tea.newError({
|
||||
code: "ParameterMissing",
|
||||
message: "'params' can not be unset",
|
||||
});
|
||||
}
|
||||
|
||||
if (Util.isUnset(this._signatureVersion) || !Util.equalString(this._signatureVersion, "v4")) {
|
||||
if (Util.isUnset(this._signatureAlgorithm) || !Util.equalString(this._signatureAlgorithm, "v2")) {
|
||||
return await this.doRequest(params, request, runtime);
|
||||
} else if (Util.equalString(params.style, "ROA") && Util.equalString(params.reqBodyType, "json")) {
|
||||
return await this.doROARequest(params.action, params.version, params.protocol, params.method, params.authType, params.pathname, params.bodyType, request, runtime);
|
||||
} else if (Util.equalString(params.style, "ROA")) {
|
||||
return await this.doROARequestWithForm(params.action, params.version, params.protocol, params.method, params.authType, params.pathname, params.bodyType, request, runtime);
|
||||
} else {
|
||||
return await this.doRPCRequest(params.action, params.version, params.protocol, params.method, params.authType, params.bodyType, request, runtime);
|
||||
}
|
||||
|
||||
} else {
|
||||
return await this.execute(params, request, runtime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Get user agent
|
||||
* @returns user agent
|
||||
*/
|
||||
getUserAgent(): string {
|
||||
let userAgent = Util.getUserAgent(this._userAgent);
|
||||
return userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Get accesskey id by using credential
|
||||
* @returns accesskey id
|
||||
*/
|
||||
async getAccessKeyId(): Promise<string> {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let accessKeyId = await this._credential.getAccessKeyId();
|
||||
return accessKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Get accesskey secret by using credential
|
||||
* @returns accesskey secret
|
||||
*/
|
||||
async getAccessKeySecret(): Promise<string> {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let secret = await this._credential.getAccessKeySecret();
|
||||
return secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Get security token by using credential
|
||||
* @returns security token
|
||||
*/
|
||||
async getSecurityToken(): Promise<string> {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let token = await this._credential.getSecurityToken();
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Get bearer token by credential
|
||||
* @returns bearer token
|
||||
*/
|
||||
async getBearerToken(): Promise<string> {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let token = this._credential.getBearerToken();
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* Get credential type by credential
|
||||
* @returns credential type e.g. access_key
|
||||
*/
|
||||
async getType(): Promise<string> {
|
||||
if (Util.isUnset(this._credential)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
let authType = this._credential.getType();
|
||||
return authType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* If inputValue is not null, return it or return defaultValue
|
||||
*
|
||||
* @param inputValue - users input value
|
||||
* @param defaultValue - default value
|
||||
* @returns the final result
|
||||
*/
|
||||
static defaultAny(inputValue: any, defaultValue: any): any {
|
||||
if (Util.isUnset(inputValue)) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return inputValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* If the endpointRule and config.endpoint are empty, throw error
|
||||
*
|
||||
* @param config - config contains the necessary information to create a client
|
||||
*/
|
||||
checkConfig(config: Config): void {
|
||||
if (Util.empty(this._endpointRule) && Util.empty(config.endpoint)) {
|
||||
throw $tea.newError({
|
||||
code: "ParameterMissing",
|
||||
message: "'config.endpoint' can not be empty",
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* set gateway client
|
||||
*
|
||||
* @param spi - .
|
||||
*/
|
||||
setGatewayClient(spi: SPI): void {
|
||||
this._spi = spi;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* set RPC header for debug
|
||||
*
|
||||
* @param headers - headers for debug, this header can be used only once.
|
||||
*/
|
||||
setRpcHeaders(headers: {[key: string ]: string}): void {
|
||||
this._headers = headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* get RPC header for debug
|
||||
*/
|
||||
getRpcHeaders(): {[key: string ]: string} {
|
||||
let headers : {[key: string ]: string} = this._headers;
|
||||
this._headers = null;
|
||||
return headers;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user