Skip to content

Commit d1e070d

Browse files
DOCSP-22882 Python Quick Start + Tutorials (#1206)
* add python sample apps * add python to quick start * add python to aws tut * add python to azure tut * add python gcp * add kv step * move comment * query on encrypted field * snake case + move var assignment * missing + char in source constant * add local key file comments
1 parent 830990d commit d1e070d

37 files changed

+1491
-9
lines changed

source/core/queryable-encryption/quick-start.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ Before You Get Started
5959

6060
`Complete Node.js Application <{+sample-app-url-qe+}node-fle-2/local/reader/>`__
6161

62+
.. tab:: Python
63+
:tabid: python
64+
65+
`Complete Python Application <{+sample-app-url-qe+}python-fle-2/local/reader/>`__
66+
6267

6368
.. tabs-selector:: drivers
6469

@@ -90,6 +95,12 @@ Procedure
9095
To view the complete code for making a {+dek-long+}, see
9196
`our Github repository <{+sample-app-url-qe+}node-fle-2/local/reader/make_data_key.js>`__.
9297

98+
.. tab::
99+
:tabid: python
100+
101+
To view the complete code for making a {+dek-long+}, see
102+
`our Github repository <{+sample-app-url-qe+}python-fle-2/local/reader/make_data_key.py>`__.
103+
93104
.. step:: Configure your MongoClient for Encrypted Reads and Writes
94105

95106
.. include:: /includes/queryable-encryption/quick-start/client.rst
@@ -108,6 +119,13 @@ Procedure
108119
To view the complete code for inserting an encrypted document, see
109120
`our Github repository <{+sample-app-url-qe+}node-fle-2/local/reader/insert_encrypted_document.js>`__.
110121

122+
.. tab::
123+
:tabid: python
124+
125+
To view the complete code for inserting an encrypted document, see
126+
`our Github repository <{+sample-app-url-qe+}python-fle-2/local/reader/insert_encrypted_document.py>`__.
127+
128+
111129
.. step:: Retrieve Your Encrypted Document
112130

113131
.. include:: /includes/queryable-encryption/quick-start/find.rst
@@ -122,6 +140,12 @@ Procedure
122140
To view the complete code for finding an encrypted document, see
123141
`our Github repository <{+sample-app-url-qe+}node-fle-2/local/reader/insert_encrypted_document.js>`__.
124142

143+
.. tab::
144+
:tabid: python
145+
146+
To view the complete code for finding an encrypted document, see
147+
`our Github repository <{+sample-app-url-qe+}python-fle-2/local/reader/insert_encrypted_document.py>`__.
148+
125149

126150
Learn More
127151
----------

source/core/queryable-encryption/tutorials/aws/aws-automatic.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ Before You Get Started
4242

4343
`Complete Node.js Application <{+sample-app-url-qe+}node-fle-2/aws/reader/>`__
4444

45+
.. tab:: Python
46+
:tabid: python
47+
48+
`Complete Python Application <{+sample-app-url-qe+}python-fle-2/aws/reader/>`__
49+
4550
.. tabs-selector:: drivers
4651

4752
Set Up the KMS
@@ -83,6 +88,12 @@ Create the Application
8388
To view the complete code for making a {+dek-long+}, see
8489
`our Github repository <{+sample-app-url-qe+}node-fle-2/aws/reader/make_data_key.js>`__.
8590

91+
.. tab::
92+
:tabid: python
93+
94+
To view the complete code for making a {+dek-long+}, see
95+
`our Github repository <{+sample-app-url-qe+}python-fle-2/aws/reader/make_data_key.py>`__.
96+
8697
.. step:: Configure your MongoClient for Encrypted Reads and Writes
8798

8899
.. include:: /includes/queryable-encryption/tutorials/automatic/aws/client.rst
@@ -101,6 +112,12 @@ Create the Application
101112
To view the complete code for inserting an encrypted document, see
102113
`our Github repository <{+sample-app-url-qe+}node-fle-2/aws/reader/insert_encrypted_document.js>`__.
103114

115+
.. tab::
116+
:tabid: python
117+
118+
To view the complete code for inserting an encrypted document, see
119+
`our Github repository <{+sample-app-url-qe+}python-fle-2/aws/reader/insert_encrypted_document.py>`__.
120+
104121
.. step:: Retrieve Your Encrypted Document
105122

106123
.. include:: /includes/queryable-encryption/tutorials/automatic/aws/find.rst
@@ -115,6 +132,11 @@ Create the Application
115132
To view the complete code for finding an encrypted document, see
116133
`our Github repository <{+sample-app-url-qe+}node-fle-2/aws/reader/insert_encrypted_document.js>`__.
117134

135+
.. tab::
136+
:tabid: python
137+
138+
To view the complete code for finding an encrypted document, see
139+
`our Github repository <{+sample-app-url-qe+}python-fle-2/aws/reader/insert_encrypted_document.py>`__.
118140

119141
Learn More
120142
----------

source/core/queryable-encryption/tutorials/azure/azure-automatic.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ Before You Get Started
4242

4343
`Complete Node.js Application <{+sample-app-url-qe+}node-fle-2/azure/reader/>`__
4444

45+
.. tab:: Python
46+
:tabid: python
47+
48+
`Complete Python Application <{+sample-app-url-qe+}python-fle-2/azure/reader/>`__
49+
4550
.. tabs-selector:: drivers
4651

4752
Set Up the KMS
@@ -82,6 +87,12 @@ Create the Application
8287
To view the complete code for making a {+dek-long+}, see
8388
`our Github repository <{+sample-app-url-qe+}node-fle-2/azure/reader/make_data_key.js>`__.
8489

90+
.. tab::
91+
:tabid: python
92+
93+
To view the complete code for making a {+dek-long+}, see
94+
`our Github repository <{+sample-app-url-qe+}python-fle-2/azure/reader/make_data_key.py>`__.
95+
8596
.. step:: Configure your MongoClient for Encrypted Reads and Writes
8697

8798
.. include:: /includes/queryable-encryption/tutorials/automatic/azure/client.rst
@@ -100,6 +111,12 @@ Create the Application
100111
To view the complete code for inserting an encrypted document, see
101112
`our Github repository <{+sample-app-url-qe+}node-fle-2/azure/reader/insert_encrypted_document.js>`__.
102113

114+
.. tab::
115+
:tabid: python
116+
117+
To view the complete code for inserting an encrypted document, see
118+
`our Github repository <{+sample-app-url-qe+}python-fle-2/azure/reader/insert_encrypted_document.py>`__.
119+
103120
.. step:: Retrieve Your Encrypted Document
104121

105122
.. include:: /includes/queryable-encryption/tutorials/automatic/azure/find.rst
@@ -114,6 +131,12 @@ Create the Application
114131
To view the complete code for finding an encrypted document, see
115132
`our Github repository <{+sample-app-url-qe+}node-fle-2/azure/reader/insert_encrypted_document.js>`__.
116133

134+
.. tab::
135+
:tabid: python
136+
137+
To view the complete code for finding an encrypted document, see
138+
`our Github repository <{+sample-app-url-qe+}python-fle-2/azure/reader/insert_encrypted_document.py>`__.
139+
117140
Learn More
118141
----------
119142

source/core/queryable-encryption/tutorials/gcp/gcp-automatic.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ Before You Get Started
4141

4242
`Complete Node.js Application <{+sample-app-url-qe+}node-fle-2/gcp/reader/>`__
4343

44+
.. tab:: Python
45+
:tabid: python
46+
47+
`Complete Python Application <{+sample-app-url-qe+}python-fle-2/gcp/reader/>`__
48+
4449
.. tabs-selector:: drivers
4550

4651
Set Up the KMS
@@ -85,6 +90,12 @@ your application to see relevant code samples.
8590
To view the complete code for making a {+dek-long+}, see
8691
`our Github repository <{+sample-app-url-qe+}node-fle-2/gcp/reader/make_data_key.js>`__.
8792

93+
.. tab::
94+
:tabid: python
95+
96+
To view the complete code for making a {+dek-long+}, see
97+
`our Github repository <{+sample-app-url-qe+}python-fle-2/gcp/reader/make_data_key.py>`__.
98+
8899
.. step:: Configure your MongoClient for Encrypted Reads and Writes
89100

90101
.. include:: /includes/queryable-encryption/tutorials/automatic/gcp/client.rst
@@ -103,6 +114,12 @@ your application to see relevant code samples.
103114
To view the complete code for inserting an encrypted document, see
104115
`our Github repository <{+sample-app-url-qe+}node-fle-2/gcp/reader/insert_encrypted_document.js>`__.
105116

117+
.. tab::
118+
:tabid: python
119+
120+
To view the complete code for inserting an encrypted document, see
121+
`our Github repository <{+sample-app-url-qe+}python-fle-2/gcp/reader/insert_encrypted_document.py>`__.
122+
106123
.. step:: Retrieve Your Encrypted Document
107124

108125
.. include:: /includes/queryable-encryption/tutorials/automatic/gcp/find.rst
@@ -117,6 +134,12 @@ your application to see relevant code samples.
117134
To view the complete code for finding an encrypted document, see
118135
`our Github repository <{+sample-app-url-qe+}node-fle-2/gcp/reader/insert_encrypted_document.js>`__.
119136

137+
.. tab::
138+
:tabid: python
139+
140+
To view the complete code for finding an encrypted document, see
141+
`our Github repository <{+sample-app-url-qe+}python-fle-2/gcp/reader/insert_encrypted_document.py>`__.
142+
120143

121144
Learn More
122145
----------

source/includes/queryable-encryption/quick-start/client.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
:dedent:
2121
:caption: insert_encrypted_document.js
2222

23+
.. tab::
24+
:tabid: python
25+
26+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/insert_encrypted_document.py
27+
:start-after: start-key-vault
28+
:end-before: end-key-vault
29+
:language: python
30+
:dedent:
31+
:caption: insert_encrypted_document.py
32+
33+
2334
.. step:: Specify the Local {+cmk-long+}
2435

2536
Specify the KMS provider and specify your key inline:
@@ -36,6 +47,15 @@
3647
:dedent:
3748
:caption: insert_encrypted_document.js
3849

50+
.. tab::
51+
:tabid: python
52+
53+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/insert_encrypted_document.py
54+
:start-after: start-kmsproviders
55+
:end-before: end-kmsproviders
56+
:language: python
57+
:dedent:
58+
:caption: insert_encrypted_document.py
3959

4060
.. step:: Create an {+enc-fields-map-title+} For Your Collection
4161

@@ -53,6 +73,15 @@
5373
:dedent:
5474
:caption: insert_encrypted_document.js
5575

76+
.. tab::
77+
:tabid: python
78+
79+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/insert_encrypted_document.py
80+
:start-after: start-schema
81+
:end-before: end-schema
82+
:language: python
83+
:dedent:
84+
:caption: insert_encrypted_document.py
5685

5786
.. step:: Specify the Location of the {+shared-library+}
5887

@@ -70,6 +99,16 @@
7099
:caption: insert_encrypted_document.js
71100
:dedent:
72101

102+
.. tab::
103+
:tabid: python
104+
105+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/insert_encrypted_document.py
106+
:start-after: start-extra-options
107+
:end-before: end-extra-options
108+
:language: python
109+
:dedent:
110+
:caption: insert_encrypted_document.py
111+
73112
.. include:: /includes/queryable-encryption/shared-lib-learn-more.rst
74113

75114
.. step:: Create the MongoClient
@@ -88,3 +127,13 @@
88127
:language: javascript
89128
:dedent:
90129
:caption: insert_encrypted_document.js
130+
131+
.. tab::
132+
:tabid: python
133+
134+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/insert_encrypted_document.py
135+
:start-after: start-client
136+
:end-before: end-client
137+
:language: python
138+
:dedent:
139+
:caption: insert_encrypted_document.py

source/includes/queryable-encryption/quick-start/dek.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
:language: javascript
2828
:dedent:
2929

30+
.. tab::
31+
:tabid: python
32+
33+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/make_data_key.py
34+
:start-after: start-kmsproviders
35+
:end-before: end-kmsproviders
36+
:language: python
37+
:dedent:
38+
:caption: make_data_key.py
39+
40+
3041
.. step:: Create your {+dek-long+}s
3142

3243
.. _qe-local-create-dek:
@@ -55,6 +66,16 @@
5566
:dedent:
5667
:caption: make_data_key.js
5768

69+
.. tab::
70+
:tabid: python
71+
72+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/make_data_key.py
73+
:start-after: start-create-dek
74+
:end-before: end-create-dek
75+
:language: python
76+
:dedent:
77+
:caption: make_data_key.py
78+
5879
.. step:: Create Your Encrypted Collection
5980

6081
Use a {+qe+} enabled ``MongoClient`` instance to specify what
@@ -72,6 +93,16 @@
7293
:dedent:
7394
:caption: make_data_key.js
7495

96+
.. tab::
97+
:tabid: python
98+
99+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/make_data_key.py
100+
:start-after: start-create-enc-collection
101+
:end-before: end-create-enc-collection
102+
:language: python
103+
:dedent:
104+
:caption: make_data_key.py
105+
75106
The output from the code in this section should resemble the following:
76107

77108
.. literalinclude:: /includes/queryable-encryption/quick-start/dek-output.out

source/includes/queryable-encryption/quick-start/find.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ a client that is not configured for automatic {+qe+}.
1818
:language: javascript
1919
:dedent:
2020

21+
.. tab::
22+
:tabid: python
23+
24+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/insert_encrypted_document.py
25+
:start-after: start-find
26+
:end-before: end-find
27+
:language: python
28+
:dedent:
29+
:caption: insert_encrypted_document.py
30+
2131
The output of the preceding code snippet should look like this:
2232

2333
.. literalinclude:: /includes/queryable-encryption/quick-start/find-output.out

source/includes/queryable-encryption/quick-start/insert.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ snippet:
1717
:dedent:
1818
:caption: insert_encrypted_document.js
1919

20+
.. tab::
21+
:tabid: python
22+
23+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/insert_encrypted_document.py
24+
:start-after: start-insert
25+
:end-before: end-insert
26+
:language: python
27+
:dedent:
28+
:caption: insert_encrypted_document.py
29+
2030
When you insert a document, your {+qe+} enabled client
2131
encrypts the fields of your document such that it resembles the following:
2232

source/includes/queryable-encryption/quick-start/key-vault-index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ Create a unique index on the ``keyAltNames`` field in your
1414
:caption: make_data_key.js
1515
:language: javascript
1616
:dedent:
17+
18+
.. tab::
19+
:tabid: python
20+
21+
.. literalinclude:: /includes/queryable-encryption/sample_apps/build/python-fle-2/local/reader/make_data_key.py
22+
:start-after: start-create-index
23+
:end-before: end-create-index
24+
:language: python
25+
:dedent:
26+
:caption: make_data_key.py
27+

0 commit comments

Comments
 (0)