Skip to content

Commit

Permalink
feat: bump to CDK 2.139, fix property "set/get" prefix handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudshiftchris committed Apr 26, 2024
1 parent 9a242bc commit 1026d36
Show file tree
Hide file tree
Showing 531 changed files with 73,827 additions and 6,787 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.squareup.kotlinpoet.ParameterSpec
import com.squareup.kotlinpoet.ParameterizedTypeName
import com.squareup.kotlinpoet.TypeName
import com.squareup.kotlinpoet.UNIT
import net.pearx.kasechange.toCamelCase

internal class MethodGenerator(
model: CdkModel,
Expand Down Expand Up @@ -115,9 +114,13 @@ internal data class MethodSpec(
) {

val name: String
get() = when (cdkName) {
"set", "get" -> cdkName
else -> cdkName.removePrefix("set").removePrefix("get").toCamelCase()
get() = when {
cdkName.length < 4 -> cdkName
(cdkName.startsWith("get") || cdkName.startsWith("set")) && cdkName[3].isUpperCase() -> cdkName.removePrefix(
"set",
).removePrefix("get").replaceFirstChar(Char::lowercaseChar)

else -> cdkName
}

data class Parameter(
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = io.cloudshiftdev.kotlin-cdk-wrapper
version = 0.7.10
version = 0.8.0

kotlin.code.style=official

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version = "3.1.8
aspectj-tools = { module = "org.aspectj:aspectjtools", version = "1.9.21.2" }

guava = { module = "com.google.guava:guava", version = "32.1.3-jre" }
awscdk = { module = "software.amazon.awscdk:aws-cdk-lib", version = "2.134.0" }
awscdk = { module = "software.amazon.awscdk:aws-cdk-lib", version = "2.139.0" }
awscdk-constructs = { module = "software.constructs:constructs", version = "10.3.0" }
squareup-kotlinpoet = { module = "com.squareup:kotlinpoet", version = "1.16.0" }
javaparser-core = { module = "com.github.javaparser:javaparser-core", version = "3.25.9" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public open class CfnJson(
* This is required in case someone JSON.stringifys an object which references this object.
* Otherwise, we'll get a cyclic JSON reference.
*/
public open fun toJson(): String = unwrap(this).toJSON()
public open fun toJSON(): String = unwrap(this).toJSON()

/**
* An Fn::GetAtt to the JSON object passed through `value` and resolved during synthesis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import software.constructs.Construct as SoftwareConstructsConstruct
* [SetTypeConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_SetTypeConfiguration.html)
* to specify configuration properties for the extension. For more information, see [Configuring
* extensions at the account
* level](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry-register.html#registry-set-configuration)
* level](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry-private.html#registry-set-configuration)
* in the *CloudFormation User Guide* .
*
* Example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public open class DockerImage(
*
* @return The overridden image name if set or image hash name in that order
*/
public open fun toJson(): String = unwrap(this).toJSON()
public open fun toJSON(): String = unwrap(this).toJSON()

public companion object {
public fun fromBuild(path: String): DockerImage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public open class Intrinsic(
*
* Called automatically when JSON.stringify() is called on a Token.
*/
public open fun toJson(): Any = unwrap(this).toJSON()
public open fun toJSON(): Any = unwrap(this).toJSON()

/**
* Convert an instance of this Token to a string list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public open class JsonNull(
/**
* Obtains the JSON representation of this object (`null`).
*/
public open fun toJson(): Any = unwrap(this).toJSON()
public open fun toJSON(): Any = unwrap(this).toJSON()

public companion object {
public val INSTANCE: JsonNull = JsonNull.wrap(software.amazon.awscdk.JsonNull.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ import kotlin.String
* // "MyBar": {
* // "Type": "Foo::Bar",
* // "Properties": {
* // "Fred": ["Flob", "Cat"]
* // "Fred": {
* // "Wobble": ["Flob", "Flib"],
* // }
* // }
* // }
* // }
* // }
* // The following will NOT throw an assertion error
* template.hasResourceProperties("Foo::Bar", Map.of(
* "Fred", Match.arrayWith(List.of("Flob"))));
* "Fred", Map.of(
* "Wobble", List.of(Match.anyValue(), Match.anyValue()))));
* // The following will throw an assertion error
* template.hasResourceProperties("Foo::Bar", Match.objectLike(Map.of(
* "Fred", Match.arrayWith(List.of("Wobble")))));
* template.hasResourceProperties("Foo::Bar", Map.of(
* "Fred", Map.of(
* "Wimble", Match.anyValue())));
* ```
*/
public abstract class Matcher(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")

package io.cloudshiftdev.awscdk.assertions

import io.cloudshiftdev.awscdk.Stack
import io.cloudshiftdev.awscdk.common.CdkObject
import kotlin.Any
import kotlin.String
import kotlin.collections.Map

/**
* Allows assertions on the tags associated with a synthesized CDK stack's manifest.
*
* Stack tags are not part of the synthesized template, so can only be
* checked from the manifest in this manner.
*
* Example:
*
* ```
* Tags tags = Tags.fromStack(stack);
* // using a default 'objectLike' Matcher
* tags.hasValues(Map.of(
* "tag-name", "tag-value"));
* // ... with Matchers embedded
* tags.hasValues(Map.of(
* "tag-name", Match.stringLikeRegexp("value")));
* // or another object Matcher at the top level
* tags.hasValues(Match.objectEquals(Map.of(
* "tag-name", Match.anyValue())));
* ```
*/
public open class Tags(
cdkObject: software.amazon.awscdk.assertions.Tags,
) : CdkObject(cdkObject) {
/**
* Get the tags associated with the manifest.
*
* This will be an empty object if
* no tags were supplied.
*
* @return The tags associated with the stack's synthesized manifest.
*/
public open fun all(): Map<String, String> = unwrap(this).all() ?: emptyMap()

/**
* Assert that the there are no tags associated with the synthesized CDK Stack's manifest.
*
* This is a convenience method over `hasValues(Match.exact({}))`, and is
* present because the more obvious method of detecting no tags
* (`Match.absent()`) will not work. Manifests default the tag set to an empty
* object.
*/
public open fun hasNone() {
unwrap(this).hasNone()
}

/**
* Assert that the given Matcher or object matches the tags associated with the synthesized CDK
* Stack's manifest.
*
* @param tags the expected set of tags.
*/
public open fun hasValues(tags: Any) {
unwrap(this).hasValues(tags)
}

public companion object {
public fun fromStack(stack: Stack): Tags =
software.amazon.awscdk.assertions.Tags.fromStack(stack.let(Stack::unwrap)).let(Tags::wrap)

internal fun wrap(cdkObject: software.amazon.awscdk.assertions.Tags): Tags = Tags(cdkObject)

internal fun unwrap(wrapped: Tags): software.amazon.awscdk.assertions.Tags = wrapped.cdkObject
as software.amazon.awscdk.assertions.Tags
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,22 +275,22 @@ public open class Template(
/**
* The CloudFormation template deserialized into an object.
*/
public open fun toJson(): Map<String, Any> = unwrap(this).toJSON() ?: emptyMap()
public open fun toJSON(): Map<String, Any> = unwrap(this).toJSON() ?: emptyMap()

public companion object {
public fun fromJson(template: Map<String, Any>): Template =
public fun fromJSON(template: Map<String, Any>): Template =
software.amazon.awscdk.assertions.Template.fromJSON(template.mapValues{CdkObjectWrappers.unwrap(it.value)}).let(Template::wrap)

public fun fromJson(template: Map<String, Any>, templateParsingOptions: TemplateParsingOptions):
public fun fromJSON(template: Map<String, Any>, templateParsingOptions: TemplateParsingOptions):
Template =
software.amazon.awscdk.assertions.Template.fromJSON(template.mapValues{CdkObjectWrappers.unwrap(it.value)},
templateParsingOptions.let(TemplateParsingOptions::unwrap)).let(Template::wrap)

@kotlin.Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("d131d7b560d1035ceeff84d745856250480d5b0c05095dfd8ded5d13b0f88a8b")
public fun fromJson(template: Map<String, Any>,
@JvmName("cbffcbc7046e55838a1d5fb9e7a97ebb37d7a2374f5094e37c1eb7be3ab5e424")
public fun fromJSON(template: Map<String, Any>,
templateParsingOptions: TemplateParsingOptions.Builder.() -> Unit): Template =
fromJson(template, TemplateParsingOptions(templateParsingOptions))
fromJSON(template, TemplateParsingOptions(templateParsingOptions))

public fun fromStack(stack: Stack): Template =
software.amazon.awscdk.assertions.Template.fromStack(stack.let(Stack::unwrap)).let(Template::wrap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

package io.cloudshiftdev.awscdk.aws_apigatewayv2_integrations

import io.cloudshiftdev.awscdk.Duration
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.services.apigatewayv2.ContentHandling
import io.cloudshiftdev.awscdk.services.apigatewayv2.PassthroughBehavior
import io.cloudshiftdev.awscdk.services.apigatewayv2.WebSocketRouteIntegration
import io.cloudshiftdev.awscdk.services.apigatewayv2.WebSocketRouteIntegrationBindOptions
Expand Down Expand Up @@ -82,6 +84,16 @@ public open class WebSocketAwsIntegration(
*/
@CdkDslMarker
public interface Builder {
/**
* Specifies how to handle response payload content type conversions.
*
* Default: - The response payload will be passed through from the integration response to
* the route response or method response without modification.
*
* @param contentHandling Specifies how to handle response payload content type conversions.
*/
public fun contentHandling(contentHandling: ContentHandling)

/**
* Specifies the credentials role required for the integration.
*
Expand Down Expand Up @@ -156,6 +168,18 @@ public open class WebSocketAwsIntegration(
* @param templateSelectionExpression The template selection expression for the integration.
*/
public fun templateSelectionExpression(templateSelectionExpression: String)

/**
* The maximum amount of time an integration will run before it returns without a response.
*
* Must be between 50 milliseconds and 29 seconds.
*
* Default: Duration.seconds(29)
*
* @param timeout The maximum amount of time an integration will run before it returns without a
* response.
*/
public fun timeout(timeout: Duration)
}

private class BuilderImpl(
Expand All @@ -165,6 +189,18 @@ public open class WebSocketAwsIntegration(
software.amazon.awscdk.aws_apigatewayv2_integrations.WebSocketAwsIntegration.Builder =
software.amazon.awscdk.aws_apigatewayv2_integrations.WebSocketAwsIntegration.Builder.create(id)

/**
* Specifies how to handle response payload content type conversions.
*
* Default: - The response payload will be passed through from the integration response to
* the route response or method response without modification.
*
* @param contentHandling Specifies how to handle response payload content type conversions.
*/
override fun contentHandling(contentHandling: ContentHandling) {
cdkBuilder.contentHandling(contentHandling.let(ContentHandling::unwrap))
}

/**
* Specifies the credentials role required for the integration.
*
Expand Down Expand Up @@ -254,6 +290,20 @@ public open class WebSocketAwsIntegration(
cdkBuilder.templateSelectionExpression(templateSelectionExpression)
}

/**
* The maximum amount of time an integration will run before it returns without a response.
*
* Must be between 50 milliseconds and 29 seconds.
*
* Default: Duration.seconds(29)
*
* @param timeout The maximum amount of time an integration will run before it returns without a
* response.
*/
override fun timeout(timeout: Duration) {
cdkBuilder.timeout(timeout.let(Duration::unwrap))
}

public fun build(): software.amazon.awscdk.aws_apigatewayv2_integrations.WebSocketAwsIntegration
= cdkBuilder.build()
}
Expand Down
Loading

0 comments on commit 1026d36

Please sign in to comment.