Commit 1466086a authored by neelesh thakur's avatar neelesh thakur
Browse files

update api spec and tutorial

parent 36f300d3
Pipeline #10792 failed with stages
in 2 minutes and 19 seconds
......@@ -84,7 +84,9 @@ paths:
'200':
description: OK
schema:
$ref: '#/definitions/PartitionInfo'
type: object
additionalProperties:
"$ref": "#/definitions/Property"
'401':
description: Unauthorized
'403':
......@@ -165,13 +167,26 @@ definitions:
PartitionInfo:
type: object
properties:
labels:
properties:
type: object
description: 'Free form key value pair object for any data partition specific values'
additionalProperties:
"$ref": "#/definitions/Property"
example:
id: 'common'
compliance-ruleset: 'shared'
elastic-username: 'elastic'
cosmos-endpoint: 'https://ado-dev-n-abc123-cosmosdb.documents.azure.com:443/'
elastic-endpoint: 'https://partition-dev.evd.ece-osdu.cloud.osdu-ds.com:9243'
storage-account-name: 'myStorageAccount'
\ No newline at end of file
properties:
compliance-ruleset:
sensitive: false
value: 'shared'
elastic-endpoint:
sensitive: true
value: 'elastic-endpoint'
cosmos-connection:
sensitive: true
value: 'cosmos-connection'
Property:
type: object
properties:
sensitive:
type: boolean
value:
type: object
\ No newline at end of file
......@@ -49,13 +49,34 @@ A sample output is shown below.
```
{
"elastic-username": "elastic",
"elastic-endpoint": "test-elastic-endpoint",
"compliance-ruleset": "shared",
"storage-account-name": "sampleAcc",
"elastic-password": "test-password",
"storage-account-key": "sampleKey",
"id": "common"
"compliance-ruleset": {
"sensitive": false,
"value": "shared"
},
"elastic-endpoint": {
"sensitive": true,
"value": "common-elastic-endpoint"
},
"elastic-username": {
"sensitive": true,
"value": "common-elastic-username"
},
"elastic-password": {
"sensitive": true,
"value": "common-elastic-password"
},
"cosmos-connection": {
"sensitive": true,
"value": "common-cosmos-connection"
},
"cosmos-endpoint": {
"sensitive": true,
"value": "common-cosmos-endpoint"
},
"id": {
"sensitive": false,
"value": "common"
}
}
```
......@@ -76,14 +97,30 @@ curl --request POST \
--header 'Authorization: Bearer <JWT>' \
--header 'Content-Type: application/json' \
--data-raw '{
"properties":
{
"elasticPassword": "test-password",
"elasticUsername": "elastic",
"elasticEndpoint": "test-elastic-endpoint",
"complianceRuleSet": "shared",
"storageAccountKey": "test-storage-key",
"id": "mypartition"
"properties": {
"compliance-ruleset": {
"value": "shared"
},
"elastic-endpoint": {
"sensitive": true,
"value": "elastic-endpoint"
},
"elastic-username": {
"sensitive": true,
"value": "elastic-username"
},
"elastic-password": {
"sensitive": true,
"value": "elastic-password"
},
"cosmos-connection": {
"sensitive": true,
"value": "cosmos-connection"
},
"cosmos-endpoint": {
"sensitive": true,
"value": "cosmos-endpoint"
}
}
}'
```
......
......@@ -27,7 +27,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<os-core-common.version>0.3.6</os-core-common.version>
<os-core-common.version>0.3.12</os-core-common.version>
</properties>
<packaging>pom</packaging>
......
......@@ -42,8 +42,9 @@ public class PartitionTableStore {
public void addPartition(String partitionId, PartitionInfo partitionInfo) {
Map<String, Property> requestProperties = partitionInfo.getProperties();
requestProperties.put(ID, Property.builder().value(partitionId).build());
TableBatchOperation batchOperation = new TableBatchOperation();
batchOperation.insertOrReplace(this.getIdPartitionEntity(partitionId));
for (Map.Entry<String, Property> entry : requestProperties.entrySet()) {
String key = entry.getKey();
Property property = entry.getValue();
......@@ -94,7 +95,7 @@ public class PartitionTableStore {
public void deletePartition(String partitionId) {
Iterable<PartitionEntity> results = (Iterable<PartitionEntity>)
this.cloudTableStore.queryByKey(PartitionEntity.class,
PARTITION_KEY, partitionId);
PARTITION_KEY, partitionId);
for (PartitionEntity tableEntity : results) {
this.cloudTableStore.deleteCloudTableEntity(PartitionEntity.class, tableEntity.getPartitionKey(), tableEntity.getRowKey());
}
......@@ -105,8 +106,8 @@ public class PartitionTableStore {
List<PartitionEntity> out = new ArrayList<>();
Iterable<PartitionEntity> results = (Iterable<PartitionEntity>)
this.cloudTableStore.queryByCompoundKey(PartitionEntity.class,
ROW_KEY, ID,
VALUE, partitionId);
ROW_KEY, ID,
VALUE, partitionId);
for (PartitionEntity tableEntity : results) {
out.add(tableEntity);
}
......@@ -118,7 +119,7 @@ public class PartitionTableStore {
List<PartitionEntity> out = new ArrayList<>();
Iterable<PartitionEntity> results = (Iterable<PartitionEntity>)
this.cloudTableStore.queryByKey(PartitionEntity.class,
PARTITION_KEY, partitionId);
PARTITION_KEY, partitionId);
for (PartitionEntity tableEntity : results) {
tableEntity.setPartitionId(tableEntity.getPartitionKey());
tableEntity.setName(tableEntity.getRowKey());
......@@ -127,15 +128,6 @@ public class PartitionTableStore {
return out;
}
private PartitionEntity getIdPartitionEntity(String partitionId) {
PartitionEntity partitionEntity = new PartitionEntity(partitionId, ID);
HashMap<String, EntityProperty> properties = new HashMap<>();
properties.put(VALUE, new EntityProperty(partitionId));
properties.put(SENSITIVE, new EntityProperty(false));
partitionEntity.setProperties(properties);
return partitionEntity;
}
private String getTenantSafeSecreteId(String partitionId, String secreteName) {
return String.format("%s-%s", partitionId, secreteName);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment