otdf-python 0.1.9__py3-none-any.whl → 0.3.0__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.
Files changed (144) hide show
  1. otdf_python/__init__.py +25 -0
  2. otdf_python/__main__.py +12 -0
  3. otdf_python/address_normalizer.py +84 -0
  4. otdf_python/aesgcm.py +55 -0
  5. otdf_python/assertion_config.py +84 -0
  6. otdf_python/asym_crypto.py +85 -0
  7. otdf_python/asym_decryption.py +53 -0
  8. otdf_python/asym_encryption.py +75 -0
  9. otdf_python/auth_headers.py +21 -0
  10. otdf_python/autoconfigure_utils.py +113 -0
  11. otdf_python/cli.py +570 -0
  12. otdf_python/collection_store.py +41 -0
  13. otdf_python/collection_store_impl.py +22 -0
  14. otdf_python/config.py +69 -0
  15. otdf_python/connect_client.py +0 -0
  16. otdf_python/constants.py +1 -0
  17. otdf_python/crypto_utils.py +78 -0
  18. otdf_python/dpop.py +81 -0
  19. otdf_python/ecc_mode.py +32 -0
  20. otdf_python/eckeypair.py +75 -0
  21. otdf_python/header.py +143 -0
  22. otdf_python/invalid_zip_exception.py +8 -0
  23. otdf_python/kas_client.py +603 -0
  24. otdf_python/kas_connect_rpc_client.py +207 -0
  25. otdf_python/kas_info.py +25 -0
  26. otdf_python/kas_key_cache.py +52 -0
  27. otdf_python/key_type.py +31 -0
  28. otdf_python/key_type_constants.py +43 -0
  29. otdf_python/manifest.py +215 -0
  30. otdf_python/nanotdf.py +553 -0
  31. otdf_python/nanotdf_ecdsa_struct.py +132 -0
  32. otdf_python/nanotdf_type.py +43 -0
  33. otdf_python/policy_binding_serializer.py +39 -0
  34. otdf_python/policy_info.py +78 -0
  35. otdf_python/policy_object.py +22 -0
  36. otdf_python/policy_stub.py +2 -0
  37. otdf_python/resource_locator.py +44 -0
  38. otdf_python/sdk.py +528 -0
  39. otdf_python/sdk_builder.py +448 -0
  40. otdf_python/sdk_exceptions.py +16 -0
  41. otdf_python/symmetric_and_payload_config.py +30 -0
  42. otdf_python/tdf.py +479 -0
  43. otdf_python/tdf_reader.py +153 -0
  44. otdf_python/tdf_writer.py +23 -0
  45. otdf_python/token_source.py +34 -0
  46. otdf_python/version.py +57 -0
  47. otdf_python/zip_reader.py +47 -0
  48. otdf_python/zip_writer.py +70 -0
  49. otdf_python-0.3.0.dist-info/METADATA +231 -0
  50. otdf_python-0.3.0.dist-info/RECORD +137 -0
  51. {otdf_python-0.1.9.dist-info → otdf_python-0.3.0.dist-info}/WHEEL +1 -2
  52. {otdf_python-0.1.9.dist-info → otdf_python-0.3.0.dist-info/licenses}/LICENSE +1 -1
  53. otdf_python_proto/__init__.py +37 -0
  54. otdf_python_proto/authorization/__init__.py +1 -0
  55. otdf_python_proto/authorization/authorization_pb2.py +80 -0
  56. otdf_python_proto/authorization/authorization_pb2.pyi +161 -0
  57. otdf_python_proto/authorization/authorization_pb2_connect.py +191 -0
  58. otdf_python_proto/authorization/v2/authorization_pb2.py +105 -0
  59. otdf_python_proto/authorization/v2/authorization_pb2.pyi +134 -0
  60. otdf_python_proto/authorization/v2/authorization_pb2_connect.py +233 -0
  61. otdf_python_proto/common/__init__.py +1 -0
  62. otdf_python_proto/common/common_pb2.py +52 -0
  63. otdf_python_proto/common/common_pb2.pyi +61 -0
  64. otdf_python_proto/entity/__init__.py +1 -0
  65. otdf_python_proto/entity/entity_pb2.py +47 -0
  66. otdf_python_proto/entity/entity_pb2.pyi +50 -0
  67. otdf_python_proto/entityresolution/__init__.py +1 -0
  68. otdf_python_proto/entityresolution/entity_resolution_pb2.py +57 -0
  69. otdf_python_proto/entityresolution/entity_resolution_pb2.pyi +55 -0
  70. otdf_python_proto/entityresolution/entity_resolution_pb2_connect.py +149 -0
  71. otdf_python_proto/entityresolution/v2/entity_resolution_pb2.py +55 -0
  72. otdf_python_proto/entityresolution/v2/entity_resolution_pb2.pyi +55 -0
  73. otdf_python_proto/entityresolution/v2/entity_resolution_pb2_connect.py +149 -0
  74. otdf_python_proto/kas/__init__.py +9 -0
  75. otdf_python_proto/kas/kas_pb2.py +103 -0
  76. otdf_python_proto/kas/kas_pb2.pyi +170 -0
  77. otdf_python_proto/kas/kas_pb2_connect.py +192 -0
  78. otdf_python_proto/legacy_grpc/__init__.py +1 -0
  79. otdf_python_proto/legacy_grpc/authorization/authorization_pb2_grpc.py +163 -0
  80. otdf_python_proto/legacy_grpc/authorization/v2/authorization_pb2_grpc.py +206 -0
  81. otdf_python_proto/legacy_grpc/common/common_pb2_grpc.py +4 -0
  82. otdf_python_proto/legacy_grpc/entity/entity_pb2_grpc.py +4 -0
  83. otdf_python_proto/legacy_grpc/entityresolution/entity_resolution_pb2_grpc.py +122 -0
  84. otdf_python_proto/legacy_grpc/entityresolution/v2/entity_resolution_pb2_grpc.py +120 -0
  85. otdf_python_proto/legacy_grpc/kas/kas_pb2_grpc.py +172 -0
  86. otdf_python_proto/legacy_grpc/logger/audit/test_pb2_grpc.py +4 -0
  87. otdf_python_proto/legacy_grpc/policy/actions/actions_pb2_grpc.py +249 -0
  88. otdf_python_proto/legacy_grpc/policy/attributes/attributes_pb2_grpc.py +873 -0
  89. otdf_python_proto/legacy_grpc/policy/kasregistry/key_access_server_registry_pb2_grpc.py +602 -0
  90. otdf_python_proto/legacy_grpc/policy/keymanagement/key_management_pb2_grpc.py +251 -0
  91. otdf_python_proto/legacy_grpc/policy/namespaces/namespaces_pb2_grpc.py +427 -0
  92. otdf_python_proto/legacy_grpc/policy/objects_pb2_grpc.py +4 -0
  93. otdf_python_proto/legacy_grpc/policy/registeredresources/registered_resources_pb2_grpc.py +524 -0
  94. otdf_python_proto/legacy_grpc/policy/resourcemapping/resource_mapping_pb2_grpc.py +516 -0
  95. otdf_python_proto/legacy_grpc/policy/selectors_pb2_grpc.py +4 -0
  96. otdf_python_proto/legacy_grpc/policy/subjectmapping/subject_mapping_pb2_grpc.py +551 -0
  97. otdf_python_proto/legacy_grpc/policy/unsafe/unsafe_pb2_grpc.py +485 -0
  98. otdf_python_proto/legacy_grpc/wellknownconfiguration/wellknown_configuration_pb2_grpc.py +77 -0
  99. otdf_python_proto/logger/__init__.py +1 -0
  100. otdf_python_proto/logger/audit/test_pb2.py +43 -0
  101. otdf_python_proto/logger/audit/test_pb2.pyi +45 -0
  102. otdf_python_proto/policy/__init__.py +1 -0
  103. otdf_python_proto/policy/actions/actions_pb2.py +75 -0
  104. otdf_python_proto/policy/actions/actions_pb2.pyi +87 -0
  105. otdf_python_proto/policy/actions/actions_pb2_connect.py +275 -0
  106. otdf_python_proto/policy/attributes/attributes_pb2.py +234 -0
  107. otdf_python_proto/policy/attributes/attributes_pb2.pyi +328 -0
  108. otdf_python_proto/policy/attributes/attributes_pb2_connect.py +863 -0
  109. otdf_python_proto/policy/kasregistry/key_access_server_registry_pb2.py +266 -0
  110. otdf_python_proto/policy/kasregistry/key_access_server_registry_pb2.pyi +450 -0
  111. otdf_python_proto/policy/kasregistry/key_access_server_registry_pb2_connect.py +611 -0
  112. otdf_python_proto/policy/keymanagement/key_management_pb2.py +79 -0
  113. otdf_python_proto/policy/keymanagement/key_management_pb2.pyi +87 -0
  114. otdf_python_proto/policy/keymanagement/key_management_pb2_connect.py +275 -0
  115. otdf_python_proto/policy/namespaces/namespaces_pb2.py +117 -0
  116. otdf_python_proto/policy/namespaces/namespaces_pb2.pyi +147 -0
  117. otdf_python_proto/policy/namespaces/namespaces_pb2_connect.py +443 -0
  118. otdf_python_proto/policy/objects_pb2.py +150 -0
  119. otdf_python_proto/policy/objects_pb2.pyi +464 -0
  120. otdf_python_proto/policy/registeredresources/registered_resources_pb2.py +139 -0
  121. otdf_python_proto/policy/registeredresources/registered_resources_pb2.pyi +196 -0
  122. otdf_python_proto/policy/registeredresources/registered_resources_pb2_connect.py +527 -0
  123. otdf_python_proto/policy/resourcemapping/resource_mapping_pb2.py +139 -0
  124. otdf_python_proto/policy/resourcemapping/resource_mapping_pb2.pyi +194 -0
  125. otdf_python_proto/policy/resourcemapping/resource_mapping_pb2_connect.py +527 -0
  126. otdf_python_proto/policy/selectors_pb2.py +57 -0
  127. otdf_python_proto/policy/selectors_pb2.pyi +90 -0
  128. otdf_python_proto/policy/subjectmapping/subject_mapping_pb2.py +127 -0
  129. otdf_python_proto/policy/subjectmapping/subject_mapping_pb2.pyi +189 -0
  130. otdf_python_proto/policy/subjectmapping/subject_mapping_pb2_connect.py +569 -0
  131. otdf_python_proto/policy/unsafe/unsafe_pb2.py +113 -0
  132. otdf_python_proto/policy/unsafe/unsafe_pb2.pyi +145 -0
  133. otdf_python_proto/policy/unsafe/unsafe_pb2_connect.py +485 -0
  134. otdf_python_proto/wellknownconfiguration/__init__.py +1 -0
  135. otdf_python_proto/wellknownconfiguration/wellknown_configuration_pb2.py +51 -0
  136. otdf_python_proto/wellknownconfiguration/wellknown_configuration_pb2.pyi +32 -0
  137. otdf_python_proto/wellknownconfiguration/wellknown_configuration_pb2_connect.py +107 -0
  138. otdf_python/_gotdf_python.cpython-312-darwin.so +0 -0
  139. otdf_python/build.py +0 -190
  140. otdf_python/go.py +0 -1478
  141. otdf_python/gotdf_python.py +0 -383
  142. otdf_python-0.1.9.dist-info/METADATA +0 -149
  143. otdf_python-0.1.9.dist-info/RECORD +0 -10
  144. otdf_python-0.1.9.dist-info/top_level.txt +0 -1
