Skip to content

Commit eeda669

Browse files
authored
Merge pull request #51 from marklogic/feature/doc-fixes
Various small doc improvements
2 parents d07a218 + 452e2a0 commit eeda669

File tree

9 files changed

+66
-31
lines changed

9 files changed

+66
-31
lines changed

docs/eval.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
layout: default
33
title: Executing code
4-
nav_order: 5
4+
nav_order: 7
55
---
66

77
The [MarkLogic REST service extension](https://docs.marklogic.com/REST/client/service-extension) supports the
88
execution of custom code, whether via an inline script or an existing module in your application's modules database.
9-
The MarkLogic Python client simplifies execution of custom code both by managing some of the complexity of submitting
10-
and custom code and also converting the multipart response into more useful Python data types.
9+
The MarkLogic Python client supports execution of custom code by simplifying the submission of custom code
10+
and converting the multipart response into more useful Python data types.
1111

1212
## Setup
1313

@@ -26,14 +26,14 @@ The [v1/eval REST endpoint](https://docs.marklogic.com/REST/POST/v1/eval) suppor
2626
and XQuery queries. Each type of query can be easily submitted via the client:
2727

2828
```
29-
client.eval.javascript("fn.currentDateTime()")
30-
client.eval.xquery("fn:current-dateTime()")
29+
client.eval(javascript="fn.currentDateTime()")
30+
client.eval(xquery="fn:current-dateTime()")
3131
```
3232

3333
Variables can optionally be provided via a `dict`:
3434

3535
```
36-
results = client.eval.javascript('Sequence.from([{"hello": myValue}])', vars={"myValue": "world"})
36+
results = client.eval(javascript='Sequence.from([{"hello": myValue}])', vars={"myValue": "world"})
3737
assert "world" == results[0]["hello"]
3838
```
3939

@@ -48,9 +48,16 @@ and XQuery main modules that have been deployed to your application's modules da
4848
the client in the following manner:
4949

5050
```
51+
# Set the input to the URI of the module you wish to invoke in your application's
52+
# modules database.
5153
client.invoke("/path/to/module.sjs")
5254
```
5355

56+
You can provide variables to your module in the same fashion as when evaluating custom code:
57+
58+
```
59+
client.invoke("/path/to/module.sjs", vars={"my_var1": "value1"})
60+
```
5461

5562
## Conversion of data types
5663

@@ -59,15 +66,15 @@ value having MarkLogic-specific type information. The client will use this type
5966
an appropriate Python data type. For example, each JSON object into the example below is converted into a `dict`:
6067

6168
```
62-
results = client.eval.javascript('Sequence.from([{"doc": 1}, {"doc": 2}])')
69+
results = client.eval(javascript='Sequence.from([{"doc": 1}, {"doc": 2}])')
6370
assert len(results) == 2
6471
assert results[0]["doc"] == 1
6572
assert results[1]["doc"] == 2
6673
```
6774

6875
The following table describes how each MarkLogic type is associated with a Python data type. For any
69-
MarkLogic type not listed in the table, such as `hexBinary` and `base64Binary`, the value is not converted and will be
70-
of type `bytes`.
76+
MarkLogic type not listed in the table, such as `hexBinary` and `base64Binary`, the value is not converted and will
77+
remain of type `bytes`.
7178

7279
| MarkLogic type | Python type |
7380
| --- | --- |
@@ -92,3 +99,9 @@ the multipart `X-URI` header. Otherwise, a value of type `dict`, `str`, or `byte
9299
Each `client.eval` method and `client.invoke` accept a `return_response` argument. When that
93100
argument is set to `True`, the original response is returned. This can be useful for custom
94101
processing of the response or debugging requests.
102+
103+
## Referencing a transaction
104+
105+
The `client.eval` and `client.invoke` functions both support referencing a
106+
[REST API transaction](https://docs.marklogic.com/REST/client/transaction-management) via the `tx`
107+
argument. See [the guide on transactions](transactions.md) for further information.

docs/example-setup.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ Then perform the following steps to create a new role:
1313

1414
1. Click on "Roles" in the "Security" box.
1515
2. Click on "Create".
16-
3. In the form, enter "python-docs-role" for "Role Name".
17-
4. Scroll down and select the "rest-extension-user", "rest-reader", "rest-writer", and "tde-admin" roles.
18-
5. Scroll further down and select the "xdbc:eval", "xdbc:invoke", and "xdmp:eval-in" privileges.
16+
3. In the form, enter `python-docs-role` for "Role Name".
17+
4. Scroll down and select the `rest-extension-user`, `rest-reader`, `rest-writer`, and `tde-admin` roles.
18+
5. Scroll further down and select the `xdbc:eval`, `xdbc:invoke`, and `xdmp:eval-in` privileges.
1919
6. Scroll to the top or bottom and click on "OK" to create the role.
2020

2121
After creating the role, return to the Admin application home page and perform the following steps:
2222

2323
1. Click on "Users" in the "Security" box.
2424
2. Click on "Create".
25-
3. In the form, enter "python-user" for "User Name" and "pyth0n" as the password.
26-
4. Scroll down until you see the "Roles" section and select the "python-docs-role" role.
25+
3. In the form, enter `python-user` for "User Name" and `pyth0n` as the password.
26+
4. Scroll down until you see the "Roles" section and select the `python-docs-role` role.
2727
5. Scroll to the top or bottom and click on "OK" to create the user.
2828

2929
(Note that you could use the `admin` role instead to grant full access to all features in MarkLogic, but this is

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ If you wish to try these examples on your own installation of MarkLogic, please
3131
for instructions on creating this user.
3232

3333
Otherwise, please see the [guide on creating a client](creating-client.md) for more information on connecting to a
34-
MarkLogic REST API instance. The [guide on managing documents](managing-documents/managing-documents.md) provides
35-
more information on how the client simplifies writing and reading multiple documents in a single request.
34+
MarkLogic REST API instance. Then choose a guide from the navigation on the left to see how the client can simplify
35+
your application's interactions with the MarkLogic REST API.
3636

docs/managing-documents/managing-documents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: default
33
title: Managing documents
4-
nav_order: 3
4+
nav_order: 4
55
has_children: true
66
permalink: /documents
77
---

docs/managing-documents/reading.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ for more information on reading documents.
116116

117117
## Returning the original HTTP response
118118

119-
The `client.documents.read` method also accepts a `return_response` argument. When that
120-
argument is set to `True`, the original response is returned. This can be useful for custom
121-
processing of the response or debugging requests.
119+
Starting in the 1.1.0 release, the `client.documents.search` method accepts a
120+
`return_response` argument. When that argument is set to `True`, the original response
121+
is returned. This can be useful for custom processing of the response or debugging requests.
122+
123+
## Referencing a transaction
124+
125+
Starting in the 1.1.0 release, you can reference a
126+
[REST API transaction](https://docs.marklogic.com/REST/client/transaction-management) via the `tx`
127+
argument. See [the guide on transactions](../transactions.md) for further information.
122128

123129
## Error handling
124130

docs/managing-documents/searching.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,15 @@ for more information on searching documents.
157157

158158
## Returning the original HTTP response
159159

160-
The `client.documents.search` method also accepts a `return_response` argument. When
161-
that argument is set to `True`, the original response is returned. This can be useful for
162-
custom processing of the response or debugging requests.
160+
Starting in the 1.1.0 release, the `client.documents.search` method accepts a
161+
`return_response` argument. When that argument is set to `True`, the original response
162+
is returned. This can be useful for custom processing of the response or debugging requests.
163+
164+
## Referencing a transaction
165+
166+
Starting in the 1.1.0 release, you can reference a
167+
[REST API transaction](https://docs.marklogic.com/REST/client/transaction-management) via the `tx`
168+
argument. See [the guide on transactions](../transactions.md) for further information.
163169

164170
## Error handling
165171

docs/managing-documents/writing.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ response = client.documents.write(Document("/doc1.json", {"doc": 1}, permissions
150150
Please see [the application developer's guide](https://docs.marklogic.com/guide/rest-dev/documents#id_11953) for
151151
more information on writing documents.
152152

153+
## Referencing a transaction
154+
155+
Starting in the 1.1.0 release, you can reference a
156+
[REST API transaction](https://docs.marklogic.com/REST/client/transaction-management) via the `tx`
157+
argument. See [the guide on transactions](../transactions.md) for further information.
158+
159+
153160
## Error handling
154161

155162
Because the `client.documents.write` method returns a `requests Response` object, any error that occurs during

docs/rows.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
layout: default
33
title: Querying for rows
4-
nav_order: 4
4+
nav_order: 6
55
---
66

77

88
The [MarkLogic REST rows service](https://docs.marklogic.com/REST/client/row-management) supports
9-
operations for querying for rows via a variety of languages. The MarkLogic Python client simplifies submitting queries
10-
for rows and converting the response into a useful data structure.
9+
operations for querying for rows via several query languages. The MarkLogic Python client simplifies submitting queries
10+
for rows and converting responses into useful data structures.
1111

1212
## Setup
1313

@@ -85,16 +85,17 @@ You can use a named argument as well:
8585
client.rows.query(dsl="op.fromView('example', 'musician')")
8686
```
8787

88-
For some use cases, it may be helpful to capture an Optic query in its serialized form. Such a query can then be
89-
submitted via the `plan` argument:
88+
For some use cases, it may be helpful to capture an Optic query
89+
[as a serialized plan](https://docs.marklogic.com/guide/app-dev/OpticAPI#id_11208).
90+
A serialized plan can then be submitted via the `plan` argument:
9091

9192
```
9293
plan = '{"$optic":{"ns":"op", "fn":"operators", "args":[{"ns":"op", "fn":"from-view", "args":["example", "musician"]}]}}'
9394
client.rows.query(plan=plan)
9495
```
9596

9697
Optic supports many different types of queries and operations; please
97-
[see the documentation]((https://docs.marklogic.com/guide/app-dev/OpticAPI#id_35559)) for further information on
98+
[see the documentation](https://docs.marklogic.com/guide/app-dev/OpticAPI#id_35559) for further information on
9899
much more powerful and flexible queries than shown in these examples, which are intended solely for demonstration of
99100
how to submit an Optic query.
100101

docs/transactions.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: default
33
title: Managing transactions
4-
nav_order: 6
4+
nav_order: 5
55
---
66

77
The [MarkLogic REST transactions service](https://docs.marklogic.com/REST/client/transaction-management)
@@ -76,7 +76,9 @@ with client.transactions.create() as tx:
7676

7777
## Getting transaction status
7878

79-
You can get the status of the transaction via the `get_status()` function:
79+
You can get the
80+
[status of the transaction](https://docs.marklogic.com/REST/GET/v1/transactions/[txid])
81+
via the `get_status()` function:
8082

8183
```
8284
with client.transactions.create() as tx:

0 commit comments

Comments
 (0)