Skip to content

Commit

Permalink
feat: support TemplateConfigration
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterYukky committed Oct 31, 2023
1 parent b003bf0 commit 1b4f388
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion aws-kendra-datasource/aws-kendra-datasource.json
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@
"type": "object",
"properties": {
"Template": {
"type": "string"
"type": "object"
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package software.amazon.kendra.datasource.convert;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import software.amazon.awssdk.core.document.Document;
Expand All @@ -18,7 +22,7 @@ public static software.amazon.awssdk.services.kendra.model.TemplateConfiguration
return null;
}
return software.amazon.awssdk.services.kendra.model.TemplateConfiguration.builder()
.template(builder.fromJson(model.getTemplate(), Document.class))
.template(builder.fromJson(builder.toJson(model.getTemplate()), Document.class))
.build();
}

Expand All @@ -29,12 +33,13 @@ public static DataSourceConfiguration toModelDataSourceConfiguration(
.build();
}

@SuppressWarnings("unchecked")
private static TemplateConfiguration toModel(software.amazon.awssdk.services.kendra.model.TemplateConfiguration sdk) {
if (sdk == null) {
return null;
}
return TemplateConfiguration.builder()
.template(builder.toJson(sdk.template(), Document.class))
.template(builder.fromJson(builder.toJson(sdk.template()), Map.class))
.build();
}
}

0 comments on commit 1b4f388

Please sign in to comment.