Skip to content

Instantly share code, notes, and snippets.

@brachi-wernick
Last active March 8, 2018 13:33
Show Gist options
  • Save brachi-wernick/6134fe4de96982562a312a721f571bd4 to your computer and use it in GitHub Desktop.
Save brachi-wernick/6134fe4de96982562a312a721f571bd4 to your computer and use it in GitHub Desktop.
AddAwsGatewayResource
//find the root resource
List<Resource> resources = gateway
.getResources(new GetResourcesRequest().withRestApiId(targetRestApi.getId())).getItems();
Resource rootResource = resources.stream().filter(resource -> resource.getPath().equals(File.separator)).findFirst().orElseThrow(RuntimeException::new);
// add our resource with a path and save its id
String resourceId=gateway.createResource(new CreateResourceRequest().withParentId(rootResourceId).withRestApiId(targetRestApiId)
.withPathPart(pathPart)).getId();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment