Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates: Q app and fix for datasource configuration #56

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions aws-qbusiness-application/aws-qbusiness-application.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@
},
"additionalProperties": false
},
"QAppsConfiguration": {
"type": "object",
"properties": {
"QAppsControlMode": {
"$ref": "#/definitions/QAppsControlMode"
}
},
"required": [
"QAppsControlMode"
],
"additionalProperties": false
},
"QAppsControlMode": {
"type": "string",
"enum": [
"ENABLED",
"DISABLED"
]
},
"Tag": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -104,6 +123,9 @@
"minLength": 10,
"pattern": "^arn:(aws|aws-us-gov|aws-cn|aws-iso|aws-iso-b):sso::\\d{12}:application/(sso)?ins-[a-zA-Z0-9-.]{16}/apl-[a-zA-Z0-9]{16}$"
},
"QAppsConfiguration": {
"$ref": "#/definitions/QAppsConfiguration"
},
"IdentityCenterInstanceArn": {
"type": "string",
"maxLength": 1224,
Expand Down
2 changes: 1 addition & 1 deletion aws-qbusiness-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>qbusiness</artifactId>
<version>2.25.42</version>
<version>2.26.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.awssdk/aws-core -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import software.amazon.awssdk.services.qbusiness.model.TagResourceRequest;
import software.amazon.awssdk.services.qbusiness.model.UntagResourceRequest;
import software.amazon.awssdk.services.qbusiness.model.UpdateApplicationRequest;
import software.amazon.cloudformation.exceptions.CfnInvalidRequestException;
import software.amazon.cloudformation.proxy.ResourceHandlerRequest;

/**
Expand Down Expand Up @@ -45,6 +46,7 @@ static CreateApplicationRequest translateToCreateRequest(final String idempotent
.encryptionConfiguration(toServiceEncryptionConfig(model.getEncryptionConfiguration()))
.attachmentsConfiguration(toServiceAttachmentConfiguration(model.getAttachmentsConfiguration()))
.tags(TagHelper.serviceTagsFromCfnTags(model.getTags()))
.qAppsConfiguration(toServiceQAppsConfiguration(model.getQAppsConfiguration()))
.build();
}

Expand Down Expand Up @@ -87,6 +89,7 @@ static ResourceModel translateFromReadResponse(final GetApplicationResponse awsR
.updatedAt(instantToString(awsResponse.updatedAt()))
.encryptionConfiguration(fromServiceEncryptionConfig(awsResponse.encryptionConfiguration()))
.attachmentsConfiguration(fromServiceAttachmentConfiguration(awsResponse.attachmentsConfiguration()))
.qAppsConfiguration(fromServiceQAppsConfiguration(awsResponse.qAppsConfiguration()))
.build();
}

Expand Down Expand Up @@ -144,6 +147,30 @@ static software.amazon.awssdk.services.qbusiness.model.AttachmentsConfiguration
.build();
}

static QAppsConfiguration fromServiceQAppsConfiguration(
software.amazon.awssdk.services.qbusiness.model.QAppsConfiguration serviceConfig
) {
if (serviceConfig == null) {
return null;
}

return QAppsConfiguration.builder()
.qAppsControlMode(serviceConfig.qAppsControlModeAsString())
.build();
}

static software.amazon.awssdk.services.qbusiness.model.QAppsConfiguration toServiceQAppsConfiguration(
QAppsConfiguration modelConfig
) {
if (modelConfig == null) {
return null;
}

return software.amazon.awssdk.services.qbusiness.model.QAppsConfiguration.builder()
.qAppsControlMode(modelConfig.getQAppsControlMode())
.build();
}

static ResourceModel translateFromReadResponseWithTags(final ListTagsForResourceResponse listTagsResponse, final ResourceModel model) {
if (listTagsResponse == null || !listTagsResponse.hasTags()) {
return model;
Expand Down Expand Up @@ -180,6 +207,7 @@ static UpdateApplicationRequest translateToUpdateRequest(final ResourceModel mod
.roleArn(model.getRoleArn())
.identityCenterInstanceArn(model.getIdentityCenterInstanceArn())
.attachmentsConfiguration(toServiceAttachmentConfiguration(model.getAttachmentsConfiguration()))
.qAppsConfiguration(toServiceQAppsConfiguration(model.getQAppsConfiguration()))
.build();
}

Expand Down
2 changes: 1 addition & 1 deletion aws-qbusiness-datasource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>qbusiness</artifactId>
<version>2.25.42</version>
<version>2.26.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.awssdk/sdk-core -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ private static Document objectToDocument(Object value) {
if (value instanceof Boolean bool) {
return Document.fromBoolean(bool);
} else if (value instanceof String string) {
// Due to how yaml handles values, we'll receive boolean values as strings.
// Parse "true"/"false" as booleans to allow creating datasources like webcrawler: https://docs.aws.amazon.com/amazonq/latest/qbusiness-ug/web-crawler-api.html
if ("true".equals(string) || "false".equals(string)) {
var boolValue = Boolean.parseBoolean(string);
return Document.fromBoolean(boolValue);
}
return Document.fromString(string);
} else if (value instanceof Number) {
if (value instanceof Integer integer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public void setup() {
"Type", "WebcrawlerV2",
"Links", List.of("link1", "link2"),
"depth", 50,
"crawlEverything", "false",
"doTheThing", "true",
"overrides", Map.of(
"a", 10
)
Expand Down Expand Up @@ -184,6 +186,8 @@ proxy, testRequest, new CallbackContext(), proxyClient, logger
"Type", Document.fromString("WebcrawlerV2"),
"Links", Document.fromList(List.of(Document.fromString("link1"), Document.fromString("link2"))),
"depth", Document.fromNumber(50),
"crawlEverything", Document.fromBoolean(false),
"doTheThing", Document.fromBoolean(true),
"overrides", Document.fromMap(Map.of(
"a", Document.fromNumber(10)
))
Expand Down
2 changes: 1 addition & 1 deletion aws-qbusiness-index/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>qbusiness</artifactId>
<version>2.25.42</version>
<version>2.26.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.awssdk/sdk-core -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion aws-qbusiness-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>qbusiness</artifactId>
<version>2.25.42</version>
<version>2.26.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion aws-qbusiness-retriever/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>qbusiness</artifactId>
<version>2.25.42</version>
<version>2.26.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.awssdk/sdk-core -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion aws-qbusiness-webexperience/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>qbusiness</artifactId>
<version>2.25.42</version>
<version>2.26.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.awssdk/sdk-core -->
<dependency>
Expand Down