Skip to content

Commit 95ae70a

Browse files
committed
#261 - Added Locale APIs
1 parent 955c058 commit 95ae70a

22 files changed

+2114
-305
lines changed

aws-dynamodb/src/main/java/com/formkiq/aws/dynamodb/PaginationResults.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.util.Map;
2828

2929
/**
30-
* Pagination Results for a DynamoDB Query.
30+
* Pagination Results for a DynamoDB Query. Use Pagination class INSTEAD!
3131
*
3232
* @param <T> Type of Results.
3333
*/

docs/openapi/openapi-iam.yaml

+21-49
Original file line numberDiff line numberDiff line change
@@ -10138,10 +10138,27 @@
1013810138
- $ref: '#/components/schemas/AddLocaleResourceSchemaItem'
1013910139
- $ref: '#/components/schemas/AddLocaleResourceClassificationItem'
1014010140
ResourceItem:
10141-
oneOf:
10142-
- $ref: '#/components/schemas/LocaleResourceInterfaceItem'
10143-
- $ref: '#/components/schemas/LocaleResourceSchemaItem'
10144-
- $ref: '#/components/schemas/LocaleResourceClassificationItem'
10141+
properties:
10142+
itemType:
10143+
$ref: '#/components/schemas/LocaleResourceType'
10144+
localizedValue:
10145+
type: string
10146+
description: Localized Value
10147+
interfaceKey:
10148+
type: string
10149+
description: Interface Key
10150+
itemKey:
10151+
type: string
10152+
description: Item Key
10153+
attributeKey:
10154+
type: string
10155+
description: Attribute Key
10156+
allowedValue:
10157+
type: string
10158+
description: Resource value
10159+
classificationId:
10160+
type: string
10161+
description: Classification Id
1014510162
LocaleResourceType:
1014610163
type: string
1014710164
description: Type of Locale Resource
@@ -10195,51 +10212,6 @@
1019510212
allowedValue:
1019610213
type: string
1019710214
description: Resource value
10198-
LocaleResourceInterfaceItem:
10199-
type: object
10200-
properties:
10201-
itemType:
10202-
$ref: '#/components/schemas/LocaleResourceType'
10203-
localizedValue:
10204-
type: string
10205-
description: Localized Value
10206-
interfaceKey:
10207-
type: string
10208-
description: Interface Key
10209-
itemKey:
10210-
type: string
10211-
description: Item Key
10212-
LocaleResourceSchemaItem:
10213-
type: object
10214-
properties:
10215-
itemType:
10216-
$ref: '#/components/schemas/LocaleResourceType'
10217-
attributeKey:
10218-
type: string
10219-
description: Attribute Key
10220-
allowedValue:
10221-
type: string
10222-
description: Resource value
10223-
itemKey:
10224-
type: string
10225-
description: Item Key
10226-
LocaleResourceClassificationItem:
10227-
type: object
10228-
properties:
10229-
itemType:
10230-
$ref: '#/components/schemas/LocaleResourceType'
10231-
classificationId:
10232-
type: string
10233-
description: Classification Id
10234-
attributeKey:
10235-
type: string
10236-
description: Attribute Key
10237-
allowedValue:
10238-
type: string
10239-
description: Resource value
10240-
itemKey:
10241-
type: string
10242-
description: Item Key
1024310215
AddLocaleResourceItemResponse:
1024410216
type: object
1024510217
properties:

docs/openapi/openapi-jwt.yaml

