@alicloud/dataworks-public20240518 7.2.3 → 7.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/client.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  // This file is auto-generated, don't edit it
2
2
  import * as $dara from '@darabonba/typescript';
3
- import OSS, * as $OSS from '@alicloud/oss-client';
4
- import OpenPlatform, * as $OpenPlatform from '@alicloud/openplatform20191219';
5
- import * as $OSSUtil from '@alicloud/oss-util';
6
- import * as $FileForm from '@alicloud/tea-fileform';
7
- import OpenApi from '@alicloud/openapi-core';
3
+ import OpenApi, * as $OpenApi from '@alicloud/openapi-core';
8
4
  import { OpenApiUtil, $OpenApiUtil }from '@alicloud/openapi-core';
9
5
 
10
6
 
@@ -46,6 +42,42 @@ export default class Client extends OpenApi {
46
42
  this._endpoint = this.getEndpoint("dataworks-public", this._regionId, this._endpointRule, this._network, this._suffix, this._endpointMap, this._endpoint);
47
43
  }
48
44
 
45
+ async _postOSSObject(bucketName: string, form: {[key: string]: any}): Promise<{[key: string]: any}> {
46
+ let request_ = new $dara.Request();
47
+ let boundary = $dara.Form.getBoundary();
48
+ request_.protocol = "HTTPS";
49
+ request_.method = "POST";
50
+ request_.pathname = `/`;
51
+ request_.headers = {
52
+ host: String(form["host"]),
53
+ date: OpenApiUtil.getDateUTCString(),
54
+ 'user-agent': OpenApiUtil.getUserAgent(""),
55
+ };
56
+ request_.headers["content-type"] = `multipart/form-data; boundary=${boundary}`;
57
+ request_.body = $dara.Form.toFileForm(form, boundary);
58
+ let response_ = await $dara.doAction(request_);
59
+
60
+ let respMap : {[key: string]: any} = null;
61
+ let bodyStr = await $dara.Stream.readAsString(response_.body);
62
+ if ((response_.statusCode >= 400) && (response_.statusCode < 600)) {
63
+ respMap = $dara.XML.parseXml(bodyStr, null);
64
+ let err = respMap["Error"];
65
+ throw new $OpenApi.ClientError({
66
+ code: String(err["Code"]),
67
+ message: String(err["Message"]),
68
+ data: {
69
+ httpCode: response_.statusCode,
70
+ requestId: String(err["RequestId"]),
71
+ hostId: String(err["HostId"]),
72
+ },
73
+ });
74
+ }
75
+
76
+ respMap = $dara.XML.parseXml(bodyStr, null);
77
+ return {
78
+ ...respMap,
79
+ };
80
+ }
49
81
 
