Skip to content

Commit

Permalink
[NOID] Fixes #2136: Support for additional HTTP headers in apoc.es pr…
Browse files Browse the repository at this point in the history
…ocedures (#3953)
  • Loading branch information
vga91 committed Mar 10, 2024
1 parent f2ccc3a commit 835113a
Show file tree
Hide file tree
Showing 21 changed files with 388 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
¦xref::overview/apoc.es/apoc.es.get.adoc[apoc.es.get icon:book[]] +

`apoc.es.get(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value` - perform a GET operation on elastic search
`apoc.es.get(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value` - perform a GET operation on elastic search
¦label:procedure[]
¦label:apoc-full[]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
¦xref::overview/apoc.es/apoc.es.getRaw.adoc[apoc.es.getRaw icon:book[]] +

`apoc.es.getRaw(host-or-port,path,payload-or-null) yield value` - perform a raw GET operation on elastic search
`apoc.es.getRaw(host-or-port,path,payload-or-null,$config) yield value` - perform a raw GET operation on elastic search
¦label:procedure[]
¦label:apoc-full[]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
¦xref::overview/apoc.es/apoc.es.post.adoc[apoc.es.post icon:book[]] +

`apoc.es.post(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null) yield value` - perform a POST operation on elastic search
`apoc.es.post(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null,$config) yield value` - perform a POST operation on elastic search
¦label:procedure[]
¦label:apoc-full[]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
¦xref::overview/apoc.es/apoc.es.postRaw.adoc[apoc.es.postRaw icon:book[]] +

`apoc.es.postRaw(host-or-port,path,payload-or-null) yield value` - perform a raw POST operation on elastic search
`apoc.es.postRaw(host-or-port,path,payload-or-null,$config) yield value` - perform a raw POST operation on elastic search
¦label:procedure[]
¦label:apoc-full[]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
¦xref::overview/apoc.es/apoc.es.put.adoc[apoc.es.put icon:book[]] +

`apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value` - perform a PUT operation on elastic search
`apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value` - perform a PUT operation on elastic search
¦label:procedure[]
¦label:apoc-full[]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
¦xref::overview/apoc.es/apoc.es.query.adoc[apoc.es.query icon:book[]] +

`apoc.es.query(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null) yield value` - perform a SEARCH operation on elastic search
`apoc.es.query(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null,$config) yield value` - perform a SEARCH operation on elastic search
¦label:procedure[]
¦label:apoc-full[]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
¦xref::overview/apoc.es/apoc.es.stats.adoc[apoc.es.stats icon:book[]] +

`apoc.es.stats(host-url-Key)` - elastic search statistics
`apoc.es.stats(host-url-Key,$config)` - elastic search statistics
¦label:procedure[]
¦label:apoc-full[]
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ This example was tested on a Mac Book Pro with 16GB of RAM. Loading 20000 docume

[source,cypher]
----
call apoc.es.post(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value
call apoc.es.post(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value
// GET/PUT/POST url/index/type/id?query -d payload
----
Expand Down Expand Up @@ -125,6 +125,34 @@ Query can be a map which is turned into a query string, a direct string or null

Payload can be a *map* which will be turned into a json payload or a string which will be sent directly or null.

=== config parameter

Config can be an optional *map*, which can have the following entries:

.Config parameters
[opts=header, cols="1,1,1,4"]
|===
| name | type | default | description
| headers | `Map` | {`content-type`: "application/json", `method`, "<httpMethod>"} | Contains a header map to add (or replace) the default one.
The `method: <httpMethod>` is needed by APOC to figure out under the hood, which http request method to pass.
That is, by default, it is `PUT` with the `apoc.es.put`, POST with the `apoc.es.post` and `apoc.es.postRaw`, and GET in other cases.
|===


For example, by using the `apoc.es.stats`, we can execute:
[source, cypher]
----
CALL apoc.es.stats('custom', { headers: {Authorization: "Basic <Base64Token>"} })
----

to use a https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html[Basic authentication]
and create the following HTTP header:
```
Authorization: Basic <Base64Token>
method: GET
Content-Type: application/json
```


=== Results

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This file is generated by DocsTest, so don't change it!
label:procedure[] label:apoc-full[]

[.emphasis]
apoc.es.get(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value - perform a GET operation on elastic search
apoc.es.get(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value - perform a GET operation on elastic search

== Signature

[source]
----
apoc.es.get(host :: STRING?, index :: STRING?, type :: STRING?, id :: STRING?, query :: ANY?, payload :: ANY?) :: (value :: MAP?)
apoc.es.get(host :: STRING?, index :: STRING?, type :: STRING?, id :: STRING?, query :: ANY?, payload :: ANY?, config = {} :: MAP?) :: (value :: MAP?)
----

== Input parameters
Expand All @@ -27,6 +27,7 @@ apoc.es.get(host :: STRING?, index :: STRING?, type :: STRING?, id :: STRING?, q
|id|STRING?|null
|query|ANY?|null
|payload|ANY?|null
|config|MAP?|{}
|===

== Output parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This file is generated by DocsTest, so don't change it!
label:procedure[] label:apoc-full[]

[.emphasis]
apoc.es.getRaw(host-or-port,path,payload-or-null) yield value - perform a raw GET operation on elastic search
apoc.es.getRaw(host-or-port,path,payload-or-null,$config) yield value - perform a raw GET operation on elastic search

== Signature

[source]
----
apoc.es.getRaw(host :: STRING?, path :: STRING?, payload :: ANY?) :: (value :: MAP?)
apoc.es.getRaw(host :: STRING?, path :: STRING?, payload :: ANY?, config = {} :: MAP?) :: (value :: MAP?)
----

== Input parameters
Expand All @@ -24,6 +24,7 @@ apoc.es.getRaw(host :: STRING?, path :: STRING?, payload :: ANY?) :: (value :: M
|host|STRING?|null
|path|STRING?|null
|payload|ANY?|null
|config|MAP?|{}
|===

== Output parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This file is generated by DocsTest, so don't change it!
label:procedure[] label:apoc-full[]

[.emphasis]
apoc.es.post(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null) yield value - perform a POST operation on elastic search
apoc.es.post(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null,$config) yield value - perform a POST operation on elastic search

== Signature

[source]
----
apoc.es.post(host :: STRING?, index :: STRING?, type :: STRING?, query :: ANY?, payload = {} :: MAP?) :: (value :: MAP?)
apoc.es.post(host :: STRING?, index :: STRING?, type :: STRING?, query :: ANY?, payload = {} :: MAP?, config = {} :: MAP?) :: (value :: MAP?)
----

== Input parameters
Expand All @@ -26,6 +26,7 @@ apoc.es.post(host :: STRING?, index :: STRING?, type :: STRING?, query :: ANY?,
|type|STRING?|null
|query|ANY?|null
|payload|MAP?|{}
|config|MAP?|{}
|===

== Output parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This file is generated by DocsTest, so don't change it!
label:procedure[] label:apoc-full[]

[.emphasis]
apoc.es.postRaw(host-or-port,path,payload-or-null) yield value - perform a raw POST operation on elastic search
apoc.es.postRaw(host-or-port,path,payload-or-null,$config) yield value - perform a raw POST operation on elastic search

== Signature

[source]
----
apoc.es.postRaw(host :: STRING?, path :: STRING?, payload :: ANY?) :: (value :: MAP?)
apoc.es.postRaw(host :: STRING?, path :: STRING?, payload :: ANY?, config = {} :: MAP?) :: (value :: MAP?)
----

== Input parameters
Expand All @@ -24,6 +24,7 @@ apoc.es.postRaw(host :: STRING?, path :: STRING?, payload :: ANY?) :: (value ::
|host|STRING?|null
|path|STRING?|null
|payload|ANY?|null
|config|MAP?|{}
|===

== Output parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This file is generated by DocsTest, so don't change it!
label:procedure[] label:apoc-full[]

[.emphasis]
apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value - perform a PUT operation on elastic search
apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value - perform a PUT operation on elastic search

== Signature

[source]
----
apoc.es.put(host :: STRING?, index :: STRING?, type :: STRING?, id :: STRING?, query :: ANY?, payload = {} :: MAP?) :: (value :: MAP?)
apoc.es.put(host :: STRING?, index :: STRING?, type :: STRING?, id :: STRING?, query :: ANY?, config = {} :: MAP?) :: (value :: MAP?)
----

== Input parameters
Expand All @@ -27,6 +27,7 @@ apoc.es.put(host :: STRING?, index :: STRING?, type :: STRING?, id :: STRING?, q
|id|STRING?|null
|query|ANY?|null
|payload|MAP?|{}
|config|MAP?|{}
|===

== Output parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ This file is generated by DocsTest, so don't change it!
label:procedure[] label:apoc-full[]

[.emphasis]
apoc.es.query(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null) yield value - perform a SEARCH operation on elastic search
apoc.es.query(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null,$config) yield value - perform a SEARCH operation on elastic search

== Signature

[source]
----
apoc.es.query(host :: STRING?, index :: STRING?, type :: STRING?, query :: ANY?, payload :: ANY?) :: (value :: MAP?)
apoc.es.query(host :: STRING?, index :: STRING?, type :: STRING?, query :: ANY?, payload :: ANY?, config = {} :: MAP?) :: (value :: MAP?)
----

== Input parameters
Expand All @@ -26,6 +26,7 @@ apoc.es.query(host :: STRING?, index :: STRING?, type :: STRING?, query :: ANY?,
|type|STRING?|null
|query|ANY?|null
|payload|ANY?|null
|config|MAP?|{}
|===

== Output parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ This file is generated by DocsTest, so don't change it!
label:procedure[] label:apoc-full[]

[.emphasis]
apoc.es.stats(host-url-Key) - elastic search statistics
apoc.es.stats(host-url-Key,$config) - elastic search statistics

== Signature

[source]
----
apoc.es.stats(host :: STRING?) :: (value :: MAP?)
apoc.es.stats(host :: STRING?, payload = {} :: MAP?, config = {} :: MAP?) :: (value :: MAP?)
----

== Input parameters
[.procedures, opts=header]
|===
| Name | Type | Default
|host|STRING?|null
|config|MAP?|{}
|===

== Output parameters
Expand Down
14 changes: 7 additions & 7 deletions docs/asciidoc/modules/ROOT/pages/overview/apoc.es/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ This file is generated by DocsTest, so don't change it!
| Qualified Name | Type | Release
|xref::overview/apoc.es/apoc.es.get.adoc[apoc.es.get icon:book[]]

apoc.es.get(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value - perform a GET operation on elastic search
apoc.es.get(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value - perform a GET operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.getRaw.adoc[apoc.es.getRaw icon:book[]]

apoc.es.getRaw(host-or-port,path,payload-or-null) yield value - perform a raw GET operation on elastic search
apoc.es.getRaw(host-or-port,path,payload-or-null,$config) yield value - perform a raw GET operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.post.adoc[apoc.es.post icon:book[]]

apoc.es.post(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null) yield value - perform a POST operation on elastic search
apoc.es.post(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null,$config) yield value - perform a POST operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.postRaw.adoc[apoc.es.postRaw icon:book[]]

apoc.es.postRaw(host-or-port,path,payload-or-null) yield value - perform a raw POST operation on elastic search
apoc.es.postRaw(host-or-port,path,payload-or-null,$config) yield value - perform a raw POST operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.put.adoc[apoc.es.put icon:book[]]

apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value - perform a PUT operation on elastic search
apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value - perform a PUT operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.query.adoc[apoc.es.query icon:book[]]

apoc.es.query(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null) yield value - perform a SEARCH operation on elastic search
apoc.es.query(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null,$config) yield value - perform a SEARCH operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.stats.adoc[apoc.es.stats icon:book[]]

apoc.es.stats(host-url-Key) - elastic search statistics
apoc.es.stats(host-url-Key,$config) - elastic search statistics
|label:procedure[]
|label:apoc-full[]
|===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,37 +1177,37 @@ Query a virtualized resource by name and return virtual nodes linked using virtu
| Qualified Name | Type | Release
|xref::overview/apoc.es/apoc.es.get.adoc[apoc.es.get icon:book[]]

apoc.es.get(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value - perform a GET operation on elastic search
apoc.es.get(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value - perform a GET operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.getRaw.adoc[apoc.es.getRaw icon:book[]]

apoc.es.getRaw(host-or-port,path,payload-or-null) yield value - perform a raw GET operation on elastic search
apoc.es.getRaw(host-or-port,path,payload-or-null,$config) yield value - perform a raw GET operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.post.adoc[apoc.es.post icon:book[]]

apoc.es.post(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null) yield value - perform a POST operation on elastic search
apoc.es.post(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null,$config) yield value - perform a POST operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.postRaw.adoc[apoc.es.postRaw icon:book[]]

apoc.es.postRaw(host-or-port,path,payload-or-null) yield value - perform a raw POST operation on elastic search
apoc.es.postRaw(host-or-port,path,payload-or-null,$config) yield value - perform a raw POST operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.put.adoc[apoc.es.put icon:book[]]

apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null) yield value - perform a PUT operation on elastic search
apoc.es.put(host-or-port,index-or-null,type-or-null,id-or-null,query-or-null,payload-or-null,$config) yield value - perform a PUT operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.query.adoc[apoc.es.query icon:book[]]

apoc.es.query(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null) yield value - perform a SEARCH operation on elastic search
apoc.es.query(host-or-port,index-or-null,type-or-null,query-or-null,payload-or-null,$config) yield value - perform a SEARCH operation on elastic search
|label:procedure[]
|label:apoc-full[]
|xref::overview/apoc.es/apoc.es.stats.adoc[apoc.es.stats icon:book[]]

apoc.es.stats(host-url-Key) - elastic search statistics
apoc.es.stats(host-url-Key,$config) - elastic search statistics
|label:procedure[]
|label:apoc-full[]
|===
Expand Down

0 comments on commit 835113a

Please sign in to comment.