+21-49
Original file line numberDiff line numberDiff line change
@@ -10138,10 +10138,27 @@
1013810138
- $ref: '#/components/schemas/AddLocaleResourceSchemaItem'
1013910139
- $ref: '#/components/schemas/AddLocaleResourceClassificationItem'
1014010140
ResourceItem:
10141-
oneOf:
10142-
- $ref: '#/components/schemas/LocaleResourceInterfaceItem'
10143-
- $ref: '#/components/schemas/LocaleResourceSchemaItem'
10144-
- $ref: '#/components/schemas/LocaleResourceClassificationItem'
10141+
properties:
10142+
itemType:
10143+
$ref: '#/components/schemas/LocaleResourceType'
10144+
localizedValue:
10145+
type: string
10146+
description: Localized Value
10147+
interfaceKey:
10148+
type: string
10149+
description: Interface Key
10150+
itemKey:
10151+
type: string
10152+
description: Item Key
10153+
attributeKey:
10154+
type: string
10155+
description: Attribute Key
10156+
allowedValue:
10157+
type: string
10158+
description: Resource value
10159+
classificationId:
10160+
type: string
10161+
description: Classification Id
1014510162
LocaleResourceType:
1014610163
type: string
1014710164
description: Type of Locale Resource
@@ -10195,51 +10212,6 @@
1019510212
allowedValue:
1019610213
type: string
1019710214
description: Resource value
10198-
LocaleResourceInterfaceItem:
10199-
type: object
10200-
properties:
10201-
itemType:
10202-
$ref: '#/components/schemas/LocaleResourceType'
10203-
localizedValue:
10204-
type: string
10205-
description: Localized Value
10206-
interfaceKey:
10207-
type: string
10208-
description: Interface Key
10209-
itemKey:
10210-
type: string
10211-
description: Item Key
10212-
LocaleResourceSchemaItem:
10213-
type: object
10214-
properties:
10215-
itemType:
10216-
$ref: '#/components/schemas/LocaleResourceType'
10217-
attributeKey:
10218-
type: string
10219-
description: Attribute Key
10220-
allowedValue:
10221-
type: string
10222-
description: Resource value
10223-
itemKey:
10224-
type: string
10225-
description: Item Key
10226-
LocaleResourceClassificationItem:
10227-
type: object
10228-
properties:
10229-
itemType:
10230-
$ref: '#/components/schemas/LocaleResourceType'
10231-
classificationId:
10232-
type: string
10233-
description: Classification Id
10234-
attributeKey:
10235-
type: string
10236-
description: Attribute Key
10237-
allowedValue:
10238-
type: string
10239-
description: Resource value
10240-
itemKey:
10241-
type: string
10242-
description: Item Key
1024310215
AddLocaleResourceItemResponse:
1024410216
type: object
1024510217
properties:

docs/openapi/openapi-key.yaml

+21-49
Original file line numberDiff line numberDiff line change
@@ -10138,10 +10138,27 @@
1013810138
- $ref: '#/components/schemas/AddLocaleResourceSchemaItem'
1013910139
- $ref: '#/components/schemas/AddLocaleResourceClassificationItem'
1014010140
ResourceItem:
10141-
oneOf:
10142-
- $ref: '#/components/schemas/LocaleResourceInterfaceItem'
10143-
- $ref: '#/components/schemas/LocaleResourceSchemaItem'
10144-
- $ref: '#/components/schemas/LocaleResourceClassificationItem'
10141+
properties:
10142+
itemType:
10143+
$ref: '#/components/schemas/LocaleResourceType'
10144+
localizedValue:
10145+
type: string
10146+
description: Localized Value
10147+
interfaceKey:
10148+
type: string
10149+
description: Interface Key
10150+
itemKey:
10151+
type: string
10152+
description: Item Key
10153+
attributeKey:
10154+
type: string
10155+
description: Attribute Key
10156+
allowedValue:
10157+
type: string
10158+
description: Resource value
10159+
classificationId:
10160+
type: string
10161+
description: Classification Id
1014510162
LocaleResourceType:
1014610163
type: string
1014710164
description: Type of Locale Resource
@@ -10195,51 +10212,6 @@
1019510212
allowedValue:
1019610213
type: string
1019710214
description: Resource value
10198-
LocaleResourceInterfaceItem:
10199-
type: object
10200-
properties:
10201-
itemType:
10202-
$ref: '#/components/schemas/LocaleResourceType'
10203-
localizedValue:
10204-
type: string
10205-
description: Localized Value
10206-
interfaceKey:
10207-
type: string
10208-
description: Interface Key
10209-
itemKey:
10210-
type: string
10211-
description: Item Key
10212-
LocaleResourceSchemaItem:
10213-
type: object
10214-
properties:
10215-
itemType:
10216-
$ref: '#/components/schemas/LocaleResourceType'
10217-
attributeKey:
10218-
type: string
10219-
description: Attribute Key
10220-
allowedValue:
10221-
type: string
10222-
description: Resource value
10223-
itemKey:
10224-
type: string
10225-
description: Item Key
10226-
LocaleResourceClassificationItem:
10227-
type: object
10228-
properties:
10229-
itemType:
10230-
$ref: '#/components/schemas/LocaleResourceType'
10231-
classificationId:
10232-
type: string
10233-
description: Classification Id
10234-
attributeKey:
10235-
type: string
10236-
description: Attribute Key
10237-
allowedValue:
10238-
type: string
10239-
description: Resource value
10240-
itemKey:
10241-
type: string
10242-
description: Item Key
1024310215
AddLocaleResourceItemResponse:
1024410216
type: object
1024510217
properties:

