otdf-python 0.0.11__py3-none-any.whl → 0.0.13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- otdf_python/_gotdf_python.cpython-311-darwin.so +0 -0
- otdf_python-0.0.13.dist-info/METADATA +149 -0
- otdf_python-0.0.13.dist-info/RECORD +10 -0
- otdf_python-0.0.11.dist-info/METADATA +0 -82
- otdf_python-0.0.11.dist-info/RECORD +0 -10
- {otdf_python-0.0.11.dist-info → otdf_python-0.0.13.dist-info}/LICENSE +0 -0
- {otdf_python-0.0.11.dist-info → otdf_python-0.0.13.dist-info}/WHEEL +0 -0
- {otdf_python-0.0.11.dist-info → otdf_python-0.0.13.dist-info}/top_level.txt +0 -0
|
Binary file
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: otdf_python
|
|
3
|
+
Version: 0.0.13
|
|
4
|
+
Home-page: https://github.com/b-long/opentdf-python-sdk
|
|
5
|
+
Author-email: b-long@users.noreply.github.com
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
|
|
9
|
+
# opentdf-python-sdk
|
|
10
|
+
|
|
11
|
+
Unofficial OpenTDF SDK for Python
|
|
12
|
+
|
|
13
|
+
[](https://github.com/b-long/opentdf-python-sdk/actions?query=workflow%3APyPIBuild)
|
|
14
|
+
|
|
15
|
+
This project is powered by gopy, which generates (and compiles) a CPython extension module from a go package. The `gopy`
|
|
16
|
+
tool unlocks performance, flexibility, and excellent Developer Experience to Python end-users. Read more about
|
|
17
|
+
[`gopy` on Github](https://github.com/go-python/gopy).
|
|
18
|
+
|
|
19
|
+
## Adding features
|
|
20
|
+
|
|
21
|
+
If you wish to expand the functionality of `otdf-python`:
|
|
22
|
+
|
|
23
|
+
1. Create a fork/branch
|
|
24
|
+
1. Add new capabilities (e.g. in `main.go`)
|
|
25
|
+
1. Add a test (e.g. in `otdf_python_test.go`)
|
|
26
|
+
1. Commit your changes, push, and open a Pull Request via
|
|
27
|
+
the Github project: https://github.com/b-long/opentdf-python-sdk
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Install from the [Python Package Index (PyPI)](https://pypi.org):
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Install the latest from pypi.org
|
|
35
|
+
pip install otdf_python
|
|
36
|
+
|
|
37
|
+
# Install a pinned version
|
|
38
|
+
pip install otdf-python==0.0.9
|
|
39
|
+
|
|
40
|
+
# Install a pinned version, from test.pypi.org
|
|
41
|
+
pip install -i https://test.pypi.org/simple/ otdf-python==0.0.9
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
Simple usage examples are given below. In addition, we recommend you also:
|
|
47
|
+
|
|
48
|
+
1. See the contents of [`main.go` on Github](https://github.com/b-long/opentdf-python-sdk/blob/main/main.go). ✨ Note that all Upper-case functions are available in Python.
|
|
49
|
+
1. See the contents of [`validate_otdf_python.py` on Github](https://github.com/b-long/opentdf-python-sdk/blob/main/validate_otdf_python.py).
|
|
50
|
+
|
|
51
|
+
### Example: Configuration
|
|
52
|
+
|
|
53
|
+
Creating a helper function may simplify the usage of `otdf-python`.
|
|
54
|
+
|
|
55
|
+
For example:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
def get_encrypt_config(data_attributes: list | None = None):
|
|
59
|
+
"""
|
|
60
|
+
The config object returned here can only be used for encryption.
|
|
61
|
+
|
|
62
|
+
While 'otdf_python.gotdf_python' internally can use golang interfaces,
|
|
63
|
+
to normalize config objects, that pattern causes a panic
|
|
64
|
+
when used from Python.
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
print("Preparing 'EncryptionConfig' object")
|
|
68
|
+
from otdf_python.gotdf_python import EncryptionConfig
|
|
69
|
+
from otdf_python.go import Slice_string
|
|
70
|
+
|
|
71
|
+
if isinstance(data_attributes, list):
|
|
72
|
+
# Create config using the attributes from the caller
|
|
73
|
+
da = Slice_string(data_attributes)
|
|
74
|
+
config: EncryptionConfig = EncryptionConfig(
|
|
75
|
+
ClientId="opentdf-sdk",
|
|
76
|
+
ClientSecret="secret",
|
|
77
|
+
PlatformEndpoint=platformEndpoint,
|
|
78
|
+
TokenEndpoint="http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token",
|
|
79
|
+
KasUrl=f"http://{platformEndpoint}/kas",
|
|
80
|
+
# FIXME: Be careful with binding the 'DataAttributes' field on this struct.
|
|
81
|
+
#
|
|
82
|
+
# In golang, this is initialized as []string , but passing
|
|
83
|
+
# DataAttributes=None, or DataAttributes=[] from Python will fail.
|
|
84
|
+
DataAttributes=da,
|
|
85
|
+
)
|
|
86
|
+
else:
|
|
87
|
+
# Create config without attributes
|
|
88
|
+
config: EncryptionConfig = EncryptionConfig(
|
|
89
|
+
ClientId="opentdf-sdk",
|
|
90
|
+
ClientSecret="secret",
|
|
91
|
+
PlatformEndpoint=platformEndpoint,
|
|
92
|
+
TokenEndpoint="http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token",
|
|
93
|
+
KasUrl=f"http://{platformEndpoint}/kas",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# NOTE: Structs from golang can be printed, like below
|
|
97
|
+
# print(config)
|
|
98
|
+
print("Returning 'EncryptionConfig'")
|
|
99
|
+
|
|
100
|
+
return config
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Example: Encrypt a string
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from otdf_python.gotdf_python import EncryptString
|
|
108
|
+
|
|
109
|
+
# Depends on the 'get_encrypt_config()' given
|
|
110
|
+
# in the README above
|
|
111
|
+
config: EncryptionConfig = get_encrypt_config()
|
|
112
|
+
|
|
113
|
+
tdf_manifest_json = EncryptString(inputText="Hello from Python", config=config)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Example: Encrypt a file
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from otdf_python.gotdf_python import EncryptFile
|
|
120
|
+
from otdf_python.go import Slice_string
|
|
121
|
+
|
|
122
|
+
# Depends on the 'get_encrypt_config()' given
|
|
123
|
+
# in the README above
|
|
124
|
+
config: EncryptionConfig = get_encrypt_config()
|
|
125
|
+
|
|
126
|
+
with tempfile.TemporaryDirectory() as tmpDir:
|
|
127
|
+
print("Created temporary directory", tmpDir)
|
|
128
|
+
|
|
129
|
+
da = Slice_string(["https://example.com/attr/attr1/value/value1", "https://example.com/attr/attr1/value/value2"])
|
|
130
|
+
|
|
131
|
+
encrypted_file = Path(tmpDir) / "some-file.tdf"
|
|
132
|
+
|
|
133
|
+
if encrypted_file.exists():
|
|
134
|
+
encrypted_file.unlink()
|
|
135
|
+
|
|
136
|
+
if encrypted_file.exists():
|
|
137
|
+
raise ValueError(
|
|
138
|
+
"The output path should not exist before calling 'EncryptFile()'."
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
outputFilePath = EncryptFile(
|
|
142
|
+
inputFilePath=str(SOME_PLAINTEXT_FILE),
|
|
143
|
+
outputFilePath=str(encrypted_file),
|
|
144
|
+
config=config,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
print(f"The output file was written to destination path: {outputFilePath}")
|
|
148
|
+
|
|
149
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
otdf_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
otdf_python/_gotdf_python.cpython-311-darwin.so,sha256=kfXHmkRdxKJjy96_DvpJGttjUWz_WW4DQtXYG19pj7o,15710712
|
|
3
|
+
otdf_python/build.py,sha256=WwdUm0ey-MV1OuYjVcp12cKprHkHzGiupk4GphbhP9U,16756
|
|
4
|
+
otdf_python/go.py,sha256=7kz0kwEbEJZp9ZJIvdcUryZmhahLRb5RrkhGBN2BDBY,49317
|
|
5
|
+
otdf_python/gotdf_python.py,sha256=UtT6rqs7pEM7KiXEVApKBAP_Xx1s1_6mifL6_TVqN_g,13880
|
|
6
|
+
otdf_python-0.0.13.dist-info/LICENSE,sha256=51wzGxR-Rns8XaiGmDLq2OqPN3qWMpoQKV-fERpVzyM,1063
|
|
7
|
+
otdf_python-0.0.13.dist-info/METADATA,sha256=bxByPukjuI1ikWmEykxSZoaYTrcSYbJbKGDIABaiB1A,4934
|
|
8
|
+
otdf_python-0.0.13.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
9
|
+
otdf_python-0.0.13.dist-info/top_level.txt,sha256=A2vK95iTIxdu4pm8kDZlvHorBKCvSN5dvlMdFbIVXrA,12
|
|
10
|
+
otdf_python-0.0.13.dist-info/RECORD,,
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: otdf_python
|
|
3
|
-
Version: 0.0.11
|
|
4
|
-
Home-page: https://github.com/b-long/opentdf-python-sdk
|
|
5
|
-
Author-email: b-long@users.noreply.github.com
|
|
6
|
-
Description-Content-Type: text/markdown
|
|
7
|
-
License-File: LICENSE
|
|
8
|
-
|
|
9
|
-
# opentdf-python-sdk
|
|
10
|
-
|
|
11
|
-
Unofficial OpenTDF SDK for Python
|
|
12
|
-
|
|
13
|
-
[](https://github.com/b-long/opentdf-python-sdk/actions?query=workflow%3APyPIBuild)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Installation
|
|
17
|
-
|
|
18
|
-
Install from PyPI.org:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
pip install otdf_python
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Usage
|
|
25
|
-
|
|
26
|
-
Simple usage examples are given below. In addition, see the content of `validate_otdf_python.py` .
|
|
27
|
-
|
|
28
|
-
### Example: Encrypt a string
|
|
29
|
-
|
|
30
|
-
```python
|
|
31
|
-
from otdf_python.gotdf_python import EncryptString
|
|
32
|
-
|
|
33
|
-
config: EncryptionConfig = _get_configuration()
|
|
34
|
-
|
|
35
|
-
tdf_manifest_json = EncryptString(inputText="Hello from Python", config=config)
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Example: Encrypt a file
|
|
40
|
-
|
|
41
|
-
```python
|
|
42
|
-
from otdf_python.gotdf_python import EncryptFile
|
|
43
|
-
from otdf_python.go import Slice_string
|
|
44
|
-
|
|
45
|
-
with tempfile.TemporaryDirectory() as tmpDir:
|
|
46
|
-
print("Created temporary directory", tmpDir)
|
|
47
|
-
|
|
48
|
-
da = Slice_string(["https://example.com/attr/attr1/value/value1", "https://example.com/attr/attr1/value/value2"])
|
|
49
|
-
|
|
50
|
-
config: EncryptionConfig = EncryptionConfig(
|
|
51
|
-
ClientId="opentdf-sdk",
|
|
52
|
-
ClientSecret="secret",
|
|
53
|
-
PlatformEndpoint=platformEndpoint,
|
|
54
|
-
TokenEndpoint="http://localhost:8888/auth/realms/opentdf/protocol/openid-connect/token",
|
|
55
|
-
KasUrl=f"http://{platformEndpoint}/kas",
|
|
56
|
-
# FIXME: Be careful with binding the 'DataAttributes' field on this struct.
|
|
57
|
-
#
|
|
58
|
-
# In golang, this is initialized as []string , but passing
|
|
59
|
-
# DataAttributes=None, or DataAttributes=[] from Python will fail.
|
|
60
|
-
# DataAttributes=...
|
|
61
|
-
DataAttributes=da,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
encrypted_file = Path(tmpDir) / "some-file.tdf"
|
|
65
|
-
|
|
66
|
-
if encrypted_file.exists():
|
|
67
|
-
encrypted_file.unlink()
|
|
68
|
-
|
|
69
|
-
if encrypted_file.exists():
|
|
70
|
-
raise ValueError(
|
|
71
|
-
"The output path should not exist before calling 'EncryptFile()'."
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
outputFilePath = EncryptFile(
|
|
75
|
-
inputFilePath=str(SOME_PLAINTEXT_FILE),
|
|
76
|
-
outputFilePath=str(encrypted_file),
|
|
77
|
-
config=config,
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
print(f"The output file was written to destination path: {outputFilePath}")
|
|
81
|
-
|
|
82
|
-
```
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
otdf_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
otdf_python/_gotdf_python.cpython-311-darwin.so,sha256=fI0Up2Nk3hgxXpp2CD_u5nQvBztk3tbPUB_DoIYfO9E,15112432
|
|
3
|
-
otdf_python/build.py,sha256=WwdUm0ey-MV1OuYjVcp12cKprHkHzGiupk4GphbhP9U,16756
|
|
4
|
-
otdf_python/go.py,sha256=7kz0kwEbEJZp9ZJIvdcUryZmhahLRb5RrkhGBN2BDBY,49317
|
|
5
|
-
otdf_python/gotdf_python.py,sha256=UtT6rqs7pEM7KiXEVApKBAP_Xx1s1_6mifL6_TVqN_g,13880
|
|
6
|
-
otdf_python-0.0.11.dist-info/LICENSE,sha256=51wzGxR-Rns8XaiGmDLq2OqPN3qWMpoQKV-fERpVzyM,1063
|
|
7
|
-
otdf_python-0.0.11.dist-info/METADATA,sha256=X7-5_6L_HpBWhGSyVI-v3ujgsOBDtgEqPu4GKMwie78,2316
|
|
8
|
-
otdf_python-0.0.11.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
9
|
-
otdf_python-0.0.11.dist-info/top_level.txt,sha256=A2vK95iTIxdu4pm8kDZlvHorBKCvSN5dvlMdFbIVXrA,12
|
|
10
|
-
otdf_python-0.0.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|