Skip to content

Commit b055cc5

Browse files
authored
Merge pull request #54 from marklogic/feature/more-docs
Added TOC and info on kwargs for eval/rows
2 parents 7080987 + 208ebae commit b055cc5

File tree

7 files changed

+75
-1
lines changed

7 files changed

+75
-1
lines changed

docs/creating-client.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ The `Client` class is the primary API to interact with in the MarkLogic Python c
1111
found in both the `Session` class and the `requests` API. You can therefore use a `Client` object in the same manner
1212
as you'd use either the `Session` class or the `requests` API.
1313

14+
## Table of contents
15+
{: .no_toc .text-delta }
16+
17+
- TOC
18+
{:toc}
19+
1420
## Creating a client
1521

1622
A `Client` instance can be created either by providing a base URL for all requests along with authentication:

docs/eval.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ execution of custom code, whether via an inline script or an existing module in
99
The MarkLogic Python client supports execution of custom code by simplifying the submission of custom code
1010
and converting the multipart response into more useful Python data types.
1111

12+
## Table of contents
13+
{: .no_toc .text-delta }
14+
15+
- TOC
16+
{:toc}
17+
1218
## Setup
1319

1420
The examples below all depend on the instructions in the [setup guide](example-setup.md) having already been performed.
@@ -117,3 +123,17 @@ processing of the response or debugging requests.
117123
The `client.eval` and `client.invoke` functions both support referencing a
118124
[REST API transaction](https://docs.marklogic.com/REST/client/transaction-management) via the `tx`
119125
argument. See [the guide on transactions](transactions.md) for further information.
126+
127+
## Providing additional arguments
128+
129+
The `client.eval` and `client.invoke` methods each provide a `**kwargs` argument, so you can pass in any other arguments you would
130+
normally pass to `requests`. For example:
131+
132+
```
133+
client.eval(javascript="fn.currentDateTime()", params={"database": "Documents"})
134+
client.invoke("/sample.sjs", params={"database": "Documents"})
135+
```
136+
137+
Please see [the eval endpoint documentation](https://docs.marklogic.com/REST/POST/v1/eval)
138+
and [the invoke endpoint documentation](https://docs.marklogic.com/REST/POST/v1/invoke) for
139+
information on additional parameters.

docs/managing-documents/reading.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ The [GET /v1/documents](https://docs.marklogic.com/REST/GET/v1/documents) endpoi
1010
reading multiple documents with metadata via a multipart/mixed HTTP response. The MarkLogic Python client simplifies
1111
handling the response by converting it into a list of `Document` instances via the `client.documents.read` method.
1212

13+
## Table of contents
14+
{: .no_toc .text-delta }
15+
16+
- TOC
17+
{:toc}
18+
1319
## Setup for examples
1420

1521
The examples below all assume that you have created a new MarkLogic user named "python-user" as described in the

docs/managing-documents/searching.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ returning content and metadata for each matching document. Similar to reading mu
1212
HTTP response. The MarkLogic Python client simplifies use of this operation by returning a list of `Document` instances
1313
via the `client.documents.search` method.
1414

15+
## Table of contents
16+
{: .no_toc .text-delta }
17+
18+
- TOC
19+
{:toc}
20+
1521
## Setup for examples
1622

1723
The examples below all assume that you have created a new MarkLogic user named "python-user" as described in the

docs/managing-documents/writing.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ writing multiple documents with metadata via a multipart HTTP request. The MarkL
1111
simplifies the use of this endpoint via the `client.documents.write` method and the `Document`
1212
class.
1313

14+
## Table of contents
15+
{: .no_toc .text-delta }
16+
17+
- TOC
18+
{:toc}
19+
20+
## Setup
21+
1422
The examples below all assume that you have created a new MarkLogic user named "python-user" as described in the
1523
[setup guide](../example-setup.md). In addition, each of the examples below requires the following `Client` instance to be created
1624
first:

docs/rows.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ The [MarkLogic REST rows service](https://docs.marklogic.com/REST/client/row-man
99
operations for querying for rows via several query languages. The MarkLogic Python client simplifies submitting queries
1010
for rows and converting responses into useful data structures.
1111

12+
## Table of contents
13+
{: .no_toc .text-delta }
14+
15+
- TOC
16+
{:toc}
17+
1218
## Setup
1319

1420
The examples below require documents to be loaded along with a
@@ -178,4 +184,18 @@ Printing the `df` object will yield the following:
178184
1 Davis Miles 1926-05-26
179185
2 Armstrong Louis 1901-08-04
180186
3 Coltrane John 1926-09-23
181-
```
187+
```
188+
189+
## Providing additional arguments
190+
191+
The `client.rows.query` method provides a `**kwargs` argument, so you can pass in any other arguments you would
192+
normally pass to `requests`. For example:
193+
194+
```
195+
response = client.rows.query("op.fromView('example', 'musician')", params={"database": "Documents"})
196+
```
197+
198+
Please see [the rows endpoint documentation](https://docs.marklogic.com/REST/POST/v1/rows) for
199+
information on additional parameters. If you are submitting a GraphQL query, then see
200+
[the GraphQL endpoint documentation](https://docs.marklogic.com/REST/POST/v1/rows/graphql) for
201+
information on parameters for that endpoint.

docs/transactions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ via a `Transaction` class that is also a
1313
thereby allowing it to handle committing or rolling back the transaction without any user
1414
involvement.
1515

16+
## Table of contents
17+
{: .no_toc .text-delta }
18+
19+
- TOC
20+
{:toc}
21+
22+
## Using a transaction
23+
1624
The following example demonstrates writing documents via multiple calls to MarkLogic,
1725
all within the same REST API transaction; the example depends on first following the
1826
instructions in the [setup guide](example-setup.md):

0 commit comments

Comments
 (0)