Skip to content

Commit

Permalink
Add cloudformation support for UserContext (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaan-berry authored Nov 17, 2020
1 parent ccf9293 commit 139c193
Show file tree
Hide file tree
Showing 12 changed files with 348 additions and 8 deletions.
9 changes: 9 additions & 0 deletions aws-kendra-datasource/aws-kendra-datasource.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@
"$ref": "#/definitions/DataSourceToIndexFieldMapping"
}
},
"DisableLocalGroups": {
"type": "boolean"
},
"SharePointConfiguration": {
"description": "SharePoint configuration",
"type": "object",
Expand Down Expand Up @@ -239,6 +242,9 @@
},
"DocumentTitleFieldName": {
"$ref": "#/definitions/DataSourceFieldName"
},
"DisableLocalGroups": {
"$ref": "#/definitions/DisableLocalGroups"
}
},
"required": [
Expand Down Expand Up @@ -632,6 +638,9 @@
},
"FieldMappings": {
"$ref": "#/definitions/DataSourceToIndexFieldMappingList"
},
"DisableLocalGroups": {
"$ref": "#/definitions/DisableLocalGroups"
}
},
"required": [
Expand Down
2 changes: 1 addition & 1 deletion aws-kendra-datasource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>kendra</artifactId>
<version>2.15.22</version>
<version>2.15.23</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.cloudformation/aws-cloudformation-rpdk-java-plugin -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static software.amazon.awssdk.services.kendra.model.OneDriveConfiguration
.exclusionPatterns(StringListConverter.toSdk(model.getExclusionPatterns()))
.fieldMappings(ListConverter.toSdk(model.getFieldMappings(), FieldMappingConverter::toSdk))
.oneDriveUsers(toSdk(model.getOneDriveUsers()))
.disableLocalGroups(model.getDisableLocalGroups())
.build();
}

Expand Down Expand Up @@ -60,6 +61,7 @@ public static OneDriveConfiguration toModel(software.amazon.awssdk.services.kend
.inclusionPatterns(StringListConverter.toModel(sdk.inclusionPatterns()))
.exclusionPatterns(StringListConverter.toModel(sdk.exclusionPatterns()))
.oneDriveUsers(toModel(sdk.oneDriveUsers()))
.disableLocalGroups(sdk.disableLocalGroups())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static software.amazon.awssdk.services.kendra.model.SharePointConfigurati
.vpcConfiguration(sdkVpcConfiguration(model.getVpcConfiguration()))
.fieldMappings(ListConverter.toSdk(model.getFieldMappings(), FieldMappingConverter::toSdk))
.documentTitleFieldName(model.getDocumentTitleFieldName())
.disableLocalGroups(model.getDisableLocalGroups())
.build();
}

Expand All @@ -46,6 +47,7 @@ private static SharePointConfiguration toModel(software.amazon.awssdk.services.k
.vpcConfiguration(modelVpcConfiguration(sdk.vpcConfiguration()))
.fieldMappings(ListConverter.toModel(sdk.fieldMappings(), FieldMappingConverter::toModel))
.documentTitleFieldName(sdk.documentTitleFieldName())
.disableLocalGroups(sdk.disableLocalGroups())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void testToSdkTopLevelFields() {
.secretArn(secretArn)
.inclusionPatterns(includes)
.exclusionPatterns(excludes)
.disableLocalGroups(true)
.build();

software.amazon.awssdk.services.kendra.model.OneDriveConfiguration sdk =
Expand All @@ -32,6 +33,7 @@ void testToSdkTopLevelFields() {
.tenantDomain(tenantDomain)
.inclusionPatterns(includes)
.exclusionPatterns(excludes)
.disableLocalGroups(true)
.build();

assertThat(OneDriveConverter.toSdkDataSourceConfiguration(model)).isEqualTo(sdk);
Expand Down Expand Up @@ -85,6 +87,7 @@ void testToModelTopLevelFields() {
.secretArn(secretArn)
.inclusionPatterns(includes)
.exclusionPatterns(excludes)
.disableLocalGroups(false)
.build();

software.amazon.awssdk.services.kendra.model.OneDriveConfiguration sdk =
Expand All @@ -93,6 +96,7 @@ void testToModelTopLevelFields() {
.tenantDomain(tenantDomain)
.inclusionPatterns(includes)
.exclusionPatterns(excludes)
.disableLocalGroups(false)
.build();

assertThat(OneDriveConverter.toModel(sdk)).isEqualTo(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class SharePointCoverterTest {
public class SharePointConverterTest {

@Test
public void testSdkDataSourceConfiguration() {
Expand All @@ -28,6 +28,7 @@ public void testSdkDataSourceConfiguration() {
.securityGroupIds(Arrays.asList("testSecurityGroupId"))
.subnetIds(Arrays.asList("testSubnetId"))
.build())
.disableLocalGroups(true)
.fieldMappings(Arrays.asList(DataSourceToIndexFieldMapping.builder()
.dataSourceFieldName("testDataSourceFieldName")
.dateFieldFormat("testDateFieldFormat")
Expand Down Expand Up @@ -56,6 +57,7 @@ public void testSdkDataSourceConfiguration() {
.indexFieldName("testIndexFieldName")
.build()))
.documentTitleFieldName("testDocumentTitleFieldName")
.disableLocalGroups(true)
.build();

assertThat(SharePointConverter.toSdkDataSourceConfiguration(dataSourceConfiguration.getSharePointConfiguration()))
Expand All @@ -71,6 +73,7 @@ public void testSdkDataSourceConfiguration_withNullVpcConfigurationAndNullFieldM
.secretArn("secretArn")
.crawlAttachments(true)
.useChangeLog(true)
.disableLocalGroups(false)
.inclusionPatterns(Arrays.asList("testInclusionPatterns"))
.exclusionPatterns(Arrays.asList("testExclusionPatterns"))
.documentTitleFieldName("testDocumentTitleFieldName")
Expand All @@ -84,6 +87,7 @@ public void testSdkDataSourceConfiguration_withNullVpcConfigurationAndNullFieldM
.secretArn("secretArn")
.crawlAttachments(true)
.useChangeLog(true)
.disableLocalGroups(false)
.inclusionPatterns(Arrays.asList("testInclusionPatterns"))
.exclusionPatterns(Arrays.asList("testExclusionPatterns"))
.documentTitleFieldName("testDocumentTitleFieldName")
Expand All @@ -103,6 +107,7 @@ public void testModelDataSourceConfiguration() {
.secretArn("secretArn")
.crawlAttachments(true)
.useChangeLog(true)
.disableLocalGroups(true)
.inclusionPatterns(Arrays.asList("testInclusionPatterns"))
.exclusionPatterns(Arrays.asList("testExclusionPatterns"))
.vpcConfiguration( software.amazon.awssdk.services.kendra.model.DataSourceVpcConfiguration.builder()
Expand All @@ -125,6 +130,7 @@ public void testModelDataSourceConfiguration() {
.secretArn("secretArn")
.crawlAttachments(true)
.useChangeLog(true)
.disableLocalGroups(true)
.inclusionPatterns(Arrays.asList("testInclusionPatterns"))
.exclusionPatterns(Arrays.asList("testExclusionPatterns"))
.vpcConfiguration( DataSourceVpcConfiguration.builder()
Expand Down
108 changes: 108 additions & 0 deletions aws-kendra-index/aws-kendra-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,108 @@
"Arn": {
"type": "string",
"maxLength": 1000
},
"UserContextPolicy": {
"type": "string",
"enum": [
"ATTRIBUTE_FILTER",
"USER_TOKEN"
]
},
"UserNameAttributeField": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"GroupAttributeField": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"KeyLocation": {
"type": "string",
"enum": [
"URL",
"SECRET_MANAGER"
]
},
"Issuer": {
"type": "string",
"minLength": 1,
"maxLength": 65
},
"ClaimRegex": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"Url": {
"type": "string",
"minLength": 1,
"maxLength": 2048,
"pattern": "^(https?|ftp|file):\\/\\/([^\\s]*)"
},
"JsonTokenTypeConfiguration": {
"type": "object",
"properties": {
"UserNameAttributeField": {
"$ref": "#/definitions/UserNameAttributeField"
},
"GroupAttributeField": {
"$ref": "#/definitions/GroupAttributeField"
}
},
"required": [
"UserNameAttributeField",
"GroupAttributeField"
]
},
"JwtTokenTypeConfiguration": {
"type": "object",
"properties": {
"KeyLocation": {
"$ref": "#/definitions/KeyLocation"
},
"URL": {
"$ref": "#/definitions/Url"
},
"SecretManagerArn": {
"$ref": "#/definitions/RoleArn"
},
"UserNameAttributeField": {
"$ref": "#/definitions/UserNameAttributeField"
},
"GroupAttributeField": {
"$ref": "#/definitions/GroupAttributeField"
},
"Issuer": {
"$ref": "#/definitions/Issuer"
},
"ClaimRegex": {
"$ref": "#/definitions/ClaimRegex"
}
},
"required": [
"KeyLocation"
]
},
"UserTokenConfiguration": {
"type": "object",
"properties": {
"JwtTokenTypeConfiguration": {
"$ref": "#/definitions/JwtTokenTypeConfiguration"
},
"JsonTokenTypeConfiguration": {
"$ref": "#/definitions/JsonTokenTypeConfiguration"
}
}
},
"UserTokenConfigurationList": {
"type": "array",
"maxItems": 1,
"items": {
"$ref": "#/definitions/UserTokenConfiguration"
}
}
},
"properties": {
Expand Down Expand Up @@ -263,6 +365,12 @@
"CapacityUnits": {
"description": "Capacity units",
"$ref": "#/definitions/CapacityUnitsConfiguration"
},
"UserContextPolicy": {
"$ref": "#/definitions/UserContextPolicy"
},
"UserTokenConfigurations": {
"$ref": "#/definitions/UserTokenConfigurationList"
}
},
"required": [
Expand Down
2 changes: 1 addition & 1 deletion aws-kendra-index/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>kendra</artifactId>
<version>2.13.63</version>
<version>2.15.23</version>
</dependency>
<!-- https://mvnrepository.com/artifact/software.amazon.cloudformation/aws-cloudformation-rpdk-java-plugin -->
<dependency>
Expand Down
Loading

0 comments on commit 139c193

Please sign in to comment.