1
1
import { localize } from "vscode-nls-i18n" ;
2
- import { ExtensionContext , workspace , ConfigurationTarget , window , ProgressLocation , MessageItem } from "vscode" ;
2
+ import { ExtensionContext , workspace , ConfigurationTarget , window , ProgressLocation , MessageItem , extensions } from "vscode" ;
3
3
4
4
import { container } from "../../container" ;
5
5
import { Context } from "../../context" ;
6
6
import { tree } from "../treeDataProvider" ;
7
7
import { getCredentailByInput } from "./auth" ;
8
8
import { AbstractClient } from "tencentcloud-sdk-nodejs/tencentcloud/common/abstract_client" ;
9
9
import { Credential } from "tencentcloud-sdk-nodejs/tencentcloud/common/interface" ;
10
- import { getCamClient , getStsClient } from "@/connectivity/client" ;
10
+ import { getCamClient , getCommonClient , getStsClient } from "@/connectivity/client" ;
11
11
import * as loginMgt from "../../../views/login/loginMgt" ;
12
12
import * as settingUtils from "../../../utils/settingUtils" ;
13
13
@@ -24,6 +24,7 @@ export namespace user {
24
24
arn ?: string ;
25
25
}
26
26
27
+ export const REQUEST_CLIENT_PREFIX = "Terraform-Vscode-" ; //Terraform-1.81.61@vscode";
27
28
export const AKSK_TITLE = "TcTerraform.pickup.aksk" ;
28
29
export const OAUTH_TITLE = "TcTerraform.pickup.oauth" ;
29
30
export const AKSK_PLACEHOLD = "TcTerraform.pickup.aksk.placeholder" ;
@@ -71,10 +72,16 @@ export namespace user {
71
72
try {
72
73
// query user info
73
74
const stsClient = await getStsClient ( ) ;
74
- const stsResp = await stsClient ?. GetCallerIdentity ( ) .
75
+ const currentVersion = getExtensionVersion ( ) ;
76
+ const reqCli = `${ REQUEST_CLIENT_PREFIX } v${ currentVersion } ` ;
77
+ stsClient . sdkVersion = reqCli ;
78
+ console . log ( '[DEBUG]--------------------getStsClient:' , stsClient ) ;
79
+ // const stsClient = await getCommonClient("sts.tencentcloudapi.com", "2018-08-13");
80
+ // const stsResp = await stsClient.request("GetCallerIdentity", req).
81
+ const stsResp = await stsClient ?. GetCallerIdentity ( null ) .
75
82
then (
76
83
( result ) => {
77
- console . debug ( '[DEBUG]--------------------------------result:' , result ) ;
84
+ console . debug ( '[DEBUG]--------------------------------GetCallerIdentity result:' , result ) ;
78
85
if ( ! result ) {
79
86
throw new Error ( '[Warn] GetCallerIdentity result.TotalCount is 0.' ) ;
80
87
}
@@ -84,12 +91,15 @@ export namespace user {
84
91
throw new Error ( err ) ;
85
92
}
86
93
) ;
94
+ // ) as stsModels.GetCallerIdentityResponse;
87
95
88
96
const camClient = await getCamClient ( ) ;
89
- const camResp = await camClient ?. GetUserAppId ( ) .
97
+ camClient . sdkVersion = reqCli ;
98
+ console . log ( '[DEBUG]--------------------getCamClient:' , camClient ) ;
99
+ const camResp = await camClient ?. GetUserAppId ( null ) .
90
100
then (
91
101
( result ) => {
92
- console . debug ( '[DEBUG]--------------------------------result:' , result ) ;
102
+ console . debug ( '[DEBUG]--------------------------------GetUserAppId result:' , result ) ;
93
103
if ( ! result ) {
94
104
throw new Error ( '[Warn] GetUserAppId result.TotalCount is 0.' ) ;
95
105
}
@@ -122,6 +132,12 @@ export namespace user {
122
132
}
123
133
}
124
134
135
+ function getExtensionVersion ( ) : string {
136
+ let extension = extensions . getExtension ( 'Tencent-Cloud.vscode-tencentcloud-terraform' ) ;
137
+ let currentVersion = extension . packageJSON . version ;
138
+ return currentVersion ;
139
+ }
140
+
125
141
export async function loginOut ( ) {
126
142
const yesBtn : MessageItem = { title : localize ( "TcTerraform.common.yes" ) } ;
127
143
const action = await window . showWarningMessage (
0 commit comments