diff --git a/packages/core/src/awsService/apprunner/explorer/apprunnerServiceNode.ts b/packages/core/src/awsService/apprunner/explorer/apprunnerServiceNode.ts index bc8a4e7401f..66d578ca0ee 100644 --- a/packages/core/src/awsService/apprunner/explorer/apprunnerServiceNode.ts +++ b/packages/core/src/awsService/apprunner/explorer/apprunnerServiceNode.ts @@ -10,13 +10,13 @@ import { AppRunnerNode } from './apprunnerNode' import { toArrayAsync, toMap } from '../../../shared/utilities/collectionUtils' import { CloudWatchLogsBase } from '../../../awsService/cloudWatchLogs/explorer/cloudWatchLogsNode' -import { CloudWatchLogs } from 'aws-sdk' import { AWSResourceNode } from '../../../shared/treeview/nodes/awsResourceNode' import * as nls from 'vscode-nls' import { getLogger } from '../../../shared/logger/logger' import { getIcon } from '../../../shared/icons' -import { DefaultCloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogsClient' +import { CloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogs' +import { LogGroup } from '@aws-sdk/client-cloudwatch-logs' const localize = nls.loadMessageBundle() const contextBase = 'awsAppRunnerServiceNode' @@ -43,7 +43,7 @@ export class AppRunnerServiceNode extends CloudWatchLogsBase implements AWSResou private readonly client: AppRunnerClient, private _info: AppRunner.Service, private currentOperation: AppRunner.OperationSummary & { Type?: ServiceOperation } = {}, - cloudwatchClient = new DefaultCloudWatchLogsClient(client.regionCode) + cloudwatchClient = new CloudWatchLogsClient(client.regionCode) ) { super('App Runner Service', parent.regionCode, cloudwatchClient) @@ -63,7 +63,7 @@ export class AppRunnerServiceNode extends CloudWatchLogsBase implements AWSResou return `https://${this._info.ServiceUrl}` } - protected async getLogGroups(): Promise> { + protected async getLogGroups(): Promise> { return toMap( await toArrayAsync( this.cloudwatchClient.describeLogGroups({ diff --git a/packages/core/src/awsService/cloudWatchLogs/commands/searchLogGroup.ts b/packages/core/src/awsService/cloudWatchLogs/commands/searchLogGroup.ts index 3ece0923dec..6b45f35fb53 100644 --- a/packages/core/src/awsService/cloudWatchLogs/commands/searchLogGroup.ts +++ b/packages/core/src/awsService/cloudWatchLogs/commands/searchLogGroup.ts @@ -17,11 +17,10 @@ import { import { DataQuickPickItem } from '../../../shared/ui/pickerPrompter' import { isValidResponse, isWizardControl, Wizard, WIZARD_RETRY } from '../../../shared/wizards/wizard' import { cwlUriSchema, msgKey, recordTelemetryFilter } from '../cloudWatchLogsUtils' -import { DefaultCloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogsClient' +import { CloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogs' import { CancellationError } from '../../../shared/utilities/timeoutUtils' import { getLogger } from '../../../shared/logger/logger' import { TimeFilterResponse, TimeFilterSubmenu } from '../timeFilterSubmenu' -import { CloudWatchLogs } from 'aws-sdk' import { ExtendedInputBoxOptions, InputBox, InputBoxPrompter } from '../../../shared/ui/inputPrompter' import { RegionSubmenu, RegionSubmenuResponse } from '../../../shared/ui/common/regionSubmenu' import { truncate } from '../../../shared/utilities/textUtilities' @@ -30,6 +29,7 @@ import { PromptResult } from '../../../shared/ui/prompter' import { ToolkitError } from '../../../shared/errors' import { Messages } from '../../../shared/utilities/messages' import { showFile } from '../../../shared/utilities/textDocumentUtilities' +import { LogGroup } from '@aws-sdk/client-cloudwatch-logs' const localize = nls.loadMessageBundle() @@ -110,7 +110,7 @@ export async function searchLogGroup( } async function getLogGroupsFromRegion(regionCode: string): Promise[]> { - const client = new DefaultCloudWatchLogsClient(regionCode) + const client = new CloudWatchLogsClient(regionCode) const logGroups = await logGroupsToArray(client.describeLogGroups()) const options = logGroups.map>((logGroupString) => ({ label: logGroupString, @@ -119,7 +119,7 @@ async function getLogGroupsFromRegion(regionCode: string): Promise): Promise { +async function logGroupsToArray(logGroups: AsyncIterableIterator): Promise { const logGroupsArray = [] for await (const logGroupObject of logGroups) { logGroupObject.logGroupName && logGroupsArray.push(logGroupObject.logGroupName) diff --git a/packages/core/src/awsService/cloudWatchLogs/commands/viewLogStream.ts b/packages/core/src/awsService/cloudWatchLogs/commands/viewLogStream.ts index 270f64380ff..87b6261110c 100644 --- a/packages/core/src/awsService/cloudWatchLogs/commands/viewLogStream.ts +++ b/packages/core/src/awsService/cloudWatchLogs/commands/viewLogStream.ts @@ -10,9 +10,8 @@ import * as vscode from 'vscode' import * as picker from '../../../shared/ui/picker' import { MultiStepWizard, WIZARD_RETRY, WIZARD_TERMINATE, WizardStep } from '../../../shared/wizards/multiStepWizard' import { LogGroupNode } from '../explorer/logGroupNode' -import { CloudWatchLogs } from 'aws-sdk' - -import { DefaultCloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogsClient' +import * as CloudWatchLogs from '@aws-sdk/client-cloudwatch-logs' +import { CloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogs' import { getPaginatedAwsCallIter, IteratorTransformer } from '../../../shared/utilities/collectionUtils' import { CloudWatchLogsGroupInfo, @@ -82,7 +81,7 @@ export class DefaultSelectLogStreamWizardContext implements SelectLogStreamWizar ) {} public async pickLogStream(): Promise { - const client = new DefaultCloudWatchLogsClient(this.regionCode) + const client = new CloudWatchLogsClient(this.regionCode) const request: CloudWatchLogs.DescribeLogStreamsRequest = { logGroupName: this.logGroupName, orderBy: 'LastEventTime', diff --git a/packages/core/src/awsService/cloudWatchLogs/explorer/cloudWatchLogsNode.ts b/packages/core/src/awsService/cloudWatchLogs/explorer/cloudWatchLogsNode.ts index 6bb305d5935..5d3891bd07e 100644 --- a/packages/core/src/awsService/cloudWatchLogs/explorer/cloudWatchLogsNode.ts +++ b/packages/core/src/awsService/cloudWatchLogs/explorer/cloudWatchLogsNode.ts @@ -6,16 +6,16 @@ import * as nls from 'vscode-nls' const localize = nls.loadMessageBundle() -import { CloudWatchLogs } from 'aws-sdk' import * as vscode from 'vscode' -import { DefaultCloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogsClient' +import { CloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogs' import { AWSTreeNodeBase } from '../../../shared/treeview/nodes/awsTreeNodeBase' import { toMap, updateInPlace, toArrayAsync } from '../../../shared/utilities/collectionUtils' import { PlaceholderNode } from '../../../shared/treeview/nodes/placeholderNode' import { makeChildrenNodes } from '../../../shared/treeview/utils' import { LogGroupNode } from './logGroupNode' +import { LogGroup } from '@aws-sdk/client-cloudwatch-logs' export abstract class CloudWatchLogsBase extends AWSTreeNodeBase { protected readonly logGroupNodes: Map @@ -24,13 +24,13 @@ export abstract class CloudWatchLogsBase extends AWSTreeNodeBase { public constructor( label: string, public override readonly regionCode: string, - protected readonly cloudwatchClient: DefaultCloudWatchLogsClient + protected readonly cloudwatchClient: CloudWatchLogsClient ) { super(label, vscode.TreeItemCollapsibleState.Collapsed) this.logGroupNodes = new Map() } - protected abstract getLogGroups(client: DefaultCloudWatchLogsClient): Promise> + protected abstract getLogGroups(client: CloudWatchLogsClient): Promise> public override async getChildren(): Promise { return await makeChildrenNodes({ @@ -58,12 +58,12 @@ export abstract class CloudWatchLogsBase extends AWSTreeNodeBase { export class CloudWatchLogsNode extends CloudWatchLogsBase { protected readonly placeholderMessage = localize('AWS.explorerNode.cloudWatchLogs.nologs', '[No log groups found]') - public constructor(regionCode: string, client = new DefaultCloudWatchLogsClient(regionCode)) { + public constructor(regionCode: string, client = new CloudWatchLogsClient(regionCode)) { super('CloudWatch Logs', regionCode, client) this.contextValue = 'awsCloudWatchLogParentNode' } - protected async getLogGroups(client: DefaultCloudWatchLogsClient): Promise> { + protected async getLogGroups(client: CloudWatchLogsClient): Promise> { return toMap(await toArrayAsync(client.describeLogGroups()), (configuration) => configuration.logGroupName) } } diff --git a/packages/core/src/awsService/cloudWatchLogs/explorer/logGroupNode.ts b/packages/core/src/awsService/cloudWatchLogs/explorer/logGroupNode.ts index 4b99c6f67cd..12c2e9dd0a8 100644 --- a/packages/core/src/awsService/cloudWatchLogs/explorer/logGroupNode.ts +++ b/packages/core/src/awsService/cloudWatchLogs/explorer/logGroupNode.ts @@ -3,19 +3,19 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { CloudWatchLogs } from 'aws-sdk' import * as os from 'os' import { AWSResourceNode } from '../../../shared/treeview/nodes/awsResourceNode' import { AWSTreeNodeBase } from '../../../shared/treeview/nodes/awsTreeNodeBase' import { getIcon } from '../../../shared/icons' import { localize } from '../../../shared/utilities/vsCodeUtils' +import { LogGroup } from '@aws-sdk/client-cloudwatch-logs' export const contextValueCloudwatchLog = 'awsCloudWatchLogNode' export class LogGroupNode extends AWSTreeNodeBase implements AWSResourceNode { public constructor( public override readonly regionCode: string, - public logGroup: CloudWatchLogs.LogGroup + public logGroup: LogGroup ) { super('') this.update(logGroup) @@ -28,7 +28,7 @@ export class LogGroupNode extends AWSTreeNodeBase implements AWSResourceNode { } } - public update(logGroup: CloudWatchLogs.LogGroup): void { + public update(logGroup: LogGroup): void { this.logGroup = logGroup this.label = this.logGroup.logGroupName || '' this.tooltip = `${this.logGroup.logGroupName}${os.EOL}${this.logGroup.arn}` diff --git a/packages/core/src/awsService/cloudWatchLogs/registry/logDataRegistry.ts b/packages/core/src/awsService/cloudWatchLogs/registry/logDataRegistry.ts index 88945d61bd2..1bbe0ce06f2 100644 --- a/packages/core/src/awsService/cloudWatchLogs/registry/logDataRegistry.ts +++ b/packages/core/src/awsService/cloudWatchLogs/registry/logDataRegistry.ts @@ -4,13 +4,13 @@ */ import * as vscode from 'vscode' -import { CloudWatchLogs } from 'aws-sdk' import { CloudWatchLogsSettings, uriToKey, msgKey, cwlUriSchema } from '../cloudWatchLogsUtils' -import { DefaultCloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogsClient' +import { CloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogs' import { waitTimeout } from '../../../shared/utilities/timeoutUtils' import { Messages } from '../../../shared/utilities/messages' import { pageableToCollection } from '../../../shared/utilities/collectionUtils' import { Settings } from '../../../shared/settings' +import * as CloudWatchLogs from '@aws-sdk/client-cloudwatch-logs' // TODO: Add debug logging statements /** Uri as a string */ @@ -212,7 +212,7 @@ export async function filterLogEventsFromUri( nextToken?: string, completeTimeout = false ): Promise { - const client = new DefaultCloudWatchLogsClient(logGroupInfo.regionName) + const client = new CloudWatchLogsClient(logGroupInfo.regionName) const cwlParameters: CloudWatchLogs.FilterLogEventsRequest = { logGroupName: logGroupInfo.groupName, @@ -301,9 +301,9 @@ export type CloudWatchLogsParameters = { } export type CloudWatchLogsResponse = { - events: CloudWatchLogs.FilteredLogEvents - nextForwardToken?: CloudWatchLogs.NextToken - nextBackwardToken?: CloudWatchLogs.NextToken + events: CloudWatchLogs.FilteredLogEvent[] + nextForwardToken?: string + nextBackwardToken?: string } export type CloudWatchLogsAction = ( @@ -323,10 +323,10 @@ export class CloudWatchLogsData { logGroupInfo!: CloudWatchLogsGroupInfo retrieveLogsFunction!: CloudWatchLogsAction next?: { - token: CloudWatchLogs.NextToken + token: string } previous?: { - token: CloudWatchLogs.NextToken + token: string } busy: boolean = false } diff --git a/packages/core/src/awsService/cloudWatchLogs/wizard/liveTailLogStreamSubmenu.ts b/packages/core/src/awsService/cloudWatchLogs/wizard/liveTailLogStreamSubmenu.ts index c94259684bb..6a9d24a5c34 100644 --- a/packages/core/src/awsService/cloudWatchLogs/wizard/liveTailLogStreamSubmenu.ts +++ b/packages/core/src/awsService/cloudWatchLogs/wizard/liveTailLogStreamSubmenu.ts @@ -3,12 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ import { Prompter, PromptResult } from '../../../shared/ui/prompter' -import { DefaultCloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogsClient' +import { CloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogs' import { createCommonButtons } from '../../../shared/ui/buttons' import { createInputBox, InputBoxPrompter } from '../../../shared/ui/inputPrompter' import { createQuickPick, DataQuickPickItem, QuickPickPrompter } from '../../../shared/ui/pickerPrompter' import { pageableToCollection } from '../../../shared/utilities/collectionUtils' -import { CloudWatchLogs } from 'aws-sdk' +import * as CloudWatchLogs from '@aws-sdk/client-cloudwatch-logs' import { isValidResponse, StepEstimator } from '../../../shared/wizards/wizard' import { isNonNullable } from '../../../shared/utilities/tsUtils' import { @@ -87,7 +87,7 @@ export class LogStreamFilterSubmenu extends Prompter { public createLogStreamSelector(): QuickPickPrompter { const helpUri = startLiveTailLogStreamNamesHelpUrl - const client = new DefaultCloudWatchLogsClient(this.region) + const client = new CloudWatchLogsClient(this.region) const request: CloudWatchLogs.DescribeLogStreamsRequest = { logGroupIdentifier: this.logGroupArn, orderBy: 'LastEventTime', diff --git a/packages/core/src/awsService/cloudWatchLogs/wizard/tailLogGroupWizard.ts b/packages/core/src/awsService/cloudWatchLogs/wizard/tailLogGroupWizard.ts index d2039686fc4..02166e3a85f 100644 --- a/packages/core/src/awsService/cloudWatchLogs/wizard/tailLogGroupWizard.ts +++ b/packages/core/src/awsService/cloudWatchLogs/wizard/tailLogGroupWizard.ts @@ -6,7 +6,7 @@ import * as nls from 'vscode-nls' import globals from '../../../shared/extensionGlobals' import { ToolkitError } from '../../../shared/errors' -import { DefaultCloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogsClient' +import { CloudWatchLogsClient } from '../../../shared/clients/cloudWatchLogs' import { cwlFilterPatternHelpUrl } from '../../../shared/constants' import { createBackButton, createExitButton, createHelpButton } from '../../../shared/ui/buttons' import { RegionSubmenu, RegionSubmenuResponse } from '../../../shared/ui/common/regionSubmenu' @@ -64,7 +64,7 @@ export function createRegionLogGroupSubmenu(): RegionSubmenu { } async function getLogGroupQuickPickOptions(regionCode: string): Promise[]> { - const client = new DefaultCloudWatchLogsClient(regionCode) + const client = new CloudWatchLogsClient(regionCode) const logGroups = client.describeLogGroups() const logGroupsOptions: DataQuickPickItem[] = [] diff --git a/packages/core/src/shared/clients/cloudWatchLogs.ts b/packages/core/src/shared/clients/cloudWatchLogs.ts new file mode 100644 index 00000000000..5e43470fa3a --- /dev/null +++ b/packages/core/src/shared/clients/cloudWatchLogs.ts @@ -0,0 +1,46 @@ +/*! + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +import * as CloudWatchLogs from '@aws-sdk/client-cloudwatch-logs' +import { ClientWrapper } from './clientWrapper' + +export class CloudWatchLogsClient extends ClientWrapper { + public constructor(regionCode: string) { + super(regionCode, CloudWatchLogs.CloudWatchLogsClient) + } + + public async *describeLogGroups( + request: CloudWatchLogs.DescribeLogGroupsRequest = {} + ): AsyncIterableIterator { + do { + const response: CloudWatchLogs.DescribeLogGroupsResponse = await this.makeRequest( + CloudWatchLogs.DescribeLogGroupsCommand, + request + ) + if (response.logGroups) { + yield* response.logGroups + } + request.nextToken = response.nextToken + } while (request.nextToken) + } + + public async describeLogStreams( + request: CloudWatchLogs.DescribeLogStreamsRequest + ): Promise { + return await this.makeRequest(CloudWatchLogs.DescribeLogStreamsCommand, request) + } + + public async getLogEvents( + request: CloudWatchLogs.GetLogEventsRequest + ): Promise { + return await this.makeRequest(CloudWatchLogs.GetLogEventsCommand, request) + } + + public async filterLogEvents( + request: CloudWatchLogs.FilterLogEventsRequest + ): Promise { + return await this.makeRequest(CloudWatchLogs.FilterLogEventsCommand, request) + } +} diff --git a/packages/core/src/shared/clients/cloudWatchLogsClient.ts b/packages/core/src/shared/clients/cloudWatchLogsClient.ts deleted file mode 100644 index 54ddc463ec0..00000000000 --- a/packages/core/src/shared/clients/cloudWatchLogsClient.ts +++ /dev/null @@ -1,61 +0,0 @@ -/*! - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * SPDX-License-Identifier: Apache-2.0 - */ - -import { CloudWatchLogs } from 'aws-sdk' -import globals from '../extensionGlobals' -import { ClassToInterfaceType } from '../utilities/tsUtils' - -export type CloudWatchLogsClient = ClassToInterfaceType -export class DefaultCloudWatchLogsClient { - public constructor(public readonly regionCode: string) {} - - public async *describeLogGroups( - request: CloudWatchLogs.DescribeLogGroupsRequest = {} - ): AsyncIterableIterator { - const sdkClient = await this.createSdkClient() - do { - const response = await this.invokeDescribeLogGroups(request, sdkClient) - if (response.logGroups) { - yield* response.logGroups - } - request.nextToken = response.nextToken - } while (request.nextToken) - } - - public async describeLogStreams( - request: CloudWatchLogs.DescribeLogStreamsRequest - ): Promise { - const sdkClient = await this.createSdkClient() - - return sdkClient.describeLogStreams(request).promise() - } - - public async getLogEvents( - request: CloudWatchLogs.GetLogEventsRequest - ): Promise { - const sdkClient = await this.createSdkClient() - - return sdkClient.getLogEvents(request).promise() - } - - public async filterLogEvents( - request: CloudWatchLogs.FilterLogEventsRequest - ): Promise { - const sdkClient = await this.createSdkClient() - - return sdkClient.filterLogEvents(request).promise() - } - - protected async invokeDescribeLogGroups( - request: CloudWatchLogs.DescribeLogGroupsRequest, - sdkClient: CloudWatchLogs - ): Promise { - return sdkClient.describeLogGroups(request).promise() - } - - protected async createSdkClient(): Promise { - return await globals.sdkClientBuilder.createAwsService(CloudWatchLogs, undefined, this.regionCode) - } -} diff --git a/packages/core/src/test/awsService/apprunner/explorer/apprunnerServiceNode.test.ts b/packages/core/src/test/awsService/apprunner/explorer/apprunnerServiceNode.test.ts index 5c1b992e390..8a16cd2e5f0 100644 --- a/packages/core/src/test/awsService/apprunner/explorer/apprunnerServiceNode.test.ts +++ b/packages/core/src/test/awsService/apprunner/explorer/apprunnerServiceNode.test.ts @@ -9,7 +9,7 @@ import { AppRunner } from 'aws-sdk' import { AppRunnerNode } from '../../../../awsService/apprunner/explorer/apprunnerNode' import { AppRunnerServiceNode } from '../../../../awsService/apprunner/explorer/apprunnerServiceNode' import { DefaultAppRunnerClient } from '../../../../shared/clients/apprunnerClient' -import { DefaultCloudWatchLogsClient } from '../../../../shared/clients/cloudWatchLogsClient' +import { CloudWatchLogsClient } from '../../../../shared/clients/cloudWatchLogs' import { asyncGenerator } from '../../../../shared/utilities/collectionUtils' import { AWSTreeNodeBase } from '../../../../shared/treeview/nodes/awsTreeNodeBase' import { stub } from '../../../utilities/stubber' @@ -33,7 +33,7 @@ describe('AppRunnerServiceNode', function () { }) beforeEach(function () { - const cloudwatchClient = stub(DefaultCloudWatchLogsClient, { regionCode: 'us-east-1' }) + const cloudwatchClient = stub(CloudWatchLogsClient, { regionCode: 'us-east-1' }) cloudwatchClient.describeLogGroups.returns(asyncGenerator([{ logGroupName: 'logs' }])) mockApprunnerClient = stub(DefaultAppRunnerClient, { regionCode: 'us-east-1' }) diff --git a/packages/core/src/test/awsService/cloudWatchLogs/explorer/cloudWatchLogsNode.test.ts b/packages/core/src/test/awsService/cloudWatchLogs/explorer/cloudWatchLogsNode.test.ts index ac2ebffded8..34eb3b1cd26 100644 --- a/packages/core/src/test/awsService/cloudWatchLogs/explorer/cloudWatchLogsNode.test.ts +++ b/packages/core/src/test/awsService/cloudWatchLogs/explorer/cloudWatchLogsNode.test.ts @@ -11,7 +11,7 @@ import { assertNodeListOnlyHasErrorNode, assertNodeListOnlyHasPlaceholderNode, } from '../../../utilities/explorerNodeAssertions' -import { DefaultCloudWatchLogsClient } from '../../../../shared/clients/cloudWatchLogsClient' +import { CloudWatchLogsClient } from '../../../../shared/clients/cloudWatchLogs' import { stub } from '../../../utilities/stubber' const fakeRegionCode = 'someregioncode' @@ -25,7 +25,7 @@ describe('CloudWatchLogsNode', function () { let logGroupNames: string[] function createClient() { - const client = stub(DefaultCloudWatchLogsClient, { regionCode: fakeRegionCode }) + const client = stub(CloudWatchLogsClient, { regionCode: fakeRegionCode }) client.describeLogGroups.callsFake(() => asyncGenerator(logGroupNames.map((name) => ({ logGroupName: name })))) return client diff --git a/packages/core/src/test/awsService/cloudWatchLogs/explorer/logGroupNode.test.ts b/packages/core/src/test/awsService/cloudWatchLogs/explorer/logGroupNode.test.ts index ba844e28ba1..88930b6c5cf 100644 --- a/packages/core/src/test/awsService/cloudWatchLogs/explorer/logGroupNode.test.ts +++ b/packages/core/src/test/awsService/cloudWatchLogs/explorer/logGroupNode.test.ts @@ -4,13 +4,13 @@ */ import assert from 'assert' -import { CloudWatchLogs } from 'aws-sdk' import * as os from 'os' import { LogGroupNode } from '../../../../awsService/cloudWatchLogs/explorer/logGroupNode' +import { LogGroup } from '@aws-sdk/client-cloudwatch-logs' describe('LogGroupNode', function () { let testNode: LogGroupNode - let fakeLogGroup: CloudWatchLogs.LogGroup + let fakeLogGroup: LogGroup before(function () { fakeLogGroup = { diff --git a/packages/core/src/test/awsService/cloudWatchLogs/registry/logDataRegistry.test.ts b/packages/core/src/test/awsService/cloudWatchLogs/registry/logDataRegistry.test.ts index bb6e9122860..6f65bc2438c 100644 --- a/packages/core/src/test/awsService/cloudWatchLogs/registry/logDataRegistry.test.ts +++ b/packages/core/src/test/awsService/cloudWatchLogs/registry/logDataRegistry.test.ts @@ -25,7 +25,6 @@ import { testLogData, unregisteredData, } from '../utils.test' -import { CloudWatchLogs } from 'aws-sdk' import { FilteredLogEvents } from 'aws-sdk/clients/cloudwatchlogs' import { formatDateTimestamp } from '../../../../shared/datetime' @@ -130,7 +129,7 @@ describe('LogDataRegistry', async function () { const pageToken2 = 'page2Token' function createCwlEvents(id: string, count: number): FilteredLogEvents { - let events: CloudWatchLogs.FilteredLogEvents = [] + let events: FilteredLogEvents = [] for (let i = 0; i < count; i++) { events = events.concat({ message: `message-${id}`, logStreamName: `stream-${id}` }) } @@ -141,7 +140,7 @@ describe('LogDataRegistry', async function () { return async function ( logGroupInfo: CloudWatchLogsGroupInfo, parameters: CloudWatchLogsParameters, - nextToken?: CloudWatchLogs.NextToken + nextToken?: string ) { return getSimulatedCwlResponse(nextToken, isPage1Empty) } @@ -153,10 +152,7 @@ describe('LogDataRegistry', async function () { * @param isPage1Empty A flag to indicate if Page 1 should have data/isn't the tail. * @returns */ - function getSimulatedCwlResponse( - token: CloudWatchLogs.NextToken | undefined, - isPage1Empty: boolean - ): CloudWatchLogsResponse { + function getSimulatedCwlResponse(token: string | undefined, isPage1Empty: boolean): CloudWatchLogsResponse { switch (token) { case pageToken1: if (isPage1Empty) { diff --git a/packages/core/src/test/awsService/cloudWatchLogs/utils.test.ts b/packages/core/src/test/awsService/cloudWatchLogs/utils.test.ts index 02a768c4f07..e51f249c1f8 100644 --- a/packages/core/src/test/awsService/cloudWatchLogs/utils.test.ts +++ b/packages/core/src/test/awsService/cloudWatchLogs/utils.test.ts @@ -4,7 +4,6 @@ */ import assert from 'assert' -import { CloudWatchLogs } from 'aws-sdk' import * as vscode from 'vscode' import { cwlUriSchema, uriToKey } from '../../../awsService/cloudWatchLogs/cloudWatchLogsUtils' import { @@ -26,7 +25,7 @@ export const backwardToken = 'backward' export async function returnPaginatedEvents( logGroupInfo: CloudWatchLogsGroupInfo, parameters: CloudWatchLogsParameters, - nextToken?: CloudWatchLogs.NextToken + nextToken?: string ) { switch (nextToken) { case forwardToken: @@ -45,7 +44,7 @@ export async function returnPaginatedEvents( export async function returnNonEmptyPaginatedEvents( logGroupInfo: CloudWatchLogsGroupInfo, parameters: CloudWatchLogsParameters, - nextToken?: CloudWatchLogs.NextToken + nextToken?: string ) { const result = await returnPaginatedEvents(logGroupInfo, parameters, nextToken) if (result.events.length === 0) { diff --git a/packages/core/src/test/shared/utilities/collectionUtils.test.ts b/packages/core/src/test/shared/utilities/collectionUtils.test.ts index 1ab5a449034..53ddc39eff8 100644 --- a/packages/core/src/test/shared/utilities/collectionUtils.test.ts +++ b/packages/core/src/test/shared/utilities/collectionUtils.test.ts @@ -4,7 +4,6 @@ */ import assert from 'assert' -import { CloudWatchLogs } from 'aws-sdk' import * as sinon from 'sinon' import * as vscode from 'vscode' import { AsyncCollection } from '../../../shared/utilities/asyncCollection' @@ -33,7 +32,7 @@ import { partialClone, inspect, } from '../../../shared/utilities/collectionUtils' - +import * as CloudWatchLogs from '@aws-sdk/client-cloudwatch-logs' import { asyncGenerator } from '../../../shared/utilities/collectionUtils' describe('CollectionUtils', async function () { @@ -370,7 +369,7 @@ describe('CollectionUtils', async function () { [CloudWatchLogs.DescribeLogStreamsRequest], CloudWatchLogs.DescribeLogStreamsResponse >() - const responses: CloudWatchLogs.LogStreams[] = [ + const responses: CloudWatchLogs.LogStream[][] = [ [{ logStreamName: 'stream1' }, { logStreamName: 'stream2' }, { logStreamName: 'stream3' }], [{ logStreamName: 'stream4' }, { logStreamName: 'stream5' }, { logStreamName: 'stream6' }], [{ logStreamName: 'stream7' }, { logStreamName: 'stream8' }, { logStreamName: 'stream9' }],