Skip to content

Commit ca0abe7

Browse files
committed
refactored handler/test stubs
1 parent bcdc050 commit ca0abe7

11 files changed

+360
-336
lines changed

python/rpdk/java/templates/init/default/HandlerWrapper.java

Lines changed: 0 additions & 152 deletions
This file was deleted.

python/rpdk/java/templates/init/guided_aws/AbstractTestBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class AbstractTestBase {
2020
}
2121
static ProxyClient<SdkClient> MOCK_PROXY(
2222
final AmazonWebServicesClientProxy proxy,
23-
final ServiceSdkClient sdkClient) {
23+
final SdkClient sdkClient) {
2424
return new ProxyClient<SdkClient>() {
2525
@Override
2626
public <RequestT extends AwsRequest, ResponseT extends AwsResponse> ResponseT
@@ -36,7 +36,7 @@ static ProxyClient<SdkClient> MOCK_PROXY(
3636
}
3737

3838
@Override
39-
public ServiceSdkClient client() {
39+
public SdkClient client() {
4040
return sdkClient;
4141
}
4242
};

python/rpdk/java/templates/init/guided_aws/BaseHandlerStd.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package {{ package_name }};
22

3+
import software.amazon.awssdk.core.SdkClient;
34
import software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy;
45
import software.amazon.cloudformation.proxy.Logger;
56
import software.amazon.cloudformation.proxy.ProgressEvent;
@@ -29,7 +30,5 @@ protected abstract ProgressEvent<ResourceModel, CallbackContext> handleRequest(
2930
final ProxyClient<SdkClient> proxyClient,
3031
final Logger logger);
3132

32-
/*
33-
* Common or abstract methods and functions should be in this class
34-
* */
33+
// Placeholder for the functionality that could be shared across Create/Read/Update/Delete/List Handlers
3534
}
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
package {{ package_name }};
22

3+
import software.amazon.awssdk.core.SdkClient;
4+
35
public class ClientBuilder {
4-
// sample client builder - change ServiceSdkClient on the desired one
5-
public static ServiceSdkClient getClient() {
6-
return ServiceSdkClient.create();
6+
/*
7+
TODO: uncomment the following, replacing YourServiceAsyncClient with your service client name
8+
It is recommended to use static HTTP client so less memory is consumed
9+
e.g. https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs/blob/master/aws-logs-loggroup/src/main/java/software/amazon/logs/loggroup/ClientBuilder.java#L9
10+
11+
private static class LazyHolder {
12+
static final YourServiceAsyncClient SERVICE_CLIENT = YourServiceAsyncClient.builder()
13+
.httpClient(LambdaWrapper.HTTP_CLIENT)
14+
.build();
15+
}
16+
17+
public static YourServiceAsyncClient getClient() {
18+
return LazyHolder.SERVICE_CLIENT;
19+
}
20+
*/
21+
22+
// TODO: remove this implementation once you have uncommented the above
23+
public static SdkClient getClient() {
24+
return null;
725
}
826
}

0 commit comments

Comments
 (0)