50
82
  getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: {[key: string ]: string}, endpoint: string): string {
51
83
  if (!$dara.isNull(endpoint)) {
@@ -594,41 +626,46 @@ export default class Client extends OpenApi {
594
626
  request.transformationRulesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.transformationRules, "TransformationRules", "json");
595
627
  }
596
628
 
597
- let body : {[key: string ]: any} = { };
598
- if (!$dara.isNull(request.description)) {
599
- body["Description"] = request.description;
600
- }
601
-
602
- if (!$dara.isNull(request.destinationDataSourceSettingsShrink)) {
603
- body["DestinationDataSourceSettings"] = request.destinationDataSourceSettingsShrink;
604
- }
605
-
629
+ let query = { };
606
630
  if (!$dara.isNull(request.destinationDataSourceType)) {
607
- body["DestinationDataSourceType"] = request.destinationDataSourceType;
631
+ query["DestinationDataSourceType"] = request.destinationDataSourceType;
608
632
  }
609
633
 
610
634
  if (!$dara.isNull(request.jobName)) {
611
- body["JobName"] = request.jobName;
612
- }
613
-
614
- if (!$dara.isNull(request.jobSettingsShrink)) {
615
- body["JobSettings"] = request.jobSettingsShrink;
635
+ query["JobName"] = request.jobName;
616
636
  }
617
637
 
618
638
  if (!$dara.isNull(request.jobType)) {
619
- body["JobType"] = request.jobType;
639
+ query["JobType"] = request.jobType;
620
640
  }
621
641
 
622
642
  if (!$dara.isNull(request.migrationType)) {
623
- body["MigrationType"] = request.migrationType;
643
+ query["MigrationType"] = request.migrationType;
624
644
  }
625
645
 
626
646
  if (!$dara.isNull(request.name)) {
627
- body["Name"] = request.name;
647
+ query["Name"] = request.name;
628
648
  }
629
649
 
630
650
  if (!$dara.isNull(request.projectId)) {
631
- body["ProjectId"] = request.projectId;
651
+ query["ProjectId"] = request.projectId;
652
+ }
653
+
654
+ if (!$dara.isNull(request.sourceDataSourceType)) {
655
+ query["SourceDataSourceType"] = request.sourceDataSourceType;
656
+ }
657
+
658
+ let body : {[key: string ]: any} = { };
659
+ if (!$dara.isNull(request.description)) {
660
+ body["Description"] = request.description;
661
+ }
662
+
663
+ if (!$dara.isNull(request.destinationDataSourceSettingsShrink)) {
664
+ body["DestinationDataSourceSettings"] = request.destinationDataSourceSettingsShrink;
665
+ }
666
+
667
+ if (!$dara.isNull(request.jobSettingsShrink)) {
668
+ body["JobSettings"] = request.jobSettingsShrink;
632
669
  }
633
670
 
634
671
  if (!$dara.isNull(request.resourceSettingsShrink)) {
@@ -639,10 +676,6 @@ export default class Client extends OpenApi {
639
676
  body["SourceDataSourceSettings"] = request.sourceDataSourceSettingsShrink;
640
677
  }
641
678
 
642
- if (!$dara.isNull(request.sourceDataSourceType)) {
643
- body["SourceDataSourceType"] = request.sourceDataSourceType;
644
- }
645
-
646
679
  if (!$dara.isNull(request.tableMappingsShrink)) {
647
680
  body["TableMappings"] = request.tableMappingsShrink;
648
681
  }
@@ -652,6 +685,7 @@ export default class Client extends OpenApi {
652
685
  }
653
686
 
654
687
  let req = new $OpenApiUtil.OpenApiRequest({
688
+ query: OpenApiUtil.query(query),
655
689
  body: OpenApiUtil.parseToMap(body),
656
690
  });
657
691
  let params = new $OpenApiUtil.Params({
@@ -1995,12 +2029,20 @@ export default class Client extends OpenApi {
1995
2029
 
1996
2030
  async createResourceAdvance(request: $_model.CreateResourceAdvanceRequest, runtime: $dara.RuntimeOptions): Promise<$_model.CreateResourceResponse> {
1997
2031
  // Step 0: init client
1998
- let accessKeyId = await this._credential.getAccessKeyId();
1999
- let accessKeySecret = await this._credential.getAccessKeySecret();
2000
- let securityToken = await this._credential.getSecurityToken();
2001
- let credentialType = this._credential.getType();
2032
+ if ($dara.isNull(this._credential)) {
2033
+ throw new $OpenApi.ClientError({
2034
+ code: "InvalidCredentials",
2035
+ 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.",
2036
+ });
2037
+ }
2038
+
2039
+ let credentialModel = await this._credential.getCredential();
2040
+ let accessKeyId = credentialModel.accessKeyId;
2041
+ let accessKeySecret = credentialModel.accessKeySecret;
2042
+ let securityToken = credentialModel.securityToken;
2043
+ let credentialType = credentialModel.type;
2002
2044
  let openPlatformEndpoint = this._openPlatformEndpoint;
2003
- if ($dara.isNull(openPlatformEndpoint)) {
2045
+ if ($dara.isNull(openPlatformEndpoint) || openPlatformEndpoint == "") {
2004
2046
  openPlatformEndpoint = "openplatform.aliyuncs.com";
2005
2047
  }
2006
2048
 
@@ -2017,51 +2059,54 @@ export default class Client extends OpenApi {
2017
2059
  protocol: this._protocol,
2018
2060
  regionId: this._regionId,
2019
2061
  });
2020
- let authClient = new OpenPlatform(authConfig);
2021
- let authRequest = new $OpenPlatform.AuthorizeFileUploadRequest({
2022
- product: "dataworks-public",
2023
- regionId: this._regionId,
2062
+ let authClient = new OpenApi(authConfig);
2063
+ let authRequest = {
2064
+ Product: "dataworks-public",
2065
+ RegionId: this._regionId,
2066
+ };
2067
+ let authReq = new $OpenApiUtil.OpenApiRequest({
2068
+ query: OpenApiUtil.query(authRequest),
2024
2069
  });
2025
- let authResponse = new $OpenPlatform.AuthorizeFileUploadResponse({ });
2026
- let ossConfig = new $OSS.Config({
2027
- accessKeyId: accessKeyId,
2028
- accessKeySecret: accessKeySecret,
2029
- type: "access_key",
2030
- protocol: this._protocol,
2031
- regionId: this._regionId,
2070
+ let authParams = new $OpenApiUtil.Params({
2071
+ action: "AuthorizeFileUpload",
2072
+ version: "2019-12-19",
2073
+ protocol: "HTTPS",
2074
+ pathname: "/",
2075
+ method: "GET",
2076
+ authType: "AK",
2077
+ style: "RPC",
2078
+ reqBodyType: "formData",
2079
+ bodyType: "json",
2032
2080
  });
2033
- let ossClient : OSS = new OSS(ossConfig);
2034
- let fileObj = new $FileForm.FileField({ });
2035
- let ossHeader = new $OSS.PostObjectRequestHeader({ });
2036
- let uploadRequest = new $OSS.PostObjectRequest({ });
2037
- let ossRuntime = new $OSSUtil.RuntimeOptions({ });
2038
- OpenApiUtil.convert(runtime, ossRuntime);
2081
+ let authResponse : {[key: string]: any} = { };
2082
+ let fileObj = new $dara.FileField({ });
2083
+ let ossHeader : {[key: string]: any} = { };
2084
+ let tmpBody : {[key: string]: any} = { };
2085
+ let useAccelerate : boolean = false;
2086
+ let authResponseBody : {[key: string ]: string} = { };
2039
2087
  let createResourceReq = new $_model.CreateResourceRequest({ });
2040
2088
  OpenApiUtil.convert(request, createResourceReq);
2041
2089
  if (!$dara.isNull(request.resourceFileObject)) {
2042
- authResponse = await authClient.authorizeFileUploadWithOptions(authRequest, runtime);
2043
- ossConfig.accessKeyId = authResponse.body.accessKeyId;
2044
- ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, this._endpointType);
2045
- ossClient = new OSS(ossConfig);
2046
- fileObj = new $FileForm.FileField({
2047
- filename: authResponse.body.objectKey,
2090
+ authResponse = await authClient.callApi(authParams, authReq, runtime);
2091
+ tmpBody = authResponse["body"];
2092
+ useAccelerate = Boolean(tmpBody["UseAccelerate"]);
2093
+ authResponseBody = OpenApiUtil.stringifyMapValue(tmpBody);
2094
+ fileObj = new $dara.FileField({
2095
+ filename: authResponseBody["ObjectKey"],
2048
2096
  content: request.resourceFileObject,
2049
2097
  contentType: "",
2050
2098
  });
2051
- ossHeader = new $OSS.PostObjectRequestHeader({
2052
- accessKeyId: authResponse.body.accessKeyId,
2053
- policy: authResponse.body.encodedPolicy,
2054
- signature: authResponse.body.signature,
2055
- key: authResponse.body.objectKey,
2099
+ ossHeader = {
2100
+ host: `${authResponseBody["Bucket"]}.${OpenApiUtil.getEndpoint(authResponseBody["Endpoint"], useAccelerate, this._endpointType)}`,
2101
+ OSSAccessKeyId: authResponseBody["AccessKeyId"],
2102
+ policy: authResponseBody["EncodedPolicy"],
2103
+ Signature: authResponseBody["Signature"],
2104
+ key: authResponseBody["ObjectKey"],
2056
2105
  file: fileObj,
2057
- successActionStatus: "201",
2058
- });
2059
- uploadRequest = new $OSS.PostObjectRequest({
2060
- bucketName: authResponse.body.bucket,
2061
- header: ossHeader,
2062
- });
2063
- await ossClient.postObject(uploadRequest, ossRuntime);
2064
- createResourceReq.resourceFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
2106
+ success_action_status: "201",
2107
+ };
2108
+ await this._postOSSObject(authResponseBody["Bucket"], ossHeader);
2109
+ createResourceReq.resourceFile = `http://${authResponseBody["Bucket"]}.${authResponseBody["Endpoint"]}/${authResponseBody["ObjectKey"]}`;
2065
2110
  }
2066
2111
 
2067
2112
  let createResourceResp = await this.createResourceWithOptions(createResourceReq, runtime);
@@ -2156,12 +2201,20 @@ export default class Client extends OpenApi {
2156
2201
 
2157
2202
  async createResourceFileAdvance(request: $_model.CreateResourceFileAdvanceRequest, runtime: $dara.RuntimeOptions): Promise<$_model.CreateResourceFileResponse> {
2158
2203
  // Step 0: init client
2159
- let accessKeyId = await this._credential.getAccessKeyId();
2160
- let accessKeySecret = await this._credential.getAccessKeySecret();
2161
- let securityToken = await this._credential.getSecurityToken();
2162
- let credentialType = this._credential.getType();
2204
+ if ($dara.isNull(this._credential)) {
2205
+ throw new $OpenApi.ClientError({
2206
+ code: "InvalidCredentials",
2207
+ 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.",
2208
+ });
2209
+ }
2210
+
2211
+ let credentialModel = await this._credential.getCredential();
2212
+ let accessKeyId = credentialModel.accessKeyId;
2213
+ let accessKeySecret = credentialModel.accessKeySecret;
2214
+ let securityToken = credentialModel.securityToken;
2215
+ let credentialType = credentialModel.type;
2163
2216
  let openPlatformEndpoint = this._openPlatformEndpoint;
2164
- if ($dara.isNull(openPlatformEndpoint)) {
2217
+ if ($dara.isNull(openPlatformEndpoint) || openPlatformEndpoint == "") {
2165
2218
  openPlatformEndpoint = "openplatform.aliyuncs.com";
2166
2219
  }
2167
2220
 
@@ -2178,51 +2231,54 @@ export default class Client extends OpenApi {
2178
2231
  protocol: this._protocol,
2179
2232
  regionId: this._regionId,
2180
2233
  });
2181
- let authClient = new OpenPlatform(authConfig);
2182
- let authRequest = new $OpenPlatform.AuthorizeFileUploadRequest({
2183
- product: "dataworks-public",
2184
- regionId: this._regionId,
2234
+ let authClient = new OpenApi(authConfig);
2235
+ let authRequest = {
2236
+ Product: "dataworks-public",
2237
+ RegionId: this._regionId,
2238
+ };
2239
+ let authReq = new $OpenApiUtil.OpenApiRequest({
2240
+ query: OpenApiUtil.query(authRequest),
2185
2241
  });
2186
- let authResponse = new $OpenPlatform.AuthorizeFileUploadResponse({ });
2187
- let ossConfig = new $OSS.Config({
2188
- accessKeyId: accessKeyId,
2189
- accessKeySecret: accessKeySecret,
2190
- type: "access_key",
2191
- protocol: this._protocol,
2192
- regionId: this._regionId,
2242
+ let authParams = new $OpenApiUtil.Params({
2243
+ action: "AuthorizeFileUpload",
2244
+ version: "2019-12-19",
2245
+ protocol: "HTTPS",
2246
+ pathname: "/",
2247
+ method: "GET",
2248
+ authType: "AK",
2249
+ style: "RPC",
2250
+ reqBodyType: "formData",
2251
+ bodyType: "json",
2193
2252
  });
2194
- let ossClient : OSS = new OSS(ossConfig);
2195
- let fileObj = new $FileForm.FileField({ });
2196
- let ossHeader = new $OSS.PostObjectRequestHeader({ });
2197
- let uploadRequest = new $OSS.PostObjectRequest({ });
2198
- let ossRuntime = new $OSSUtil.RuntimeOptions({ });
2199
- OpenApiUtil.convert(runtime, ossRuntime);
2253
+ let authResponse : {[key: string]: any} = { };
2254
+ let fileObj = new $dara.FileField({ });
2255
+ let ossHeader : {[key: string]: any} = { };
2256
+ let tmpBody : {[key: string]: any} = { };
2257
+ let useAccelerate : boolean = false;
2258
+ let authResponseBody : {[key: string ]: string} = { };
2200
2259
  let createResourceFileReq = new $_model.CreateResourceFileRequest({ });
2201
2260
  OpenApiUtil.convert(request, createResourceFileReq);
2202
2261
  if (!$dara.isNull(request.resourceFileObject)) {
2203
- authResponse = await authClient.authorizeFileUploadWithOptions(authRequest, runtime);
2204
- ossConfig.accessKeyId = authResponse.body.accessKeyId;
2205
- ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, this._endpointType);
2206
- ossClient = new OSS(ossConfig);
2207
- fileObj = new $FileForm.FileField({
2208
- filename: authResponse.body.objectKey,
2262
+ authResponse = await authClient.callApi(authParams, authReq, runtime);
2263
+ tmpBody = authResponse["body"];
2264
+ useAccelerate = Boolean(tmpBody["UseAccelerate"]);
2265
+ authResponseBody = OpenApiUtil.stringifyMapValue(tmpBody);
2266
+ fileObj = new $dara.FileField({
2267
+ filename: authResponseBody["ObjectKey"],
2209
2268
  content: request.resourceFileObject,
2210
2269
  contentType: "",
2211
2270
  });
2212
- ossHeader = new $OSS.PostObjectRequestHeader({
2213
- accessKeyId: authResponse.body.accessKeyId,
2214
- policy: authResponse.body.encodedPolicy,
2215
- signature: authResponse.body.signature,
2216
- key: authResponse.body.objectKey,
2271
+ ossHeader = {
2272
+ host: `${authResponseBody["Bucket"]}.${OpenApiUtil.getEndpoint(authResponseBody["Endpoint"], useAccelerate, this._endpointType)}`,
2273
+ OSSAccessKeyId: authResponseBody["AccessKeyId"],
2274
+ policy: authResponseBody["EncodedPolicy"],
2275
+ Signature: authResponseBody["Signature"],
2276
+ key: authResponseBody["ObjectKey"],
2217
2277
  file: fileObj,
2218
- successActionStatus: "201",
2219
- });
2220
- uploadRequest = new $OSS.PostObjectRequest({
2221
- bucketName: authResponse.body.bucket,
2222
- header: ossHeader,
2223
- });
2224
- await ossClient.postObject(uploadRequest, ossRuntime);
2225
- createResourceFileReq.resourceFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
2278
+ success_action_status: "201",
2279
+ };
2280
+ await this._postOSSObject(authResponseBody["Bucket"], ossHeader);
2281
+ createResourceFileReq.resourceFile = `http://${authResponseBody["Bucket"]}.${authResponseBody["Endpoint"]}/${authResponseBody["ObjectKey"]}`;
2226
2282
  }
2227
2283
 
2228
2284
  let createResourceFileResp = await this.createResourceFileWithOptions(createResourceFileReq, runtime);
@@ -6147,12 +6203,20 @@ export default class Client extends OpenApi {
6147
6203
 
6148
6204
  async importCertificateAdvance(request: $_model.ImportCertificateAdvanceRequest, runtime: $dara.RuntimeOptions): Promise<$_model.ImportCertificateResponse> {
6149
6205
  // Step 0: init client
6150
- let accessKeyId = await this._credential.getAccessKeyId();
6151
- let accessKeySecret = await this._credential.getAccessKeySecret();
6152
- let securityToken = await this._credential.getSecurityToken();
6153
- let credentialType = this._credential.getType();
6206
+ if ($dara.isNull(this._credential)) {
6207
+ throw new $OpenApi.ClientError({
6208
+ code: "InvalidCredentials",
6209
+ 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.",
6210
+ });
6211
+ }
6212
+
6213
+ let credentialModel = await this._credential.getCredential();
6214
+ let accessKeyId = credentialModel.accessKeyId;
6215
+ let accessKeySecret = credentialModel.accessKeySecret;
6216
+ let securityToken = credentialModel.securityToken;
6217
+ let credentialType = credentialModel.type;
6154
6218
  let openPlatformEndpoint = this._openPlatformEndpoint;
6155
- if ($dara.isNull(openPlatformEndpoint)) {
6219
+ if ($dara.isNull(openPlatformEndpoint) || openPlatformEndpoint == "") {
6156
6220
  openPlatformEndpoint = "openplatform.aliyuncs.com";
6157
6221
  }
6158
6222
 
@@ -6169,51 +6233,54 @@ export default class Client extends OpenApi {
6169
6233
  protocol: this._protocol,
6170
6234
  regionId: this._regionId,
6171
6235
  });
6172
- let authClient = new OpenPlatform(authConfig);
6173
- let authRequest = new $OpenPlatform.AuthorizeFileUploadRequest({
6174
- product: "dataworks-public",
6175
- regionId: this._regionId,
6236
+ let authClient = new OpenApi(authConfig);
6237
+ let authRequest = {
6238
+ Product: "dataworks-public",
6239
+ RegionId: this._regionId,
6240
+ };
6241
+ let authReq = new $OpenApiUtil.OpenApiRequest({
6242
+ query: OpenApiUtil.query(authRequest),
6176
6243
  });
6177
- let authResponse = new $OpenPlatform.AuthorizeFileUploadResponse({ });
6178
- let ossConfig = new $OSS.Config({
6179
- accessKeyId: accessKeyId,
6180
- accessKeySecret: accessKeySecret,
6181
- type: "access_key",
6182
- protocol: this._protocol,
6183
- regionId: this._regionId,
6244
+ let authParams = new $OpenApiUtil.Params({
6245
+ action: "AuthorizeFileUpload",
6246
+ version: "2019-12-19",
6247
+ protocol: "HTTPS",
6248
+ pathname: "/",
6249
+ method: "GET",
6250
+ authType: "AK",
6251
+ style: "RPC",
6252
+ reqBodyType: "formData",
6253
+ bodyType: "json",
6184
6254
  });
6185
- let ossClient : OSS = new OSS(ossConfig);
6186
- let fileObj = new $FileForm.FileField({ });
6187
- let ossHeader = new $OSS.PostObjectRequestHeader({ });
6188
- let uploadRequest = new $OSS.PostObjectRequest({ });
6189
- let ossRuntime = new $OSSUtil.RuntimeOptions({ });
6190
- OpenApiUtil.convert(runtime, ossRuntime);
6255
+ let authResponse : {[key: string]: any} = { };
6256
+ let fileObj = new $dara.FileField({ });
6257
+ let ossHeader : {[key: string]: any} = { };
6258
+ let tmpBody : {[key: string]: any} = { };
6259
+ let useAccelerate : boolean = false;
6260
+ let authResponseBody : {[key: string ]: string} = { };
6191
6261
  let importCertificateReq = new $_model.ImportCertificateRequest({ });
6192
6262
  OpenApiUtil.convert(request, importCertificateReq);
6193
6263
  if (!$dara.isNull(request.certificateFileObject)) {
6194
- authResponse = await authClient.authorizeFileUploadWithOptions(authRequest, runtime);
6195
- ossConfig.accessKeyId = authResponse.body.accessKeyId;
6196
- ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, this._endpointType);
6197
- ossClient = new OSS(ossConfig);
6198
- fileObj = new $FileForm.FileField({
6199
- filename: authResponse.body.objectKey,
6264
+ authResponse = await authClient.callApi(authParams, authReq, runtime);
6265
+ tmpBody = authResponse["body"];
6266
+ useAccelerate = Boolean(tmpBody["UseAccelerate"]);
6267
+ authResponseBody = OpenApiUtil.stringifyMapValue(tmpBody);
6268
+ fileObj = new $dara.FileField({
6269
+ filename: authResponseBody["ObjectKey"],
6200
6270
  content: request.certificateFileObject,
6201
6271
  contentType: "",
6202
6272
  });
6203
- ossHeader = new $OSS.PostObjectRequestHeader({
6204
- accessKeyId: authResponse.body.accessKeyId,
6205
- policy: authResponse.body.encodedPolicy,
6206
- signature: authResponse.body.signature,
6207
- key: authResponse.body.objectKey,
6273
+ ossHeader = {
6274
+ host: `${authResponseBody["Bucket"]}.${OpenApiUtil.getEndpoint(authResponseBody["Endpoint"], useAccelerate, this._endpointType)}`,
6275
+ OSSAccessKeyId: authResponseBody["AccessKeyId"],
6276
+ policy: authResponseBody["EncodedPolicy"],
6277
+ Signature: authResponseBody["Signature"],
6278
+ key: authResponseBody["ObjectKey"],
6208
6279
  file: fileObj,
6209
- successActionStatus: "201",
6210
- });
6211
- uploadRequest = new $OSS.PostObjectRequest({
6212
- bucketName: authResponse.body.bucket,
6213
- header: ossHeader,
6214
- });
6215
- await ossClient.postObject(uploadRequest, ossRuntime);
6216
- importCertificateReq.certificateFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
6280
+ success_action_status: "201",
6281
+ };
6282
+ await this._postOSSObject(authResponseBody["Bucket"], ossHeader);
6283
+ importCertificateReq.certificateFile = `http://${authResponseBody["Bucket"]}.${authResponseBody["Endpoint"]}/${authResponseBody["ObjectKey"]}`;
6217
6284
  }
6218
6285
 
6219
6286
  let importCertificateResp = await this.importCertificateWithOptions(importCertificateReq, runtime);
@@ -10945,15 +11012,19 @@ export default class Client extends OpenApi {
10945
11012
  }
10946
11013
 
10947
11014
  let query = { };
11015
+ if (!$dara.isNull(request.DIJobId)) {
11016
+ query["DIJobId"] = request.DIJobId;
11017
+ }
11018
+
10948
11019
  if (!$dara.isNull(request.id)) {
10949
11020
  query["Id"] = request.id;
10950
11021
  }
10951
11022
 
10952
- let body : {[key: string ]: any} = { };
10953
- if (!$dara.isNull(request.DIJobId)) {
10954
- body["DIJobId"] = request.DIJobId;
11023
+ if (!$dara.isNull(request.projectId)) {
11024
+ query["ProjectId"] = request.projectId;
10955
11025
  }
10956
11026
 
11027
+ let body : {[key: string ]: any} = { };
10957
11028
  if (!$dara.isNull(request.description)) {
10958
11029
  body["Description"] = request.description;
10959
11030
  }
@@ -10962,10 +11033,6 @@ export default class Client extends OpenApi {
10962
11033
  body["JobSettings"] = request.jobSettingsShrink;
10963
11034
  }
10964
11035
 
10965
- if (!$dara.isNull(request.projectId)) {
10966
- body["ProjectId"] = request.projectId;
10967
- }
10968
-
10969
11036
  if (!$dara.isNull(request.resourceSettingsShrink)) {
10970
11037
  body["ResourceSettings"] = request.resourceSettingsShrink;
10971
11038
  }
@@ -11978,12 +12045,20 @@ export default class Client extends OpenApi {
11978
12045
 
11979
12046
  async updateResourceAdvance(request: $_model.UpdateResourceAdvanceRequest, runtime: $dara.RuntimeOptions): Promise<$_model.UpdateResourceResponse> {
11980
12047
  // Step 0: init client
11981
- let accessKeyId = await this._credential.getAccessKeyId();
11982
- let accessKeySecret = await this._credential.getAccessKeySecret();
11983
- let securityToken = await this._credential.getSecurityToken();
11984
- let credentialType = this._credential.getType();
12048
+ if ($dara.isNull(this._credential)) {
12049
+ throw new $OpenApi.ClientError({
12050
+ code: "InvalidCredentials",
12051
+ 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.",
12052
+ });
12053
+ }
12054
+
12055
+ let credentialModel = await this._credential.getCredential();
12056
+ let accessKeyId = credentialModel.accessKeyId;
12057
+ let accessKeySecret = credentialModel.accessKeySecret;
12058
+ let securityToken = credentialModel.securityToken;
12059
+ let credentialType = credentialModel.type;
11985
12060
  let openPlatformEndpoint = this._openPlatformEndpoint;
11986
- if ($dara.isNull(openPlatformEndpoint)) {
12061
+ if ($dara.isNull(openPlatformEndpoint) || openPlatformEndpoint == "") {
11987
12062
  openPlatformEndpoint = "openplatform.aliyuncs.com";
11988
12063
  }
11989
12064
 
@@ -12000,51 +12075,54 @@ export default class Client extends OpenApi {
12000
12075
  protocol: this._protocol,
12001
12076
  regionId: this._regionId,
12002
12077
  });
12003
- let authClient = new OpenPlatform(authConfig);
12004
- let authRequest = new $OpenPlatform.AuthorizeFileUploadRequest({
12005
- product: "dataworks-public",
12006
- regionId: this._regionId,
12078
+ let authClient = new OpenApi(authConfig);
12079
+ let authRequest = {
12080
+ Product: "dataworks-public",
12081
+ RegionId: this._regionId,
12082
+ };
12083
+ let authReq = new $OpenApiUtil.OpenApiRequest({
12084
+ query: OpenApiUtil.query(authRequest),
12007
12085
  });
12008
- let authResponse = new $OpenPlatform.AuthorizeFileUploadResponse({ });
12009
- let ossConfig = new $OSS.Config({
12010
- accessKeyId: accessKeyId,
12011
- accessKeySecret: accessKeySecret,
12012
- type: "access_key",
12013
- protocol: this._protocol,
12014
- regionId: this._regionId,
12086
+ let authParams = new $OpenApiUtil.Params({
12087
+ action: "AuthorizeFileUpload",
12088
+ version: "2019-12-19",
12089
+ protocol: "HTTPS",
12090
+ pathname: "/",
12091
+ method: "GET",
12092
+ authType: "AK",
12093
+ style: "RPC",
12094
+ reqBodyType: "formData",
12095
+ bodyType: "json",
12015
12096
  });
12016
- let ossClient : OSS = new OSS(ossConfig);
12017
- let fileObj = new $FileForm.FileField({ });
12018
- let ossHeader = new $OSS.PostObjectRequestHeader({ });
12019
- let uploadRequest = new $OSS.PostObjectRequest({ });
12020
- let ossRuntime = new $OSSUtil.RuntimeOptions({ });
12021
- OpenApiUtil.convert(runtime, ossRuntime);
12097
+ let authResponse : {[key: string]: any} = { };
12098
+ let fileObj = new $dara.FileField({ });
12099
+ let ossHeader : {[key: string]: any} = { };
12100
+ let tmpBody : {[key: string]: any} = { };
12101
+ let useAccelerate : boolean = false;
12102
+ let authResponseBody : {[key: string ]: string} = { };
12022
12103
  let updateResourceReq = new $_model.UpdateResourceRequest({ });
12023
12104
  OpenApiUtil.convert(request, updateResourceReq);
12024
12105
  if (!$dara.isNull(request.resourceFileObject)) {
12025
- authResponse = await authClient.authorizeFileUploadWithOptions(authRequest, runtime);
12026
- ossConfig.accessKeyId = authResponse.body.accessKeyId;
12027
- ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, this._endpointType);
12028
- ossClient = new OSS(ossConfig);
12029
- fileObj = new $FileForm.FileField({
12030
- filename: authResponse.body.objectKey,
12106
+ authResponse = await authClient.callApi(authParams, authReq, runtime);
12107
+ tmpBody = authResponse["body"];
12108
+ useAccelerate = Boolean(tmpBody["UseAccelerate"]);
12109
+ authResponseBody = OpenApiUtil.stringifyMapValue(tmpBody);
12110
+ fileObj = new $dara.FileField({
12111
+ filename: authResponseBody["ObjectKey"],
12031
12112
  content: request.resourceFileObject,
12032
12113
  contentType: "",
12033
12114
  });
12034
- ossHeader = new $OSS.PostObjectRequestHeader({
12035
- accessKeyId: authResponse.body.accessKeyId,
12036
- policy: authResponse.body.encodedPolicy,
12037
- signature: authResponse.body.signature,
12038
- key: authResponse.body.objectKey,
12115
+ ossHeader = {
12116
+ host: `${authResponseBody["Bucket"]}.${OpenApiUtil.getEndpoint(authResponseBody["Endpoint"], useAccelerate, this._endpointType)}`,
12117
+ OSSAccessKeyId: authResponseBody["AccessKeyId"],
12118
+ policy: authResponseBody["EncodedPolicy"],
12119
+ Signature: authResponseBody["Signature"],
12120
+ key: authResponseBody["ObjectKey"],
12039
12121
  file: fileObj,
12040
- successActionStatus: "201",
12041
- });
12042
- uploadRequest = new $OSS.PostObjectRequest({
12043
- bucketName: authResponse.body.bucket,
12044
- header: ossHeader,
12045
- });
12046
- await ossClient.postObject(uploadRequest, ossRuntime);
12047
- updateResourceReq.resourceFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
12122
+ success_action_status: "201",
12123
+ };
12124
+ await this._postOSSObject(authResponseBody["Bucket"], ossHeader);
12125
+ updateResourceReq.resourceFile = `http://${authResponseBody["Bucket"]}.${authResponseBody["Endpoint"]}/${authResponseBody["ObjectKey"]}`;
12048
12126
  }
12049
12127
 
12050
12128
  let updateResourceResp = await this.updateResourceWithOptions(updateResourceReq, runtime);