Skip to content

Commit 1c5920a

Browse files
committed
refactor: finish migration
1 parent 476e104 commit 1c5920a

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

packages/core/src/awsService/cloudWatchLogs/commands/viewLogStream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as picker from '../../../shared/ui/picker'
1111
import { MultiStepWizard, WIZARD_RETRY, WIZARD_TERMINATE, WizardStep } from '../../../shared/wizards/multiStepWizard'
1212
import { LogGroupNode } from '../explorer/logGroupNode'
1313
import { CloudWatchLogs } from 'aws-sdk'
14-
14+
import * as CloudWatchLogsV3 from '@aws-sdk/client-cloudwatch-logs'
1515
import { CloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogsClient'
1616
import { getPaginatedAwsCallIter, IteratorTransformer } from '../../../shared/utilities/collectionUtils'
1717
import {
@@ -83,7 +83,7 @@ export class DefaultSelectLogStreamWizardContext implements SelectLogStreamWizar
8383

8484
public async pickLogStream(): Promise<LogSearchChoice> {
8585
const client = new CloudWatchLogsClient(this.regionCode)
86-
const request: CloudWatchLogs.DescribeLogStreamsRequest = {
86+
const request: CloudWatchLogsV3.DescribeLogStreamsRequest = {
8787
logGroupName: this.logGroupName,
8888
orderBy: 'LastEventTime',
8989
descending: true,

packages/core/src/awsService/cloudWatchLogs/wizard/liveTailLogStreamSubmenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { createCommonButtons } from '../../../shared/ui/buttons'
88
import { createInputBox, InputBoxPrompter } from '../../../shared/ui/inputPrompter'
99
import { createQuickPick, DataQuickPickItem, QuickPickPrompter } from '../../../shared/ui/pickerPrompter'
1010
import { pageableToCollection } from '../../../shared/utilities/collectionUtils'
11-
import { CloudWatchLogs } from 'aws-sdk'
11+
import * as CloudWatchLogs from '@aws-sdk/client-cloudwatch-logs'
1212
import { isValidResponse, StepEstimator } from '../../../shared/wizards/wizard'
1313
import { isNonNullable } from '../../../shared/utilities/tsUtils'
1414
import {

packages/core/src/shared/clients/cloudWatchLogsClient.ts

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { CloudWatchLogs } from 'aws-sdk'
76
import * as CloudWatchLogsV3 from '@aws-sdk/client-cloudwatch-logs'
8-
import globals from '../extensionGlobals'
97
import { ClientWrapper } from './clientWrapper'
108

9+
// TODO: each consumer of CWL client implements their own pagination. This should be done here.
1110
export class CloudWatchLogsClient extends ClientWrapper<CloudWatchLogsV3.CloudWatchLogsClient> {
1211
public constructor(regionCode: string) {
1312
super(regionCode, CloudWatchLogsV3.CloudWatchLogsClient)
1413
}
1514

1615
public async *describeLogGroups(
17-
request: CloudWatchLogs.DescribeLogGroupsRequest = {}
18-
): AsyncIterableIterator<CloudWatchLogs.LogGroup> {
19-
const sdkClient = await this.createSdkClient()
16+
request: CloudWatchLogsV3.DescribeLogGroupsRequest = {}
17+
): AsyncIterableIterator<CloudWatchLogsV3.LogGroup> {
2018
do {
21-
const response = await this.invokeDescribeLogGroups(request, sdkClient)
19+
const response: CloudWatchLogsV3.DescribeLogGroupsResponse = await this.makeRequest(
20+
CloudWatchLogsV3.DescribeLogGroupsCommand,
21+
request
22+
)
2223
if (response.logGroups) {
2324
yield* response.logGroups
2425
}
@@ -27,37 +28,20 @@ export class CloudWatchLogsClient extends ClientWrapper<CloudWatchLogsV3.CloudWa
2728
}
2829

2930
public async describeLogStreams(
30-
request: CloudWatchLogs.DescribeLogStreamsRequest
31-
): Promise<CloudWatchLogs.DescribeLogStreamsResponse> {
32-
const sdkClient = await this.createSdkClient()
33-
34-
return sdkClient.describeLogStreams(request).promise()
31+
request: CloudWatchLogsV3.DescribeLogStreamsRequest
32+
): Promise<CloudWatchLogsV3.DescribeLogStreamsResponse> {
33+
return await this.makeRequest(CloudWatchLogsV3.DescribeLogStreamsCommand, request)
3534
}
3635

3736
public async getLogEvents(
38-
request: CloudWatchLogs.GetLogEventsRequest
39-
): Promise<CloudWatchLogs.GetLogEventsResponse> {
40-
const sdkClient = await this.createSdkClient()
41-
42-
return sdkClient.getLogEvents(request).promise()
37+
request: CloudWatchLogsV3.GetLogEventsRequest
38+
): Promise<CloudWatchLogsV3.GetLogEventsResponse> {
39+
return await this.makeRequest(CloudWatchLogsV3.GetLogEventsCommand, request)
4340
}
4441

4542
public async filterLogEvents(
46-
request: CloudWatchLogs.FilterLogEventsRequest
47-
): Promise<CloudWatchLogs.FilterLogEventsResponse> {
48-
const sdkClient = await this.createSdkClient()
49-
50-
return sdkClient.filterLogEvents(request).promise()
51-
}
52-
53-
protected async invokeDescribeLogGroups(
54-
request: CloudWatchLogs.DescribeLogGroupsRequest,
55-
sdkClient: CloudWatchLogs
56-
): Promise<CloudWatchLogs.DescribeLogGroupsResponse> {
57-
return sdkClient.describeLogGroups(request).promise()
58-
}
59-
60-
protected async createSdkClient(): Promise<CloudWatchLogs> {
61-
return await globals.sdkClientBuilder.createAwsService(CloudWatchLogs, undefined, this.regionCode)
43+
request: CloudWatchLogsV3.FilterLogEventsRequest
44+
): Promise<CloudWatchLogsV3.FilterLogEventsResponse> {
45+
return await this.makeRequest(CloudWatchLogsV3.FilterLogEventsCommand, request)
6246
}
6347
}

0 commit comments

Comments
 (0)