@@ -1,383 +0,0 @@
1
-
2
- # python wrapper for package gotdf_python within overall package gotdf_python
3
- # This is what you import to use the package.
4
- # File is generated by gopy. Do not edit.
5
- # gopy build --output=otdf_python -vm=python3 .
6
-
7
- # the following is required to enable dlopen to open the _go.so file
8
- import os,sys,inspect,collections
9
- try:
10
- import collections.abc as _collections_abc
11
- except ImportError:
12
- _collections_abc = collections
13
-
14
- cwd = os.getcwd()
15
- currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
16
- os.chdir(currentdir)
17
- from . import _gotdf_python
18
- from . import go
19
-
20
- os.chdir(cwd)
21
-
22
- # to use this code in your end-user python file, import it as follows:
23
- # from gotdf_python import gotdf_python
24
- # and then refer to everything using gotdf_python. prefix
25
- # packages imported by this package listed below:
26
-
27
-
28
-
29
-
30
- # ---- Types ---
31
-
32
-
33
- #---- Enums from Go (collections of consts with same type) ---
34
-
35
-
36
- #---- Constants from Go: Python can only ask that you please don't change these! ---
37
-
38
-
39
- # ---- Global Variables: can only use functions to access ---
40
-
41
-
42
- # ---- Interfaces ---
43
-
44
-
45
- # ---- Structs ---
46
-
47
- # Python type for struct gotdf_python.DecryptionConfig
48
- class DecryptionConfig(go.GoClass):
49
- """"""
50
- def __init__(self, *args, **kwargs):
51
- """
52
- handle=A Go-side object is always initialized with an explicit handle=arg
53
- otherwise parameters can be unnamed in order of field names or named fields
54
- in which case a new Go object is constructed first
55
- """
56
- if len(kwargs) == 1 and 'handle' in kwargs:
57
- self.handle = kwargs['handle']
58
- _gotdf_python.IncRef(self.handle)
59
- elif len(args) == 1 and isinstance(args[0], go.GoClass):
60
- self.handle = args[0].handle
61
- _gotdf_python.IncRef(self.handle)
62
- else:
63
- self.handle = _gotdf_python.gotdf_python_DecryptionConfig_CTor()
64
- _gotdf_python.IncRef(self.handle)
65
- if 0 < len(args):
66
- self.ClientId = args[0]
67
- if "ClientId" in kwargs:
68
- self.ClientId = kwargs["ClientId"]
69
- if 1 < len(args):
70
- self.ClientSecret = args[1]
71
- if "ClientSecret" in kwargs:
72
- self.ClientSecret = kwargs["ClientSecret"]
73
- if 2 < len(args):
74
- self.PlatformEndpoint = args[2]
75
- if "PlatformEndpoint" in kwargs:
76
- self.PlatformEndpoint = kwargs["PlatformEndpoint"]
77
- if 3 < len(args):
78
- self.TokenEndpoint = args[3]
79
- if "TokenEndpoint" in kwargs:
80
- self.TokenEndpoint = kwargs["TokenEndpoint"]
81
- if 4 < len(args):
82
- self.KasUrl = args[4]
83
- if "KasUrl" in kwargs:
84
- self.KasUrl = kwargs["KasUrl"]
85
- def __del__(self):
86
- _gotdf_python.DecRef(self.handle)
87
- def __str__(self):
88
- pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
89
- sv = 'gotdf_python.DecryptionConfig{'
90
- first = True
91
- for v in pr:
92
- if callable(v[1]):
93
- continue
94
- if first:
95
- first = False
96
- else:
97
- sv += ', '
98
- sv += v[0] + '=' + str(v[1])
99
- return sv + '}'
100
- def __repr__(self):
101
- pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
102
- sv = 'gotdf_python.DecryptionConfig ( '
103
- for v in pr:
104
- if not callable(v[1]):
105
- sv += v[0] + '=' + str(v[1]) + ', '
106
- return sv + ')'
107
- @property
108
- def ClientId(self):
109
- return _gotdf_python.gotdf_python_DecryptionConfig_ClientId_Get(self.handle)
110
- @ClientId.setter
111
- def ClientId(self, value):
112
- if isinstance(value, go.GoClass):
113
- _gotdf_python.gotdf_python_DecryptionConfig_ClientId_Set(self.handle, value.handle)
114
- else:
115
- _gotdf_python.gotdf_python_DecryptionConfig_ClientId_Set(self.handle, value)
116
- @property
117
- def ClientSecret(self):
118
- return _gotdf_python.gotdf_python_DecryptionConfig_ClientSecret_Get(self.handle)
119
- @ClientSecret.setter
120
- def ClientSecret(self, value):
121
- if isinstance(value, go.GoClass):
122
- _gotdf_python.gotdf_python_DecryptionConfig_ClientSecret_Set(self.handle, value.handle)
123
- else:
124
- _gotdf_python.gotdf_python_DecryptionConfig_ClientSecret_Set(self.handle, value)
125
- @property
126
- def PlatformEndpoint(self):
127
- return _gotdf_python.gotdf_python_DecryptionConfig_PlatformEndpoint_Get(self.handle)
128
- @PlatformEndpoint.setter
129
- def PlatformEndpoint(self, value):
130
- if isinstance(value, go.GoClass):
131
- _gotdf_python.gotdf_python_DecryptionConfig_PlatformEndpoint_Set(self.handle, value.handle)
132
- else:
133
- _gotdf_python.gotdf_python_DecryptionConfig_PlatformEndpoint_Set(self.handle, value)
134
- @property
135
- def TokenEndpoint(self):
136
- return _gotdf_python.gotdf_python_DecryptionConfig_TokenEndpoint_Get(self.handle)
137
- @TokenEndpoint.setter
138
- def TokenEndpoint(self, value):
139
- if isinstance(value, go.GoClass):
140
- _gotdf_python.gotdf_python_DecryptionConfig_TokenEndpoint_Set(self.handle, value.handle)
141
- else:
142
- _gotdf_python.gotdf_python_DecryptionConfig_TokenEndpoint_Set(self.handle, value)
143
- @property
144
- def KasUrl(self):
145
- return _gotdf_python.gotdf_python_DecryptionConfig_KasUrl_Get(self.handle)
146
- @KasUrl.setter
147
- def KasUrl(self, value):
148
- if isinstance(value, go.GoClass):
149
- _gotdf_python.gotdf_python_DecryptionConfig_KasUrl_Set(self.handle, value.handle)
150
- else:
151
- _gotdf_python.gotdf_python_DecryptionConfig_KasUrl_Set(self.handle, value)
152
-
153
- # Python type for struct gotdf_python.EncryptionConfig
154
- class EncryptionConfig(go.GoClass):
155
- """In a pure golang library, we'd probably embed\nthe 'DecryptionConfig' struct into the\n'EncryptionConfig' struct. However, this makes\nusage from Python / Gopy difficult, so\nit's not worthwhile.\n"""
156
- def __init__(self, *args, **kwargs):
157
- """
158
- handle=A Go-side object is always initialized with an explicit handle=arg
159
- otherwise parameters can be unnamed in order of field names or named fields
160
- in which case a new Go object is constructed first
161
- """
162
- if len(kwargs) == 1 and 'handle' in kwargs:
163
- self.handle = kwargs['handle']
164
- _gotdf_python.IncRef(self.handle)
165
- elif len(args) == 1 and isinstance(args[0], go.GoClass):
166
- self.handle = args[0].handle
167
- _gotdf_python.IncRef(self.handle)
168
- else:
169
- self.handle = _gotdf_python.gotdf_python_EncryptionConfig_CTor()
170
- _gotdf_python.IncRef(self.handle)
171
- if 0 < len(args):
172
- self.ClientId = args[0]
173
- if "ClientId" in kwargs:
174
- self.ClientId = kwargs["ClientId"]
175
- if 1 < len(args):
176
- self.ClientSecret = args[1]
177
- if "ClientSecret" in kwargs:
178
- self.ClientSecret = kwargs["ClientSecret"]
179
- if 2 < len(args):
180
- self.PlatformEndpoint = args[2]
181
- if "PlatformEndpoint" in kwargs:
182
- self.PlatformEndpoint = kwargs["PlatformEndpoint"]
183
- if 3 < len(args):
184
- self.TokenEndpoint = args[3]
185
- if "TokenEndpoint" in kwargs:
186
- self.TokenEndpoint = kwargs["TokenEndpoint"]
187
- if 4 < len(args):
188
- self.KasUrl = args[4]
189
- if "KasUrl" in kwargs:
190
- self.KasUrl = kwargs["KasUrl"]
191
- if 5 < len(args):
192
- self.DataAttributes = args[5]
193
- if "DataAttributes" in kwargs:
194
- self.DataAttributes = kwargs["DataAttributes"]
195
- def __del__(self):
196
- _gotdf_python.DecRef(self.handle)
197
- def __str__(self):
198
- pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
199
- sv = 'gotdf_python.EncryptionConfig{'
200
- first = True
201
- for v in pr:
202
- if callable(v[1]):
203
- continue
204
- if first:
205
- first = False
206
- else:
207
- sv += ', '
208
- sv += v[0] + '=' + str(v[1])
209
- return sv + '}'
210
- def __repr__(self):
211
- pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
212
- sv = 'gotdf_python.EncryptionConfig ( '
213
- for v in pr:
214
- if not callable(v[1]):
215
- sv += v[0] + '=' + str(v[1]) + ', '
216
- return sv + ')'
217
- @property
218
- def ClientId(self):
219
- return _gotdf_python.gotdf_python_EncryptionConfig_ClientId_Get(self.handle)
220
- @ClientId.setter
221
- def ClientId(self, value):
222
- if isinstance(value, go.GoClass):
223
- _gotdf_python.gotdf_python_EncryptionConfig_ClientId_Set(self.handle, value.handle)
224
- else:
225
- _gotdf_python.gotdf_python_EncryptionConfig_ClientId_Set(self.handle, value)
226
- @property
227
- def ClientSecret(self):
228
- return _gotdf_python.gotdf_python_EncryptionConfig_ClientSecret_Get(self.handle)
229
- @ClientSecret.setter
230
- def ClientSecret(self, value):
231
- if isinstance(value, go.GoClass):
232
- _gotdf_python.gotdf_python_EncryptionConfig_ClientSecret_Set(self.handle, value.handle)
233
- else:
234
- _gotdf_python.gotdf_python_EncryptionConfig_ClientSecret_Set(self.handle, value)
235
- @property
236
- def PlatformEndpoint(self):
237
- return _gotdf_python.gotdf_python_EncryptionConfig_PlatformEndpoint_Get(self.handle)
238
- @PlatformEndpoint.setter
239
- def PlatformEndpoint(self, value):
240
- if isinstance(value, go.GoClass):
241
- _gotdf_python.gotdf_python_EncryptionConfig_PlatformEndpoint_Set(self.handle, value.handle)
242
- else:
243
- _gotdf_python.gotdf_python_EncryptionConfig_PlatformEndpoint_Set(self.handle, value)
244
- @property
245
- def TokenEndpoint(self):
246
- return _gotdf_python.gotdf_python_EncryptionConfig_TokenEndpoint_Get(self.handle)
247
- @TokenEndpoint.setter
248
- def TokenEndpoint(self, value):
249
- if isinstance(value, go.GoClass):
250
- _gotdf_python.gotdf_python_EncryptionConfig_TokenEndpoint_Set(self.handle, value.handle)
251
- else:
252
- _gotdf_python.gotdf_python_EncryptionConfig_TokenEndpoint_Set(self.handle, value)
253
- @property
254
- def KasUrl(self):
255
- return _gotdf_python.gotdf_python_EncryptionConfig_KasUrl_Get(self.handle)
256
- @KasUrl.setter
257
- def KasUrl(self, value):
258
- if isinstance(value, go.GoClass):
259
- _gotdf_python.gotdf_python_EncryptionConfig_KasUrl_Set(self.handle, value.handle)
260
- else:
261
- _gotdf_python.gotdf_python_EncryptionConfig_KasUrl_Set(self.handle, value)
262
- @property
263
- def DataAttributes(self):
264
- return go.Slice_string(handle=_gotdf_python.gotdf_python_EncryptionConfig_DataAttributes_Get(self.handle))
265
- @DataAttributes.setter
266
- def DataAttributes(self, value):
267
- if isinstance(value, go.GoClass):
268
- _gotdf_python.gotdf_python_EncryptionConfig_DataAttributes_Set(self.handle, value.handle)
269
- else:
270
- raise TypeError("supplied argument type {t} is not a go.GoClass".format(t=type(value)))
271
-
272
- # Python type for struct gotdf_python.TokenAuth
273
- class TokenAuth(go.GoClass):
274
- """"""
275
- def __init__(self, *args, **kwargs):
276
- """
277
- handle=A Go-side object is always initialized with an explicit handle=arg
278
- otherwise parameters can be unnamed in order of field names or named fields
279
- in which case a new Go object is constructed first
280
- """
281
- if len(kwargs) == 1 and 'handle' in kwargs:
282
- self.handle = kwargs['handle']
283
- _gotdf_python.IncRef(self.handle)
284
- elif len(args) == 1 and isinstance(args[0], go.GoClass):
285
- self.handle = args[0].handle
286
- _gotdf_python.IncRef(self.handle)
287
- else:
288
- self.handle = _gotdf_python.gotdf_python_TokenAuth_CTor()
289
- _gotdf_python.IncRef(self.handle)
290
- if 0 < len(args):
291
- self.AccessToken = args[0]
292
- if "AccessToken" in kwargs:
293
- self.AccessToken = kwargs["AccessToken"]
294
- if 1 < len(args):
295
- self.NpeClientId = args[1]
296
- if "NpeClientId" in kwargs:
297
- self.NpeClientId = kwargs["NpeClientId"]
298
- def __del__(self):
299
- _gotdf_python.DecRef(self.handle)
300
- def __str__(self):
301
- pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
302
- sv = 'gotdf_python.TokenAuth{'
303
- first = True
304
- for v in pr:
305
- if callable(v[1]):
306
- continue
307
- if first:
308
- first = False
309
- else:
310
- sv += ', '
311
- sv += v[0] + '=' + str(v[1])
312
- return sv + '}'
313
- def __repr__(self):
314
- pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')]
315
- sv = 'gotdf_python.TokenAuth ( '
316
- for v in pr:
317
- if not callable(v[1]):
318
- sv += v[0] + '=' + str(v[1]) + ', '
319
- return sv + ')'
320
- @property
321
- def AccessToken(self):
322
- return _gotdf_python.gotdf_python_TokenAuth_AccessToken_Get(self.handle)
323
- @AccessToken.setter
324
- def AccessToken(self, value):
325
- if isinstance(value, go.GoClass):
326
- _gotdf_python.gotdf_python_TokenAuth_AccessToken_Set(self.handle, value.handle)
327
- else:
328
- _gotdf_python.gotdf_python_TokenAuth_AccessToken_Set(self.handle, value)
329
- @property
330
- def NpeClientId(self):
331
- return _gotdf_python.gotdf_python_TokenAuth_NpeClientId_Get(self.handle)
332
- @NpeClientId.setter
333
- def NpeClientId(self, value):
334
- if isinstance(value, go.GoClass):
335
- _gotdf_python.gotdf_python_TokenAuth_NpeClientId_Set(self.handle, value.handle)
336
- else:
337
- _gotdf_python.gotdf_python_TokenAuth_NpeClientId_Set(self.handle, value)
338
-
339
-
340
- # ---- Slices ---
341
-
342
-
343
- # ---- Maps ---
344
-
345
-
346
- # ---- Constructors ---
347
-
348
-
349
- # ---- Functions ---
350
- def EncryptFile(inputFilePath, outputFilePath, config):
351
- """EncryptFile(str inputFilePath, str outputFilePath, object config) str, str"""
352
- return _gotdf_python.gotdf_python_EncryptFile(inputFilePath, outputFilePath, config.handle)
353
- def EncryptFilePE(inputFilePath, outputFilePath, config, token):
354
- """EncryptFilePE(str inputFilePath, str outputFilePath, object config, object token) str, str
355
-
356
- Encrypts a file as a PE (Person Entity), returning a TDF manifest and the cipher text.
357
- """
358
- return _gotdf_python.gotdf_python_EncryptFilePE(inputFilePath, outputFilePath, config.handle, token.handle)
359
- def EncryptString(inputText, config):
360
- """EncryptString(str inputText, object config) str, str"""
361
- return _gotdf_python.gotdf_python_EncryptString(inputText, config.handle)
362
- def Hello():
363
- """Hello() str
364
-
365
- A simple "Hello, world" function, used for learning golang (e.g. unit testing),
366
- as well as validating the necessary mechanisms to compile this library
367
- into a Python wheel.
368
-
369
- In the future, this function might be removed or replaced with a more
370
- conventional & useful function like GetVersion()
371
- """
372
- return _gotdf_python.gotdf_python_Hello()
373
- def DecryptFile(inputFilePath, outputFilePath, config):
374
- """DecryptFile(str inputFilePath, str outputFilePath, object config) str, str"""
375
- return _gotdf_python.gotdf_python_DecryptFile(inputFilePath, outputFilePath, config.handle)
376
- def DecryptFilePE(inputFilePath, outputFilePath, config, token):
377
- """DecryptFilePE(str inputFilePath, str outputFilePath, object config, object token) str, str"""
378
- return _gotdf_python.gotdf_python_DecryptFilePE(inputFilePath, outputFilePath, config.handle, token.handle)
379
- def DecryptStringPE(inputText, config, token):
380
- """DecryptStringPE(str inputText, object config, object token) str, str"""
381
- return _gotdf_python.gotdf_python_DecryptStringPE(inputText, config.handle, token.handle)
382
-
383
-
@@ -1,149 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: otdf_python
3
- Version: 0.1.9
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
- [![Tests](https://github.com/b-long/opentdf-python-sdk/workflows/PyPIBuild/badge.svg)](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
- ```
@@ -1,10 +0,0 @@
1
- otdf_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- otdf_python/_gotdf_python.cpython-312-darwin.so,sha256=jazdOllpkFdjoxsZPUk0k70cy_0otCcT41NRJ8F1IHY,15789992
3
- otdf_python/build.py,sha256=1rFsosV3JfeaySm5QT14CY0x51go6XbdiL3UgreyIek,16756
4
- otdf_python/go.py,sha256=7kz0kwEbEJZp9ZJIvdcUryZmhahLRb5RrkhGBN2BDBY,49317
5
- otdf_python/gotdf_python.py,sha256=PcXrL4WNGcK-peWHhO1Xt72KYgE3US2Q0y33OlcHGtQ,13880
6
- otdf_python-0.1.9.dist-info/LICENSE,sha256=51wzGxR-Rns8XaiGmDLq2OqPN3qWMpoQKV-fERpVzyM,1063
7
- otdf_python-0.1.9.dist-info/METADATA,sha256=vs9qd-uFjdtJ7uiJQwqoMzndIlARJ5mZJdKaMT5nmG0,4933
8
- otdf_python-0.1.9.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
9
- otdf_python-0.1.9.dist-info/top_level.txt,sha256=A2vK95iTIxdu4pm8kDZlvHorBKCvSN5dvlMdFbIVXrA,12
10
- otdf_python-0.1.9.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- otdf_python