Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix document HTTP API examples #616

Merged
merged 11 commits into from
Oct 21, 2024
Merged
26 changes: 13 additions & 13 deletions .circleci/base_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ jobs:
steps:
- add_ssh_keys:
fingerprints:
- "6f:62:f0:fc:7e:bc:e4:a3:5e:2d:b9:ff:c9:a3:e3:60"
- "46:9f:e7:8a:46:9d:e1:bc:c2:db:36:1e:0b:5c:ed:7d"
- "37:83:f6:17:83:8c:39:bc:52:8a:72:e4:0f:d1:e2:86"
- "SHA256:8uq1GQqiVEx4mMbcN0vh99pAeXXwH0o/FHmwsAMNACk" # arangodb/docs-hugo
#- "SHA256:OE7k4elryS7yb1giEaxQkrAlFPM4fnKtz5G9Ft75x1c" # arangodb/arangodb
#- "SHA256:fIpByW5kNA9xbhEawhClMdoimiRsr6yggmwPRXutZ5o" # arangodb/enterprise
- run: ssh-keyscan github.com >> ~/.ssh/known_hosts && cat ~/.ssh/known_hosts

- run:
Expand Down Expand Up @@ -458,9 +458,9 @@ jobs:
steps:
- add_ssh_keys:
fingerprints:
- "6f:62:f0:fc:7e:bc:e4:a3:5e:2d:b9:ff:c9:a3:e3:60"
- "46:9f:e7:8a:46:9d:e1:bc:c2:db:36:1e:0b:5c:ed:7d"
- "37:83:f6:17:83:8c:39:bc:52:8a:72:e4:0f:d1:e2:86"
- "SHA256:8uq1GQqiVEx4mMbcN0vh99pAeXXwH0o/FHmwsAMNACk" # arangodb/docs-hugo
#- "SHA256:OE7k4elryS7yb1giEaxQkrAlFPM4fnKtz5G9Ft75x1c" # arangodb/arangodb
#- "SHA256:fIpByW5kNA9xbhEawhClMdoimiRsr6yggmwPRXutZ5o" # arangodb/enterprise
- attach_workspace:
at: .

Expand Down Expand Up @@ -499,9 +499,9 @@ jobs:
steps:
- add_ssh_keys:
fingerprints:
- "6f:62:f0:fc:7e:bc:e4:a3:5e:2d:b9:ff:c9:a3:e3:60"
- "46:9f:e7:8a:46:9d:e1:bc:c2:db:36:1e:0b:5c:ed:7d"
- "37:83:f6:17:83:8c:39:bc:52:8a:72:e4:0f:d1:e2:86"
- "SHA256:8uq1GQqiVEx4mMbcN0vh99pAeXXwH0o/FHmwsAMNACk" # arangodb/docs-hugo
#- "SHA256:OE7k4elryS7yb1giEaxQkrAlFPM4fnKtz5G9Ft75x1c" # arangodb/arangodb
#- "SHA256:fIpByW5kNA9xbhEawhClMdoimiRsr6yggmwPRXutZ5o" # arangodb/enterprise
- run: ssh-keyscan github.com >> ~/.ssh/known_hosts
- clone-docs-and-merge
- download-generated-data
Expand Down Expand Up @@ -545,17 +545,17 @@ jobs:
- image: << parameters.build-image >>
resource_class: xlarge
environment:
GIT_SSH_COMMAND: ssh
#GIT_SSH_COMMAND: ssh
SCCACHE_ERROR_LOG: /tmp/sccache.log
SCCACHE_LOG: info,sccache::cache=debug,sccache::compiler::compiler=debug
steps:
- setup_remote_docker:
version: default # TODO: Does this need to match the installed docker-cli version?
- add_ssh_keys:
fingerprints:
- "6f:62:f0:fc:7e:bc:e4:a3:5e:2d:b9:ff:c9:a3:e3:60"
- "46:9f:e7:8a:46:9d:e1:bc:c2:db:36:1e:0b:5c:ed:7d"
- "37:83:f6:17:83:8c:39:bc:52:8a:72:e4:0f:d1:e2:86"
#- "SHA256:8uq1GQqiVEx4mMbcN0vh99pAeXXwH0o/FHmwsAMNACk" # arangodb/docs-hugo
#- "SHA256:OE7k4elryS7yb1giEaxQkrAlFPM4fnKtz5G9Ft75x1c" # arangodb/arangodb
- "SHA256:fIpByW5kNA9xbhEawhClMdoimiRsr6yggmwPRXutZ5o" # arangodb/enterprise
- run: ssh-keyscan github.com >> ~/.ssh/known_hosts && cat ~/.ssh/known_hosts
- clone-arangodb:
branch: << parameters.arangodb-branch >>
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,8 @@ need to be output explicitly by calling one of the following functions:
for formatting complex requests.
- `logJsonResponse(response)`: output a JSON server reply (fails on invalid JSON)
- `logJsonLResponse(response)`: output a JSONL server reply (fails on invalid JSON)
- `logRawResponse(response)`: output plaintext response (do not use for JSON replies)
- `logRawResponse(response)`: output plaintext response (do not use for JSON replies;
can be used for endpoint calls that return an empty body to output the headers)
- `logPlainResponse(response)`: output decoded response (new lines instead of
`\r\n` etc.). Useful for formatting complex responses, like from batch requests.
- `logHtmlResponse(response)`: output HTML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name: COMBINING_GRAPH_01_create_graph
description: ''
---
var examples = require("@arangodb/graph-examples/example-graph");
var g = examples.loadGraph("routeplanner");
examples.loadGraph("routeplanner");
~examples.dropGraph("routeplanner");
```

Expand Down
19 changes: 12 additions & 7 deletions site/content/3.11/develop/http-api/documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,9 @@ var document = db.products.save({"hello":"world"});
var url = "/_api/document/" + document._id;

var response = logCurlRequest('GET', url);

assert(response.code === 200);

logJsonResponse(response);

db._drop(cn);
```

Expand All @@ -204,8 +203,9 @@ var url = "/_api/document/" + document._id;
var headers = {"If-None-Match": "\"" + document._rev + "\""};

var response = logCurlRequest('GET', url, "", headers);

assert(response.code === 304);
logRawResponse(response);

db._drop(cn);
```

Expand All @@ -215,13 +215,17 @@ description: |-
Unknown document identifier:
name: RestDocumentHandlerReadDocumentUnknownHandle
---
var url = "/_api/document/products/unknown-identifier";
var cn = "products";
db._drop(cn);
db._create(cn);

var response = logCurlRequest('GET', url);
var url = "/_api/document/" + cn + "/unknown-identifier";

var response = logCurlRequest('GET', url);
assert(response.code === 404);

logJsonResponse(response);

db._drop(cn);
```

#### Get a document header
Expand Down Expand Up @@ -332,8 +336,9 @@ var document = db.products.save({"hello":"world"});
var url = "/_api/document/" + document._id;

var response = logCurlRequest('HEAD', url);

assert(response.code === 200);
logRawResponse(response);

db._drop(cn);
```

Expand Down
100 changes: 50 additions & 50 deletions site/content/3.11/develop/http-api/graphs/named-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -780,20 +780,20 @@ var graph = require("@arangodb/general-graph");
}
var url = "/_api/gharial";
body = {
name: "disjointSmartGraph",
edgeDefinitions: [{
collection: "edges",
from: [ "startVertices" ],
to: [ "endVertices" ]
}],
orphanCollections: [ "orphanVertices" ],
isSmart: true,
options: {
isDisjoint: true,
replicationFactor: 2,
numberOfShards: 9,
smartGraphAttribute: "region"
}
name: "disjointSmartGraph",
edgeDefinitions: [{
collection: "edges",
from: [ "startVertices" ],
to: [ "endVertices" ]
}],
orphanCollections: [ "orphanVertices" ],
isSmart: true,
options: {
isDisjoint: true,
replicationFactor: 2,
numberOfShards: 9,
smartGraphAttribute: "region"
}
};

var response = logCurlRequest('POST', url, body);
Expand Down Expand Up @@ -822,20 +822,20 @@ var graph = require("@arangodb/general-graph");
}
var url = "/_api/gharial";
body = {
name: "smartGraph",
edgeDefinitions: [{
collection: "edges",
from: [ "startVertices" ],
to: [ "endVertices" ]
}],
orphanCollections: [ "orphanVertices" ],
isSmart: true,
options: {
replicationFactor: 2,
numberOfShards: 9,
smartGraphAttribute: "region",
satellites: [ "endVertices" ]
}
name: "smartGraph",
edgeDefinitions: [{
collection: "edges",
from: [ "startVertices" ],
to: [ "endVertices" ]
}],
orphanCollections: [ "orphanVertices" ],
isSmart: true,
options: {
replicationFactor: 2,
numberOfShards: 9,
smartGraphAttribute: "region",
satellites: [ "endVertices" ]
}
};

var response = logCurlRequest('POST', url, body);
Expand All @@ -861,18 +861,18 @@ var graph = require("@arangodb/general-graph");
}
var url = "/_api/gharial";
body = {
name: "enterpriseGraph",
edgeDefinitions: [{
collection: "edges",
from: [ "startVertices" ],
to: [ "endVertices" ]
}],
orphanCollections: [ ],
isSmart: true,
options: {
replicationFactor: 2,
numberOfShards: 9,
}
name: "enterpriseGraph",
edgeDefinitions: [{
collection: "edges",
from: [ "startVertices" ],
to: [ "endVertices" ]
}],
orphanCollections: [ ],
isSmart: true,
options: {
replicationFactor: 2,
numberOfShards: 9,
}
};

var response = logCurlRequest('POST', url, body);
Expand Down Expand Up @@ -900,16 +900,16 @@ var graph = require("@arangodb/general-graph");
}
var url = "/_api/gharial";
body = {
name: "satelliteGraph",
edgeDefinitions: [{
collection: "edges",
from: [ "startVertices" ],
to: [ "endVertices" ]
}],
orphanCollections: [ ],
options: {
replicationFactor: "satellite"
}
name: "satelliteGraph",
edgeDefinitions: [{
collection: "edges",
from: [ "startVertices" ],
to: [ "endVertices" ]
}],
orphanCollections: [ ],
options: {
replicationFactor: "satellite"
}
};

var response = logCurlRequest('POST', url, body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name: COMBINING_GRAPH_01_create_graph
description: ''
---
var examples = require("@arangodb/graph-examples/example-graph");
var g = examples.loadGraph("routeplanner");
examples.loadGraph("routeplanner");
~examples.dropGraph("routeplanner");
```

Expand Down
19 changes: 12 additions & 7 deletions site/content/3.12/develop/http-api/documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,9 @@ var document = db.products.save({"hello":"world"});
var url = "/_api/document/" + document._id;

var response = logCurlRequest('GET', url);

assert(response.code === 200);

logJsonResponse(response);

db._drop(cn);
```

Expand All @@ -204,8 +203,9 @@ var url = "/_api/document/" + document._id;
var headers = {"If-None-Match": "\"" + document._rev + "\""};

var response = logCurlRequest('GET', url, "", headers);

assert(response.code === 304);
logRawResponse(response);

db._drop(cn);
```

Expand All @@ -215,13 +215,17 @@ description: |-
Unknown document identifier:
name: RestDocumentHandlerReadDocumentUnknownHandle
---
var url = "/_api/document/products/unknown-identifier";
var cn = "products";
db._drop(cn);
db._create(cn);

var response = logCurlRequest('GET', url);
var url = "/_api/document/" + cn + "/unknown-identifier";

var response = logCurlRequest('GET', url);
assert(response.code === 404);

logJsonResponse(response);

db._drop(cn);
```

#### Get a document header
Expand Down Expand Up @@ -332,8 +336,9 @@ var document = db.products.save({"hello":"world"});
var url = "/_api/document/" + document._id;

var response = logCurlRequest('HEAD', url);

assert(response.code === 200);
logRawResponse(response);

db._drop(cn);
```

Expand Down
Loading