Skip to content

Commit 06747ef

Browse files
committed
fixed wrong decorator guide in readme
1 parent a8854e8 commit 06747ef

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,30 @@ It provides generators and library templates for supporting multiple languages a
235235

236236
The **client-encryption-python** library provides a method you can use to integrate the OpenAPI generated client with this library:
237237
```python
238-
from client_encryption.field_level_encryption_config import FieldLevelEncryptionConfig
239238
from client_encryption.api_encryption import add_encryption_layer
240239

240+
config = {
241+
"paths": {
242+
"$": {
243+
...
244+
}
245+
},
246+
"ivFieldName": "iv",
247+
"encryptedKeyFieldName": "encryptedKey",
248+
...
249+
"oaepPaddingDigestAlgorithm": "SHA256"
250+
}
251+
241252
add_encryption_layer(api_client, config)
242253
```
254+
255+
Alternatively you can pass the configuration by a json file:
256+
```python
257+
from client_encryption.api_encryption import add_encryption_layer
258+
259+
add_encryption_layer(api_client, "path/to/my/config.json")
260+
```
261+
243262
This method will add the field level encryption in the generated OpenApi client, taking care of encrypting request and decrypting response payloads, but also of updating HTTP headers when needed, automatically, without manually calling `encrypt_payload()`/`decrypt_payload()` functions for each API request or response.
244263

245264
##### OpenAPI Generator <a name="openapi-generator"></a>
@@ -265,21 +284,17 @@ To use it:
265284
2. Import the **mastercard-client-encryption** module and the generated swagger ApiClient
266285

267286
```python
268-
from client_encryption.field_level_encryption_config import FieldLevelEncryptionConfig
269287
from client_encryption.api_encryption import add_encryption_layer
270288
from swagger_client.api_client import ApiClient # import generated swagger ApiClient
271289
```
272290

273291
3. Add the field level encryption layer to the generated client:
274292

275293
```python
276-
# Read the service configuration file
277-
config_file_path = "./config.json"
278-
config = FieldLevelEncryptionConfig(config_file_path)
279294
# Create a new instance of the generated client
280295
api_client = ApiClient()
281296
# Enable field level encryption
282-
add_encryption_layer(api_client, config)
297+
add_encryption_layer(api_client, "path/to/my/config.json")
283298
```
284299

285300
4. Use the `ApiClient` instance with the Field Level Encryption enabled:
@@ -308,7 +323,6 @@ According to the above the signing layer must be applied first in order to work
308323

309324
```python
310325
from oauth1.signer_interceptor import add_signing_layer
311-
from client_encryption.field_level_encryption_config import FieldLevelEncryptionConfig
312326
from client_encryption.api_encryption import add_encryption_layer
313327
from swagger_client.api_client import ApiClient # import generated swagger ApiClient
314328
```
@@ -324,12 +338,7 @@ According to the above the signing layer must be applied first in order to work
324338
325339
4. Then add the field level encryption layer:
326340
```python
327-
# Read the service configuration file
328-
config_file_path = "./config.json"
329-
config = FieldLevelEncryptionConfig(config_file_path)
330-
331-
# Enable field level encryption
332-
add_encryption_layer(api_client, config)
341+
add_encryption_layer(api_client, "path/to/my/config.json")
333342
```
334343

335344
5. Use the `ApiClient` instance with Authentication and Field Level Encryption both enabled:

0 commit comments

Comments
 (0)