Partition.md 5.69 KB
Newer Older
Riabokon Stanislav(EPAM)[GCP]'s avatar
Riabokon Stanislav(EPAM)[GCP] committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
## Partition Service

## Table of Contents <a name="TOC"></a>
* [Introduction](#introduction)
* [Checking Service Health](#checking-service-health)
* [Partition API access](#partition-api-access)
* [APIs](#apis)
    * [Get partition details](#get-partition)
    * [Create a new partition](#create-partition)
    * [Update an existing partition](#update-partition)
    * [Delete an existing partition](#delete-partition)
    * [List of partitions](#list-partition)
    

## Introduction <a name="introduction"></a>
Partition service is responsible for creating and retrieving the partition specific properties (secret and non-secret) on behalf of other services.

## Health Check <a name="checking-service-health"></a>
An endpoint to check if service is up and running.
```
GET api/partition/v1/_ah/liveness_check
```
<details><summary>curl</summary>

```
curl --request GET \
  --url 'https://<base_url>/api/partition/v1/_ah/liveness_check'
```
</details>

## Partition API access <a name="partition-api-access"></a>
As Partition service APIs are mostly consumed by other services, API access is limited to service accounts only.

## APIs <a name="apis"></a>
### Get partition details<a name="get-partition"></a>
Consuming services can use this API to get details of a partition. Partition details consists of a set of key-value pairs of properties.

```
GET api/partition/v1/partitions/{partitionId}
```
<details><summary>curl</summary>

```
curl --request GET \
  --url 'https://<base_url>/api/partition/v1/partitions/osdu' \
  --header 'Authorization: Bearer <JWT>' \
  --header 'Content-Type: application/json'
```
</details>

A sample output is shown below.
<details><summary>Sample response</summary>

```
{
    "projectId": {
        "sensitive": false,
        "value": "osdu"
    },
    "serviceAccount": {
        "sensitive": false,
        "value": ".iam.gserviceaccount.com"
    },
    "complianceRuleSet": {
        "sensitive": false,
        "value": "shared"
    },
    "dataPartitionId": {
        "sensitive": false,
        "value": "osdu"
    },
    "name": {
        "sensitive": false,
        "value": "osdu"
    },
    "policy-service-enabled": {
        "sensitive": false,
        "value": "false"
    },
    "bucket": {
        "sensitive": false,
        "value": "bucketName"
    },
    "crmAccountID": {
        "sensitive": false,
86
        "value": ["osdu","osdu"]
Riabokon Stanislav(EPAM)[GCP]'s avatar
Riabokon Stanislav(EPAM)[GCP] committed
87
88
89
90
91
92
93
94
95
96
    }
}
```

</details>

[Back to Table of Contents](#TOC)

### Create a new partition<a name="create-partition"></a>
This api can be used to create a new partition. A plausible use case would be partition provisioning infrastructure script.
97
The default namespace value of Cloud Datastore is `partition`.
Riabokon Stanislav(EPAM)[GCP]'s avatar
Riabokon Stanislav(EPAM)[GCP] committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
```
POST api/partition/v1/partitions/{partitionId}
```
<details><summary>curl</summary>

```
curl --request POST \
  --url 'https://<base_url>/api/partition/v1/partitions/mypartition' \
  --header 'Authorization: Bearer <JWT>' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "properties": {
        "projectId": {
            "sensitive": false,
            "value": "mypartition"
        },
        "serviceAccount": {
            "sensitive": false,
            "value": ".iam.gserviceaccount.com"
        },
        "complianceRuleSet": {
            "sensitive": false,
            "value": "shared"
        },
        "dataPartitionId": {
            "sensitive": false,
            "value": "mypartition"
        },
        "name": {
            "sensitive": false,
            "value": "mypartition"
        },
        "policy-service-enabled": {
            "sensitive": false,
            "value": "false"
        },
        "bucket": {
            "sensitive": false,
            "value": "bucketName"
        },
        "crmAccountID": {
            "sensitive": false,
140
            "value": ["mypartition","mypartition"]
Riabokon Stanislav(EPAM)[GCP]'s avatar
Riabokon Stanislav(EPAM)[GCP] committed
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
        }
      }
  }'
```
</details>

[Back to Table of Contents](#TOC)

### Update an existing partition<a name="update-partition"></a>
This api is used to update the properties of an existing partition. With this api, we can modify existing properties or add new ones. Deletion of properties can not be achieved, we'll have to delete the partition and re-create it for the same effect.
```
PATCH api/partition/v1/partitions/{partitionId}
```
<details><summary>curl</summary>

```
curl --request PATCH \
  --url 'https://<base_url>/api/partition/v1/partitions/mypartition' \
  --header 'Authorization: Bearer <JWT>' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "properties": {
          "bucket": {
              "value": "bucket-update-value"
          },
          "new-key": {
              "sensitive": true,
              "value": "new-value"
          }
      }
  }'
```
</details>

### Delete an existing partition<a name="delete-partition"></a>
This api is used to delete an existing partition. A plausible use case would be partition teardown infrastructure script.
```
DELETE api/partition/v1/partitions/{partitionId}
```
<details><summary>curl</summary>

```
curl --request DELETE \
  --url 'https://<base_url>/api/partition/v1/partitions/mypartition' \
  --header 'Authorization: Bearer <JWT>' \
  --header 'Content-Type: application/json'
```
</details>


### List partitions <a name="list-partition"></a>
Consuming services can use this API to list all partitions Id.  
```
GET api/partition/v1/partitions
```
<details><summary>curl</summary>

```
curl --request GET \
  --url 'https://<base_url>/api/partition/v1/partitions' \
  --header 'Authorization: Bearer <JWT>' \
  --header 'Content-Type: application/json'
```
</details>

A sample output is shown below.
<details><summary>Sample response</summary>

```
[
    "default-dev",
    "opendes",
    "osdu",
    "mypartition"
]
```

</details>

[Back to Table of Contents](#TOC)