Skip to content

Commit 0ef384b

Browse files
fix(generated): update partitioned database examples (#720)
Generated SDK source code using: - Generator version 3.96.0 - Specification version 1.0.0-dev0.1.18 - Automation (cloudant-sdks) version 30afc34
1 parent ff3ac6e commit 0ef384b

File tree

29 files changed

+183
-140
lines changed

29 files changed

+183
-140
lines changed

examples/README.md

+96-70
Large diffs are not rendered by default.

examples/snippets/deleteAttachment/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
response = service.delete_attachment(
77
db='products',
8-
doc_id='small-appliances:100001',
8+
doc_id='1000042',
99
attachment_name='product_details.txt',
1010
rev='4-1a0d1cd6f40472509e9aac646183736a'
1111
).get_result()
1212

1313
print(response)
1414
# section: markdown
15-
# This example requires the `product_details.txt` attachment in `small-appliances:100001` document to exist. To create the attachment, see [Create or modify an attachment.](#putattachment)
15+
# This example requires the `product_details.txt` attachment in `1000042` document to exist. To create the attachment, see [Create or modify an attachment.](#putattachment)

examples/snippets/deleteDocument/example_request.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
service = CloudantV1.new_instance()
55

66
response = service.delete_document(
7-
db='events',
8-
doc_id='0007241142412418284',
9-
rev='2-9a0d1cd9f40472509e9aac6461837367'
7+
db='orders',
8+
doc_id='order00058',
9+
rev='1-99b02e08da151943c2dcb40090160bb8'
1010
).get_result()
1111

1212
print(response)

examples/snippets/getAttachment/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
response_attachment = service.get_attachment(
77
db='products',
8-
doc_id='small-appliances:100001',
8+
doc_id='1000042',
99
attachment_name='product_details.txt'
1010
).get_result().content
1111

1212
print(response_attachment)
1313
# section: markdown
14-
# This example requires the `product_details.txt` attachment in `small-appliances:100001` document to exist. To create the attachment, see [Create or modify an attachment.](#putattachment)
14+
# This example requires the `product_details.txt` attachment in `1000042` document to exist. To create the attachment, see [Create or modify an attachment.](#putattachment)

examples/snippets/getDocument/example_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
response = service.get_document(
77
db='products',
8-
doc_id='small-appliances:1000042'
8+
doc_id='1000042'
99
).get_result()
1010

1111
print(response)

examples/snippets/getDocumentShardsInfo/example_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
response = service.get_document_shards_info(
77
db='products',
8-
doc_id='small-appliances:1000042'
8+
doc_id='1000042'
99
).get_result()
1010

1111
print(response)

examples/snippets/getPartitionInformation/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
service = CloudantV1.new_instance()
55

66
response = service.get_partition_information(
7-
db='products',
8-
partition_key='small-appliances'
7+
db='events',
8+
partition_key='ns1HJS13AMkK'
99
).get_result()
1010

1111
print(response)

examples/snippets/getSearchInfo/example_request.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
service = CloudantV1.new_instance()
55

66
response = service.get_search_info(
7-
db='products',
8-
ddoc='appliances',
9-
index='findByPrice'
7+
db='events',
8+
ddoc='checkout',
9+
index='findByDate'
1010
).get_result()
1111

1212
print(response)
1313
# section: markdown
14-
# This example requires the `findByPrice` Cloudant Search partitioned index to exist. To create the design document with this index, see [Create or modify a design document.](#putdesigndocument)
14+
# This example requires the `findByDate` Cloudant Search partitioned index to exist. To create the design document with this index, see [Create or modify a design document.](#putdesigndocument)

examples/snippets/headAttachment/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
response = service.head_attachment(
77
db='products',
8-
doc_id='small-appliances:100001',
8+
doc_id='1000042',
99
attachment_name='product_details.txt'
1010
)
1111
print(response.get_status_code())
1212
print(response.get_headers()['Content-Length'])
1313
print(response.get_headers()['Content-Type'])
1414
# section: markdown
15-
# This example requires the `product_details.txt` attachment in `small-appliances:100001` document to exist. To create the attachment, see [Create or modify an attachment.](#putattachment)
15+
# This example requires the `product_details.txt` attachment in `1000042` document to exist. To create the attachment, see [Create or modify an attachment.](#putattachment)

examples/snippets/headDesignDocument/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
service = CloudantV1.new_instance()
55

66
response = service.head_design_document(
7-
db='products',
8-
ddoc='appliances'
7+
db='events',
8+
ddoc='checkout'
99
)
1010
print(response.get_status_code())
1111
print(response.get_headers()['ETag'])

examples/snippets/headDocument/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
service = CloudantV1.new_instance()
55

66
response = service.head_document(
7-
db='events',
8-
doc_id='0007241142412418284'
7+
db='orders',
8+
doc_id='order00058'
99
)
1010
print(response.get_status_code())
1111
print(response.get_headers()['ETag'])

examples/snippets/postAllDocsQueries/example_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
service = CloudantV1.new_instance()
55

66
all_docs_query1 = AllDocsQuery(
7-
keys=['small-appliances:1000042', 'small-appliances:1000043']
7+
keys=['1000042', '1000043']
88
)
99

1010
all_docs_query2 = AllDocsQuery(

examples/snippets/postBulkDocs/example_request_as_a_stream.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
{
1717
"docs": [
1818
{
19-
"_id": "0007241142412418284",
19+
"_id": "ns1HJS13AMkK:0007241142412418284",
2020
"type": "event",
21-
"userid": "abc123",
21+
"userId": "abc123",
2222
"eventType": "addedToBasket",
2323
"productId": "1000042",
2424
"date": "2019-01-28T10:44:22.000Z"
2525
},
2626
{
27-
"_id": "0007241142412418285",
27+
"_id": "H8tDIwfadxp9:0007241142412418285",
2828
"type": "event",
29-
"userid": "abc123",
29+
"userId": "abc234",
3030
"eventType": "addedToBasket",
3131
"productId": "1000050",
3232
"date": "2019-01-25T20:00:00.000Z"

examples/snippets/postBulkDocs/example_request_create_documents.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
service = CloudantV1.new_instance()
55

66
event_doc_1 = Document(
7-
_id="0007241142412418284",
7+
_id="ns1HJS13AMkK:0007241142412418284",
88
type="event",
9-
userid="abc123",
9+
userId="abc123",
1010
eventType="addedToBasket",
1111
productId="1000042",
1212
date="2019-01-28T10:44:22.000Z"
1313
)
1414
event_doc_2 = Document(
15-
_id="0007241142412418285",
15+
_id="H8tDIwfadxp9:0007241142412418285",
1616
type="event",
17-
userid="abc234",
17+
userId="abc234",
1818
eventType="addedToBasket",
1919
productId="1000050",
2020
date="2019-01-25T20:00:00.000Z"

examples/snippets/postBulkDocs/example_request_delete_documents.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
service = CloudantV1.new_instance()
55

66
event_doc_1 = Document(
7-
_id="0007241142412418284",
7+
_id="ns1HJS13AMkK:0007241142412418284",
88
_rev="1-5005d65514fe9e90f8eccf174af5dd64",
99
_deleted=True,
1010
)
1111
event_doc_2 = Document(
12-
_id="0007241142412418285",
12+
_id="H8tDIwfadxp9:0007241142412418285",
1313
_rev="1-2d7810b054babeda4812b3924428d6d6",
1414
_deleted=True,
1515
)

examples/snippets/postDocument/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
service = CloudantV1.new_instance()
55

66
products_doc = Document(
7-
_id="small-appliances:1000042",
7+
_id="1000042",
88
type="product",
9-
productid="1000042",
9+
productId="1000042",
1010
brand="Salter",
1111
name="Digital Kitchen Scales",
1212
description="Slim Colourful Design Electronic Cooking Appliance for Home / Kitchen, Weigh up to 5kg + Aquatronic for Liquids ml + fl. oz. 15Yr Guarantee - Green",

examples/snippets/postFind/example_request_for_json_index_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
).get_result()
1313
print(response)
1414
# section: markdown
15-
# This example requires the `getUserByAddress` Cloudant Query "json" index to exist. To create the index, see [Create a new index on a database.](#postindex)
15+
# This example requires the `getUserByEmail` Cloudant Query "json" index to exist. To create the index, see [Create a new index on a database.](#postindex)

examples/snippets/postFind/example_request_for_text_index_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
).get_result()
1212
print(response)
1313
# section: markdown
14-
# This example requires the `getUserByVerifiedEmail` Cloudant Query "text" index to exist. To create the index, see [Create a new index on a database.](#postindex)
14+
# This example requires the `getUserByAddress` Cloudant Query "text" index to exist. To create the index, see [Create a new index on a database.](#postindex)

examples/snippets/postPartitionAllDocs/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
service = CloudantV1.new_instance()
55

66
response = service.post_partition_all_docs(
7-
db='products',
8-
partition_key='small-appliances',
7+
db='events',
8+
partition_key='ns1HJS13AMkK',
99
include_docs=True
1010
).get_result()
1111

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# section: code
2+
from ibmcloudant.cloudant_v1 import CloudantV1
3+
4+
service = CloudantV1.new_instance()
5+
6+
response = service.post_partition_explain(
7+
db='events',
8+
execution_stats=True,
9+
limit=10,
10+
partition_key='ns1HJS13AMkK',
11+
selector={'userId': {'$eq': 'abc123'}}
12+
).get_result()
13+
14+
print(response)

examples/snippets/postPartitionFind/example_request.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
service = CloudantV1.new_instance()
55

66
response = service.post_partition_find(
7-
db='products',
8-
partition_key='small-appliances',
9-
fields=['productid', 'name', 'description'],
10-
selector={'type': {'$eq': 'product'}}
7+
db='events',
8+
partition_key='ns1HJS13AMkK',
9+
fields=['productId', 'eventType', 'date'],
10+
selector={'userId': {'$eq': 'abc123'}}
1111
).get_result()
1212

1313
print(response)

examples/snippets/postPartitionSearch/example_request.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
service = CloudantV1.new_instance()
55

66
response = service.post_partition_search(
7-
db='products',
8-
partition_key='small-appliances',
9-
ddoc='appliances',
10-
index='findByPrice',
11-
query='price:[14 TO 20]'
7+
db='events',
8+
partition_key='ns1HJS13AMkK',
9+
ddoc='checkout',
10+
index='findByDate',
11+
query='date:[2019-01-01T12:00:00.000Z TO 2019-01-31T12:00:00.000Z]'
1212
).get_result()
1313

1414
print(response)
1515
# section: markdown
16-
# This example requires the `findByPrice` Cloudant Search partitioned index to exist. To create the design document with this index, see [Create or modify a design document.](#putdesigndocument)
16+
# This example requires the `findByDate` Cloudant Search partitioned index to exist. To create the design document with this index, see [Create or modify a design document.](#putdesigndocument)

examples/snippets/postPartitionView/example_request.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
service = CloudantV1.new_instance()
55

66
response = service.post_partition_view(
7-
db='products',
8-
ddoc='appliances',
7+
db='events',
8+
ddoc='checkout',
9+
include_docs=True,
910
limit=10,
10-
partition_key='small-appliances',
11-
view='byApplianceProdId'
11+
partition_key='ns1HJS13AMkK',
12+
view='byProductId'
1213
).get_result()
1314

1415
print(response)
1516
# section: markdown
16-
# This example requires the `byApplianceProdId` partitioned view to exist. To create the design document with this view, see [Create or modify a design document.](#putdesigndocument)
17+
# This example requires the `byProductId` partitioned view to exist. To create the design document with this view, see [Create or modify a design document.](#putdesigndocument)

examples/snippets/postRevsDiff/example_request.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
).get_result()
1818

1919
print(response)
20+
// section: markdown
21+
// This example requires the example revisions in the POST body to be replaced with valid revisions.

examples/snippets/putAttachment/example_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
detailed_description = "This appliance includes..."
77
response = service.put_attachment(
88
db='products',
9-
doc_id='small-appliances:100001',
9+
doc_id='1000042',
1010
attachment_name='product_details.txt',
1111
attachment=detailed_description,
1212
content_type='text/plain'

examples/snippets/putDatabase/example_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
service = CloudantV1.new_instance()
55

6-
response = service.put_database(db='products', partitioned=True).get_result()
6+
response = service.put_database(db='events', partitioned=True).get_result()
77

88
print(response)

examples/snippets/putDesignDocument/example_request.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
service = CloudantV1.new_instance()
55

66
email_view_map_reduce = DesignDocumentViewsMapReduce(
7-
map='function(doc) { if(doc.email_verified === true){\n emit(doc.email, [doc.name, doc.email_verified, doc.joined]) }}'
7+
map='function(doc) { if(doc.email_verified === true) { emit(doc.email, [doc.name, doc.email_verified, doc.joined]); }}'
88
)
99

1010
user_index = SearchIndexDefinition(
11-
index='function (doc) { index("name", doc.name); index("active", doc.active); }',
11+
index='function(doc) { index("name", doc.name); index("active", doc.active); }',
1212
analyzer=AnalyzerConfiguration(name="standard", fields={"email": Analyzer(name="email")}))
1313

1414
design_document = DesignDocument(
@@ -27,11 +27,11 @@
2727
# Partitioned DesignDocument Example
2828

2929
product_map = DesignDocumentViewsMapReduce(
30-
map='function(doc) { emit(doc.productId, [doc.brand, doc.name, doc.description]) }'
30+
map='function(doc) { emit(doc.productId, [doc.date, doc.eventType, doc.userId]); }'
3131
)
3232

33-
price_index = SearchIndexDefinition(
34-
index='function (doc) { index("price", doc.price);}',
33+
date_index = SearchIndexDefinition(
34+
index='function(doc) { index("date", doc.date); }',
3535
analyzer=AnalyzerConfiguration(name="classic", fields={"description": Analyzer(name="english")})
3636
)
3737

@@ -40,17 +40,17 @@
4040
)
4141

4242
partitioned_design_doc = DesignDocument(
43-
views={'byApplianceProdId': product_map},
44-
indexes={'findByPrice': price_index},
43+
views={'byProductId': product_map},
44+
indexes={'findByDate': date_index},
4545
options=design_document_options
4646
)
4747

4848
response = service.put_design_document(
49-
db='products',
49+
db='events',
5050
design_document=partitioned_design_doc,
51-
ddoc='appliances'
51+
ddoc='checkout'
5252
).get_result()
5353

5454
print(response)
5555
# section: markdown
56-
# This example creates `allusers` design document in the `users` database and `appliances` design document in the partitioned `products` database.
56+
# This example creates `allusers` design document in the `users` database and `checkout` design document in the partitioned `events` database.

examples/snippets/putDocument/example_request.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
event_doc = Document(
77
type='event',
8-
userid='abc123',
8+
userId='abc123',
99
eventType='addedToBasket',
1010
productId='1000042',
1111
date='2019-01-28T10:44:22.000Z'
1212
)
1313
response = service.put_document(
1414
db='events',
15-
doc_id='0007241142412418284',
15+
doc_id='ns1HJS13AMkK:0007241142412418284',
1616
document=event_doc
1717
).get_result()
1818

0 commit comments

Comments
 (0)