-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps(apigateway): migrate client to use v3. (#6760)
## Problem client still uses v2. ## Solution - Very straightforward migration, mostly exchanging types. ## Verification - Create a simple APIGateway that redirects to a GET request to this repo's homepage. - Use the invoke method from the IDE. - Copy ARN, name, and URL. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
1 parent
f4f9354
commit 2c0b4a5
Showing
8 changed files
with
633 additions
and
92 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*! | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { ClientWrapper } from './clientWrapper' | ||
import { | ||
APIGatewayClient as ApiGatewayClientSDK, | ||
GetResourcesCommand, | ||
GetResourcesRequest, | ||
GetRestApisCommand, | ||
GetRestApisRequest, | ||
GetStagesCommand, | ||
Resource, | ||
Resources, | ||
RestApi, | ||
RestApis, | ||
Stages, | ||
TestInvokeMethodCommand, | ||
TestInvokeMethodRequest, | ||
TestInvokeMethodResponse, | ||
} from '@aws-sdk/client-api-gateway' | ||
|
||
export class ApiGatewayClient extends ClientWrapper<ApiGatewayClientSDK> { | ||
public constructor(regionCode: string) { | ||
super(regionCode, ApiGatewayClientSDK) | ||
} | ||
|
||
public async *getResourcesForApi(apiId: string): AsyncIterableIterator<Resource> { | ||
const request: GetResourcesRequest = { | ||
restApiId: apiId, | ||
} | ||
|
||
do { | ||
const response: Resources = await this.makeRequest(GetResourcesCommand, request) | ||
|
||
if (response.items !== undefined && response.items.length > 0) { | ||
yield* response.items | ||
} | ||
|
||
request.position = response.position | ||
} while (request.position !== undefined) | ||
} | ||
|
||
public async getStages(apiId: string): Promise<Stages> { | ||
return this.makeRequest(GetStagesCommand, { | ||
restApiId: apiId, | ||
}) | ||
} | ||
|
||
public async *listApis(): AsyncIterableIterator<RestApi> { | ||
const request: GetRestApisRequest = {} | ||
|
||
do { | ||
const response: RestApis = await this.makeRequest(GetRestApisCommand, request) | ||
|
||
if (response.items !== undefined && response.items.length > 0) { | ||
yield* response.items | ||
} | ||
|
||
request.position = response.position | ||
} while (request.position !== undefined) | ||
} | ||
|
||
public async testInvokeMethod( | ||
apiId: string, | ||
resourceId: string, | ||
method: string, | ||
body: string, | ||
pathWithQueryString: string | undefined | ||
): Promise<TestInvokeMethodResponse> { | ||
const request: TestInvokeMethodRequest = { | ||
restApiId: apiId, | ||
resourceId: resourceId, | ||
httpMethod: method, | ||
body: body, | ||
} | ||
if (pathWithQueryString) { | ||
request.pathWithQueryString = pathWithQueryString | ||
} | ||
|
||
return this.makeRequest(TestInvokeMethodCommand, request) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters