Skip to content

Commit e5bcd70

Browse files
authored
Merge pull request #173 from HarperDB/operations-utilities-refactor
Breaking operations-api/utilities out to separate files
2 parents c6a1c55 + 63375ca commit e5bcd70

File tree

9 files changed

+451
-440
lines changed

9 files changed

+451
-440
lines changed

.gitbook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
root: ./docs/
22

33
redirects:
4+
developers/operations-api/utilities: developers/operations-api/system-operations.md
45
install-harperdb: deployments/install-harper/README.md
56
install-harperdb/linux: deployments/install-harper/linux.md
67
install-harperdb/other: deployments/install-harper/README.md

docs/SUMMARY.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
* [Registration](developers/operations-api/registration.md)
3232
* [Jobs](developers/operations-api/jobs.md)
3333
* [Logs](developers/operations-api/logs.md)
34-
* [Utilities](developers/operations-api/utilities.md)
34+
* [System Operations](developers/operations-api/system-operations.md)
35+
* [Configuration](developers/operations-api/configuration.md)
36+
* [Certificate Management](developers/operations-api/certificate-management.md)
3537
* [Token Authentication](developers/operations-api/token-authentication.md)
3638
* [SQL Operations](developers/operations-api/sql-operations.md)
3739
* [Advanced JSON SQL Examples](developers/operations-api/advanced-json-sql-examples.md)

docs/developers/operations-api/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ The operations API reference is available below and categorized by topic:
2626
* [Registration](registration.md)
2727
* [Jobs](jobs.md)
2828
* [Logs](logs.md)
29-
* [Utilities](utilities.md)
29+
* [System Operations](system-operations.md)
30+
* [Configuration](configuration.md)
31+
* [Certificate Management](certificate-management.md)
3032
* [Token Authentication](token-authentication.md)
3133
* [SQL Operations](sql-operations.md)
3234
* [Advanced JSON SQL Examples](advanced-json-sql-examples.md)

docs/developers/operations-api/bulk-operations.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Bulk Operations
22

3+
## Export Local
4+
Exports data based on a given search operation to a local file in JSON or CSV format.
5+
6+
* operation _(required)_ - must always be `export_local`
7+
* format _(required)_ - the format you wish to export the data, options are `json` & `csv`
8+
* path _(required)_ - path local to the server to export the data
9+
* search_operation _(required)_ - search_operation of `search_by_hash`, `search_by_value`, `search_by_conditions` or `sql`
10+
* filename _(optional)_ - the name of the file where your export will be written to (do not include extension in filename). If one is not provided it will be autogenerated based on the epoch.
11+
12+
### Body
13+
```json
14+
{
15+
"operation": "export_local",
16+
"format": "json",
17+
"path": "/data/",
18+
"search_operation": {
19+
"operation": "sql",
20+
"sql": "SELECT * FROM dev.breed"
21+
}
22+
}
23+
```
24+
25+
### Response: 200
26+
```json
27+
{
28+
"message": "Starting job with id 6fc18eaa-3504-4374-815c-44840a12e7e5"
29+
}
30+
```
31+
32+
---
33+
334
## CSV Data Load
435
Ingests CSV data, provided directly in the operation as an `insert`, `update` or `upsert` into the specified database table.
536

@@ -92,6 +123,43 @@ Ingests CSV data, provided via URL, as an `insert`, `update` or `upsert` into th
92123

93124
---
94125

126+
## Export To S3
127+
Exports data based on a given search operation from table to AWS S3 in JSON or CSV format.
128+
129+
* operation _(required)_ - must always be `export_to_s3`
130+
* format _(required)_ - the format you wish to export the data, options are `json` & `csv`
131+
* s3 _(required)_ - details your access keys, bucket, bucket region and key for saving the data to S3
132+
* search_operation _(required)_ - search_operation of `search_by_hash`, `search_by_value`, `search_by_conditions` or `sql`
133+
134+
### Body
135+
```json
136+
{
137+
"operation": "export_to_s3",
138+
"format": "json",
139+
"s3": {
140+
"aws_access_key_id": "YOUR_KEY",
141+
"aws_secret_access_key": "YOUR_SECRET_KEY",
142+
"bucket": "BUCKET_NAME",
143+
"key": "OBJECT_NAME",
144+
"region": "BUCKET_REGION"
145+
},
146+
"search_operation": {
147+
"operation": "sql",
148+
"sql": "SELECT * FROM dev.dog"
149+
}
150+
}
151+
```
152+
153+
### Response: 200
154+
```json
155+
{
156+
"message": "Starting job with id 9fa85968-4cb1-4008-976e-506c4b13fc4a",
157+
"job_id": "9fa85968-4cb1-4008-976e-506c4b13fc4a"
158+
}
159+
```
160+
161+
---
162+
95163
## Import from S3
96164
This operation allows users to import CSV or JSON files from an AWS S3 bucket as an `insert`, `update` or `upsert`.
97165

@@ -129,4 +197,35 @@ This operation allows users to import CSV or JSON files from an AWS S3 bucket as
129197
"message": "Starting job with id 062a1892-6a0a-4282-9791-0f4c93b12e16",
130198
"job_id": "062a1892-6a0a-4282-9791-0f4c93b12e16"
131199
}
200+
```
201+
202+
---
203+
204+
## Delete Records Before
205+
206+
Delete data before the specified timestamp on the specified database table exclusively on the node where it is executed. Any clustered nodes with replicated data will retain that data.
207+
208+
_Operation is restricted to super_user roles only_
209+
210+
* operation _(required)_ - must always be `delete_records_before`
211+
* date _(required)_ - records older than this date will be deleted. Supported format looks like: `YYYY-MM-DDThh:mm:ss.sZ`
212+
* schema _(required)_ - name of the schema where you are deleting your data
213+
* table _(required)_ - name of the table where you are deleting your data
214+
215+
### Body
216+
```json
217+
{
218+
"operation": "delete_records_before",
219+
"date": "2021-01-25T23:05:27.464",
220+
"schema": "dev",
221+
"table": "breed"
222+
}
223+
```
224+
225+
### Response: 200
226+
```json
227+
{
228+
"message": "Starting job with id d3aed926-e9fe-4ec1-aea7-0fb4451bd373",
229+
"job_id": "d3aed926-e9fe-4ec1-aea7-0fb4451bd373"
230+
}
132231
```
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Certificate Management
2+
3+
## Add Certificate
4+
5+
Adds or updates a certificate in the `hdb_certificate` system table.
6+
If a `private_key` is provided it will __not__ be stored in `hdb_certificate`, it will be written to file in `<ROOTPATH>/keys/`.
7+
If a `private_key` is not passed the operation will search for one that matches the certificate. If one is not found an error will be returned.
8+
9+
_Operation is restricted to super_user roles only_
10+
11+
* operation _(required)_ - must always be `add_certificate`
12+
* name _(required)_ - a unique name for the certificate
13+
* certificate _(required)_ - a PEM formatted certificate string
14+
* is_authority _(required)_ - a boolean indicating if the certificate is a certificate authority
15+
* hosts _(optional)_ - an array of hostnames that the certificate is valid for
16+
* private_key _(optional)_ - a PEM formatted private key string
17+
18+
### Body
19+
```json
20+
{
21+
"operation": "add_certificate",
22+
"name": "my-cert",
23+
"certificate": "-----BEGIN CERTIFICATE-----ZDFAay... -----END CERTIFICATE-----",
24+
"is_authority": false,
25+
"private_key": "-----BEGIN RSA PRIVATE KEY-----Y4dMpw5f... -----END RSA PRIVATE KEY-----"
26+
}
27+
```
28+
29+
### Response: 200
30+
```json
31+
{
32+
"message": "Successfully added certificate: my-cert"
33+
}
34+
```
35+
36+
---
37+
38+
## Remove Certificate
39+
40+
Removes a certificate from the `hdb_certificate` system table and deletes the corresponding private key file.
41+
42+
_Operation is restricted to super_user roles only_
43+
44+
* operation _(required)_ - must always be `remove_certificate`
45+
* name _(required)_ - the name of the certificate
46+
47+
### Body
48+
```json
49+
{
50+
"operation": "remove_certificate",
51+
"name": "my-cert"
52+
}
53+
```
54+
55+
### Response: 200
56+
```json
57+
{
58+
"message": "Successfully removed my-cert"
59+
}
60+
```
61+
62+
---
63+
64+
## List Certificates
65+
66+
Lists all certificates in the `hdb_certificate` system table.
67+
68+
_Operation is restricted to super_user roles only_
69+
70+
* operation _(required)_ - must always be `list_certificates`
71+
72+
### Body
73+
```json
74+
{
75+
"operation": "list_certificates"
76+
}
77+
```
78+
79+
### Response: 200
80+
```json
81+
[
82+
{
83+
"name": "HarperDB-Certificate-Authority-node1",
84+
"certificate": "-----BEGIN CERTIFICATE-----\r\nTANBgkqhk... S34==\r\n-----END CERTIFICATE-----\r\n",
85+
"private_key_name": "privateKey.pem",
86+
"is_authority": true,
87+
"details": {
88+
"issuer": "CN=HarperDB-Certificate-Authority-node1 C=USA ST=Colorado L=Denver O=HarperDB\\, Inc.",
89+
"subject": "CN=HarperDB-Certificate-Authority-node1 C=USA ST=Colorado L=Denver O=HarperDB\\, Inc.",
90+
"serial_number": "5235345",
91+
"valid_from": "Aug 27 15:00:00 2024 GMT",
92+
"valid_to": "Aug 25 15:00:00 2034 GMT"
93+
},
94+
"is_self_signed": true,
95+
"uses": [
96+
"https",
97+
"wss"
98+
]
99+
},
100+
{
101+
"name": "node1",
102+
"certificate": "-----BEGIN CERTIFICATE-----\r\ngIEcSR1M... 5bv==\r\n-----END CERTIFICATE-----\r\n",
103+
"private_key_name": "privateKey.pem",
104+
"is_authority": false,
105+
"details": {
106+
"issuer": "CN=HarperDB-Certificate-Authority-node1 C=USA ST=Colorado L=Denver O=HarperDB\\, Inc.",
107+
"subject": "CN=node.1 C=USA ST=Colorado L=Denver O=HarperDB\\, Inc.",
108+
"subject_alt_name": "IP Address:127.0.0.1, DNS:localhost, IP Address:0:0:0:0:0:0:0:1, DNS:node.1",
109+
"serial_number": "5243646",
110+
"valid_from": "Aug 27 15:00:00 2024 GMT",
111+
"valid_to": "Aug 25 15:00:00 2034 GMT"
112+
},
113+
"is_self_signed": true,
114+
"uses": [
115+
"https",
116+
"wss"
117+
]
118+
}
119+
]
120+
```

docs/developers/operations-api/components.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ _Operation is restricted to super\_user roles only_
317317
}
318318
```
319319

320+
***
321+
320322
## Add SSH Key
321323

322324
Adds an SSH key for deploying components from private repositories. This will also create an ssh config file that will be used when deploying the components.
@@ -379,6 +381,8 @@ Host harperdb-private-component.github.com
379381

380382
Note that `deploy_component` with a package uses `npm install` so the url must be a valid npm format url. The above is an example of a url using a tag in the repo to install.
381383

384+
***
385+
382386
## Update SSH Key
383387

384388
Updates the private key contents of an existing SSH key.
@@ -436,6 +440,8 @@ _Operation is restricted to super\_user roles only_
436440
}
437441
```
438442

443+
***
444+
439445
## List SSH Keys
440446

441447
List off the names of added SSH keys
@@ -463,6 +469,8 @@ _Operation is restricted to super\_user roles only_
463469
]
464470
```
465471

472+
***
473+
466474
## Set SSH Known Hosts
467475

468476
Sets the SSH known\_hosts file. This will overwrite the file.
@@ -513,3 +521,27 @@ _Operation is restricted to super\_user roles only_
513521
"known_hosts": "github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=\ngithub.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl\ngithub.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=\n"
514522
}
515523
```
524+
525+
***
526+
527+
## Install Node Modules
528+
This operation is deprecated, as it is handled automatically by deploy_component and restart.
529+
Executes npm install against specified custom function projects.
530+
531+
_Operation is restricted to super_user roles only_
532+
533+
* operation _(required)_ - must always be `install_node_modules`
534+
* projects _(required)_ - must ba an array of custom functions projects.
535+
* dry_run _(optional)_ - refers to the npm --dry-run flag: [https://docs.npmjs.com/cli/v8/commands/npm-install#dry-run](https://docs.npmjs.com/cli/v8/commands/npm-install#dry-run). Defaults to false.
536+
537+
### Body
538+
```json
539+
{
540+
"operation": "install_node_modules",
541+
"projects": [
542+
"dogs",
543+
"cats"
544+
],
545+
"dry_run": true
546+
}
547+
```

0 commit comments

Comments
 (0)