dynamodb-documents/src/main/java/com/formkiq/stacks/dynamodb/ApiKeysServiceDynamoDb.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@
3535
import com.formkiq.aws.dynamodb.DynamoDbConnectionBuilder;
3636
import com.formkiq.aws.dynamodb.DynamoDbService;
3737
import com.formkiq.aws.dynamodb.DynamoDbServiceImpl;
38-
import com.formkiq.aws.dynamodb.MapToAttributeValue;
3938
import com.formkiq.aws.dynamodb.QueryConfig;
40-
import com.formkiq.stacks.dynamodb.base64.Base64ToMap;
4139
import com.formkiq.stacks.dynamodb.base64.Pagination;
40+
import com.formkiq.stacks.dynamodb.base64.StringToMapAttributeValue;
4241
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
4342
import software.amazon.awssdk.services.dynamodb.model.QueryResponse;
4443

@@ -148,8 +147,7 @@ public Pagination<ApiKey> list(final String siteId, final String nextToken, fina
148147
AttributeValue pk = fromS(apiKey.pkGsi1(siteId));
149148
AttributeValue sk = fromS("apikey" + TAG_DELIMINATOR);
150149

151-
Map<String, AttributeValue> startKey =
152-
new MapToAttributeValue().apply(new Base64ToMap().apply(nextToken));
150+
Map<String, AttributeValue> startKey = new StringToMapAttributeValue().apply(nextToken);
153151
QueryResponse response = this.db.queryBeginsWith(config, pk, sk, startKey, limit);
154152

155153
List<Map<String, AttributeValue>> attrs = response.items().stream()

dynamodb-documents/src/main/java/com/formkiq/stacks/dynamodb/WebhooksServiceImpl.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@
4040
import com.formkiq.aws.dynamodb.DynamoDbService;
4141
import com.formkiq.aws.dynamodb.DynamoDbServiceImpl;
4242
import com.formkiq.aws.dynamodb.ID;
43-
import com.formkiq.aws.dynamodb.MapToAttributeValue;
4443
import com.formkiq.aws.dynamodb.PaginationMapToken;
4544
import com.formkiq.aws.dynamodb.PaginationResults;
4645
import com.formkiq.aws.dynamodb.PaginationToAttributeValue;
4746
import com.formkiq.aws.dynamodb.QueryResponseToPagination;
4847
import com.formkiq.aws.dynamodb.model.DocumentTag;
4948
import com.formkiq.aws.dynamodb.objects.DateUtil;
50-
import com.formkiq.stacks.dynamodb.base64.Base64ToMap;
5149
import com.formkiq.stacks.dynamodb.base64.Pagination;
50+
import com.formkiq.stacks.dynamodb.base64.StringToMapAttributeValue;
5251
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
5352
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
5453
import software.amazon.awssdk.services.dynamodb.model.AttributeValueUpdate;
@@ -226,8 +225,7 @@ public Pagination<DynamicObject> findWebhooks(final String siteId, final String
226225

227226
String expr = GSI1_PK + " = :pk";
228227

229-
Map<String, AttributeValue> startKey =
230-
new MapToAttributeValue().apply(new Base64ToMap().apply(nextToken));
228+
Map<String, AttributeValue> startKey = new StringToMapAttributeValue().apply(nextToken);
231229
QueryRequest q = QueryRequest.builder().tableName(this.documentTableName).indexName(GSI1)
232230
.keyConditionExpression(expr).expressionAttributeValues(key).exclusiveStartKey(startKey)
233231
.limit(limit).build();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* MIT License
3+
*
4+
* Copyright (c) 2018 - 2020 FormKiQ
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.formkiq.stacks.dynamodb.base64;
25+
26+
import com.formkiq.aws.dynamodb.MapToAttributeValue;
27+
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
28+
29+
import java.util.Map;
30+
import java.util.function.Function;
31+
32+
/**
33+
* {@link Function} to convert Pagination {@link String} next token to a DynamoDb StartKey.
34+
*/
35+
public class StringToMapAttributeValue implements Function<String, Map<String, AttributeValue>> {
36+
@Override
37+
public Map<String, AttributeValue> apply(final String nextToken) {
38+
return new MapToAttributeValue().apply(new Base64ToMap().apply(nextToken));
39+
}
40+
}

0 commit comments

Comments
 (0)