cmem-plugin-uuid 1.0.0rc1__tar.gz
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.
- cmem_plugin_uuid-1.0.0rc1/LICENSE +201 -0
- cmem_plugin_uuid-1.0.0rc1/PKG-INFO +242 -0
- cmem_plugin_uuid-1.0.0rc1/README-public.md +221 -0
- cmem_plugin_uuid-1.0.0rc1/cmem_plugin_uuid/__init__.py +1 -0
- cmem_plugin_uuid-1.0.0rc1/cmem_plugin_uuid/transform/__init__.py +464 -0
- cmem_plugin_uuid-1.0.0rc1/cmem_plugin_uuid/utils.py +102 -0
- cmem_plugin_uuid-1.0.0rc1/pyproject.toml +82 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2021 CMEM
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cmem-plugin-uuid
|
|
3
|
+
Version: 1.0.0rc1
|
|
4
|
+
Summary: Create universally unique identifiers (UUIDs) versions 1, 3, 4, 5, 6, 7 and 8 in transformations.
|
|
5
|
+
Home-page: https://github.com/eccenca/cmem-plugin-uuid
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: eccenca Corporate Memory,plugin,UUID
|
|
8
|
+
Author: eccenca GmbH
|
|
9
|
+
Author-email: cmempy-developer@eccenca.com
|
|
10
|
+
Requires-Python: >=3.11,<4.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Plugins
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Requires-Dist: cmem-plugin-base (>=4.3.0,<5.0.0)
|
|
18
|
+
Requires-Dist: uuid6 (>=2023.5.2)
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# cmem-plugin-uuid
|
|
22
|
+
|
|
23
|
+
Create universally unique identifiers (UUIDs) versions 1, 3, 4, 5, 6, 7 and 8 in transformations.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
`cmemc -c my-cmem admin workspace python install cmem-plugin-uuid`
|
|
28
|
+
|
|
29
|
+
## UUID1
|
|
30
|
+
|
|
31
|
+
UUID1 version is generated from a host ID, sequence number, and the current time.
|
|
32
|
+
|
|
33
|
+
### Parameters
|
|
34
|
+
|
|
35
|
+
#### Node
|
|
36
|
+
|
|
37
|
+
Node value in the form "01:23:45:67:89:AB", "01-23-45-67-89-AB", or "0123456789AB".
|
|
38
|
+
If not given, [`uuid.getnode()`](https://docs.python.org/3/library/uuid.html#uuid.getnode) is used to
|
|
39
|
+
attempt to obtain the hardware address. If this is unsuccessful a random 48-bit number is chosen.
|
|
40
|
+
|
|
41
|
+
Default value: _None_
|
|
42
|
+
ID: `node`
|
|
43
|
+
|
|
44
|
+
#### Clock sequence
|
|
45
|
+
|
|
46
|
+
If clock sequence is given, it is used as the sequence number, otherwise a random 14-bit sequence number is chosen.
|
|
47
|
+
|
|
48
|
+
Default value: _None_
|
|
49
|
+
ID: `clock_seq`
|
|
50
|
+
|
|
51
|
+
<br>
|
|
52
|
+
|
|
53
|
+
## UUID3
|
|
54
|
+
|
|
55
|
+
UUID version 3 is a reproducible UUID based on the MD5 hash of a namespace identifier (which is a UUID) and a name
|
|
56
|
+
(which is a string).
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Parameters
|
|
60
|
+
|
|
61
|
+
#### Namespace
|
|
62
|
+
|
|
63
|
+
The namespace can be entered manually or selected from the namespace UUIDs defined in
|
|
64
|
+
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122):
|
|
65
|
+
|
|
66
|
+
- Namespace DNS: 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (*namespace_dns*)
|
|
67
|
+
- Namespace URL: 6ba7b811-9dad-11d1-80b4-00c04fd430c8 (*namespace_url*)
|
|
68
|
+
- Namespace OID: 6ba7b812-9dad-11d1-80b4-00c04fd430c8 (*namespace_oid*)
|
|
69
|
+
- Namespace X500: 6ba7b814-9dad-11d1-80b4-00c04fd430c8 (*namespace_x500*)
|
|
70
|
+
|
|
71
|
+
If none of the predefined namespace UUIDs is selected, the input namespace is either directly
|
|
72
|
+
interpreted as a UUID, or used to derive a UUID (see parameter _Namespace as UUID_). If no namespace is given,
|
|
73
|
+
the output is the same as that of the standard CMEM UUID operator with input value.
|
|
74
|
+
|
|
75
|
+
Default value: _none_
|
|
76
|
+
ID: `namespace`
|
|
77
|
+
|
|
78
|
+
#### Use input as namespace
|
|
79
|
+
|
|
80
|
+
If enabled, the input value is used for the namespace.
|
|
81
|
+
|
|
82
|
+
Default value: _False_
|
|
83
|
+
ID: `input_as_namespace`
|
|
84
|
+
|
|
85
|
+
#### Namespace as UUID
|
|
86
|
+
|
|
87
|
+
Applies only if none of the pre-defined namespaces is selected. If enabled, the namespace string
|
|
88
|
+
needs to be a valid UUID. Otherwise, the namespace UUID is a UUIDv1 derived from the MD5
|
|
89
|
+
hash of the namespace string.
|
|
90
|
+
|
|
91
|
+
Default value: _False_
|
|
92
|
+
ID: `namespace_as_uuid`
|
|
93
|
+
|
|
94
|
+
<br>
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## UUID4
|
|
98
|
+
|
|
99
|
+
UUID version 4 specifies a random UUID. This plugin is equivalent to the standard CMEM UUID operator without input value.
|
|
100
|
+
|
|
101
|
+
<br>
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## UUID5
|
|
105
|
+
|
|
106
|
+
UUID version 5 is a reproducible UUID based on the SHA1 hash of a namespace identifier (which is a UUID) and a
|
|
107
|
+
name (which is a string).
|
|
108
|
+
|
|
109
|
+
### Parameters
|
|
110
|
+
|
|
111
|
+
#### Namespace
|
|
112
|
+
|
|
113
|
+
The namespace can be entered manually or selected from the namespace UUIDs defined in
|
|
114
|
+
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122):
|
|
115
|
+
|
|
116
|
+
- Namespace DNS: 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (*namespace_dns*)
|
|
117
|
+
- Namespace URL: 6ba7b811-9dad-11d1-80b4-00c04fd430c8 (*namespace_url*)
|
|
118
|
+
- Namespace OID: 6ba7b812-9dad-11d1-80b4-00c04fd430c8 (*namespace_oid*)
|
|
119
|
+
- Namespace X500: 6ba7b814-9dad-11d1-80b4-00c04fd430c8 (*namespace_x500*)
|
|
120
|
+
|
|
121
|
+
If none of the predefined namespace UUIDs is selected, the input namespace is either directly
|
|
122
|
+
interpreted as a UUID, or used to derive a UUID (see parameter _Namespace as UUID_).
|
|
123
|
+
|
|
124
|
+
Default value: _none_
|
|
125
|
+
ID: `namespace`
|
|
126
|
+
|
|
127
|
+
#### Namespace as UUID
|
|
128
|
+
|
|
129
|
+
Applies only if none of the pre-defined namespaces is selected. If enabled, the namespace string
|
|
130
|
+
needs to be a valid UUID. Otherwise, the namespace UUID is a UUIDv1 derived from the SHA1
|
|
131
|
+
hash of the namespace string.
|
|
132
|
+
|
|
133
|
+
Default value: _False_
|
|
134
|
+
ID: `namespace_as_uuid`
|
|
135
|
+
|
|
136
|
+
<br>
|
|
137
|
+
|
|
138
|
+
## UUID6
|
|
139
|
+
|
|
140
|
+
UUID6 version is generated from a host ID, sequence number, and the current time.
|
|
141
|
+
UUID version 6 is a field-compatible version of UUIDv1, reordered for improved DB locality.
|
|
142
|
+
|
|
143
|
+
### Parameters
|
|
144
|
+
|
|
145
|
+
#### Node
|
|
146
|
+
|
|
147
|
+
Node value in the form "01:23:45:67:89:AB", "01-23-45-67-89-AB", or "0123456789AB".
|
|
148
|
+
If not given, a random 48-bit sequence number is chosen.
|
|
149
|
+
|
|
150
|
+
Default value: _None_
|
|
151
|
+
ID: `node`
|
|
152
|
+
|
|
153
|
+
#### Clock sequence
|
|
154
|
+
|
|
155
|
+
If clock sequence is given, it is used as the sequence number, otherwise a random 14-bit number is chosen.
|
|
156
|
+
|
|
157
|
+
Default value: _None_
|
|
158
|
+
ID: `clock_seq`
|
|
159
|
+
|
|
160
|
+
<br>
|
|
161
|
+
|
|
162
|
+
## UUID7
|
|
163
|
+
|
|
164
|
+
UUID version 7 features a time-ordered value field derived from the
|
|
165
|
+
widely implemented and well known Unix Epoch timestamp source, the
|
|
166
|
+
number of milliseconds since midnight 1 Jan 1970 UTC, leap seconds
|
|
167
|
+
excluded, as well as improved entropy characteristics over versions
|
|
168
|
+
1 or 6.
|
|
169
|
+
|
|
170
|
+
<br>
|
|
171
|
+
|
|
172
|
+
## UUID8
|
|
173
|
+
|
|
174
|
+
UUID version 8 features a time-ordered value field derived from the
|
|
175
|
+
widely implemented and well known Unix Epoch timestamp source, the
|
|
176
|
+
number of nanoseconds since midnight 1 Jan 1970 UTC, leap seconds
|
|
177
|
+
excluded.
|
|
178
|
+
|
|
179
|
+
<br>
|
|
180
|
+
|
|
181
|
+
## UUID1 to UUID6
|
|
182
|
+
|
|
183
|
+
Generate a UUID version 6 from a UUID version 1. The input needs to be a valid UUIDv1
|
|
184
|
+
hexdecimal string.
|
|
185
|
+
|
|
186
|
+
<br>
|
|
187
|
+
|
|
188
|
+
## UUID Version
|
|
189
|
+
|
|
190
|
+
Outputs the UUID version from a UUID input string.
|
|
191
|
+
|
|
192
|
+
<br>
|
|
193
|
+
|
|
194
|
+
## UUID Convert
|
|
195
|
+
|
|
196
|
+
Convert a UUID from one format to another. The plugin accepts strings in the correct format, however, the log will show
|
|
197
|
+
a warning if the input does not comply with the standard specified in [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122) and the
|
|
198
|
+
[proposed updates](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-01.html).
|
|
199
|
+
|
|
200
|
+
### Parameters
|
|
201
|
+
|
|
202
|
+
#### From
|
|
203
|
+
|
|
204
|
+
The input format
|
|
205
|
+
|
|
206
|
+
Options:
|
|
207
|
+
|
|
208
|
+
- **UUID/32-character hexadecimal string** (*uuid_hex*):
|
|
209
|
+
|
|
210
|
+
A standard UUID or a UUID as a 32-character lowercase hexadecimal string.
|
|
211
|
+
- **128-bit integer** (_int_):
|
|
212
|
+
|
|
213
|
+
The UUID as a 128-bit integer.
|
|
214
|
+
- **URN** (_urn_):
|
|
215
|
+
|
|
216
|
+
The UUID as a URN.
|
|
217
|
+
|
|
218
|
+
Default value: _UUID/32-character lowercase hexadecimal string_
|
|
219
|
+
ID: `from_format`
|
|
220
|
+
|
|
221
|
+
#### To
|
|
222
|
+
|
|
223
|
+
The output format
|
|
224
|
+
|
|
225
|
+
Options:
|
|
226
|
+
|
|
227
|
+
- **UUID** (_uuid_):
|
|
228
|
+
|
|
229
|
+
A standard UUID.
|
|
230
|
+
- **32-character lowercase hexadecimal string** (_hex_):
|
|
231
|
+
|
|
232
|
+
The UUID as a 32-character lowercase hexadecimal string.
|
|
233
|
+
- **128-bit integer** (_int_):
|
|
234
|
+
|
|
235
|
+
The UUID as a 128-bit integer.
|
|
236
|
+
- **URN** (_urn_):
|
|
237
|
+
|
|
238
|
+
The UUID as a URN as specified in [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122).
|
|
239
|
+
|
|
240
|
+
Default value: _32-character lowercase hexadecimal string_
|
|
241
|
+
ID: `to_format`
|
|
242
|
+
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# cmem-plugin-uuid
|
|
2
|
+
|
|
3
|
+
Create universally unique identifiers (UUIDs) versions 1, 3, 4, 5, 6, 7 and 8 in transformations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`cmemc -c my-cmem admin workspace python install cmem-plugin-uuid`
|
|
8
|
+
|
|
9
|
+
## UUID1
|
|
10
|
+
|
|
11
|
+
UUID1 version is generated from a host ID, sequence number, and the current time.
|
|
12
|
+
|
|
13
|
+
### Parameters
|
|
14
|
+
|
|
15
|
+
#### Node
|
|
16
|
+
|
|
17
|
+
Node value in the form "01:23:45:67:89:AB", "01-23-45-67-89-AB", or "0123456789AB".
|
|
18
|
+
If not given, [`uuid.getnode()`](https://docs.python.org/3/library/uuid.html#uuid.getnode) is used to
|
|
19
|
+
attempt to obtain the hardware address. If this is unsuccessful a random 48-bit number is chosen.
|
|
20
|
+
|
|
21
|
+
Default value: _None_
|
|
22
|
+
ID: `node`
|
|
23
|
+
|
|
24
|
+
#### Clock sequence
|
|
25
|
+
|
|
26
|
+
If clock sequence is given, it is used as the sequence number, otherwise a random 14-bit sequence number is chosen.
|
|
27
|
+
|
|
28
|
+
Default value: _None_
|
|
29
|
+
ID: `clock_seq`
|
|
30
|
+
|
|
31
|
+
<br>
|
|
32
|
+
|
|
33
|
+
## UUID3
|
|
34
|
+
|
|
35
|
+
UUID version 3 is a reproducible UUID based on the MD5 hash of a namespace identifier (which is a UUID) and a name
|
|
36
|
+
(which is a string).
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Parameters
|
|
40
|
+
|
|
41
|
+
#### Namespace
|
|
42
|
+
|
|
43
|
+
The namespace can be entered manually or selected from the namespace UUIDs defined in
|
|
44
|
+
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122):
|
|
45
|
+
|
|
46
|
+
- Namespace DNS: 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (*namespace_dns*)
|
|
47
|
+
- Namespace URL: 6ba7b811-9dad-11d1-80b4-00c04fd430c8 (*namespace_url*)
|
|
48
|
+
- Namespace OID: 6ba7b812-9dad-11d1-80b4-00c04fd430c8 (*namespace_oid*)
|
|
49
|
+
- Namespace X500: 6ba7b814-9dad-11d1-80b4-00c04fd430c8 (*namespace_x500*)
|
|
50
|
+
|
|
51
|
+
If none of the predefined namespace UUIDs is selected, the input namespace is either directly
|
|
52
|
+
interpreted as a UUID, or used to derive a UUID (see parameter _Namespace as UUID_). If no namespace is given,
|
|
53
|
+
the output is the same as that of the standard CMEM UUID operator with input value.
|
|
54
|
+
|
|
55
|
+
Default value: _none_
|
|
56
|
+
ID: `namespace`
|
|
57
|
+
|
|
58
|
+
#### Use input as namespace
|
|
59
|
+
|
|
60
|
+
If enabled, the input value is used for the namespace.
|
|
61
|
+
|
|
62
|
+
Default value: _False_
|
|
63
|
+
ID: `input_as_namespace`
|
|
64
|
+
|
|
65
|
+
#### Namespace as UUID
|
|
66
|
+
|
|
67
|
+
Applies only if none of the pre-defined namespaces is selected. If enabled, the namespace string
|
|
68
|
+
needs to be a valid UUID. Otherwise, the namespace UUID is a UUIDv1 derived from the MD5
|
|
69
|
+
hash of the namespace string.
|
|
70
|
+
|
|
71
|
+
Default value: _False_
|
|
72
|
+
ID: `namespace_as_uuid`
|
|
73
|
+
|
|
74
|
+
<br>
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## UUID4
|
|
78
|
+
|
|
79
|
+
UUID version 4 specifies a random UUID. This plugin is equivalent to the standard CMEM UUID operator without input value.
|
|
80
|
+
|
|
81
|
+
<br>
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## UUID5
|
|
85
|
+
|
|
86
|
+
UUID version 5 is a reproducible UUID based on the SHA1 hash of a namespace identifier (which is a UUID) and a
|
|
87
|
+
name (which is a string).
|
|
88
|
+
|
|
89
|
+
### Parameters
|
|
90
|
+
|
|
91
|
+
#### Namespace
|
|
92
|
+
|
|
93
|
+
The namespace can be entered manually or selected from the namespace UUIDs defined in
|
|
94
|
+
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122):
|
|
95
|
+
|
|
96
|
+
- Namespace DNS: 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (*namespace_dns*)
|
|
97
|
+
- Namespace URL: 6ba7b811-9dad-11d1-80b4-00c04fd430c8 (*namespace_url*)
|
|
98
|
+
- Namespace OID: 6ba7b812-9dad-11d1-80b4-00c04fd430c8 (*namespace_oid*)
|
|
99
|
+
- Namespace X500: 6ba7b814-9dad-11d1-80b4-00c04fd430c8 (*namespace_x500*)
|
|
100
|
+
|
|
101
|
+
If none of the predefined namespace UUIDs is selected, the input namespace is either directly
|
|
102
|
+
interpreted as a UUID, or used to derive a UUID (see parameter _Namespace as UUID_).
|
|
103
|
+
|
|
104
|
+
Default value: _none_
|
|
105
|
+
ID: `namespace`
|
|
106
|
+
|
|
107
|
+
#### Namespace as UUID
|
|
108
|
+
|
|
109
|
+
Applies only if none of the pre-defined namespaces is selected. If enabled, the namespace string
|
|
110
|
+
needs to be a valid UUID. Otherwise, the namespace UUID is a UUIDv1 derived from the SHA1
|
|
111
|
+
hash of the namespace string.
|
|
112
|
+
|
|
113
|
+
Default value: _False_
|
|
114
|
+
ID: `namespace_as_uuid`
|
|
115
|
+
|
|
116
|
+
<br>
|
|
117
|
+
|
|
118
|
+
## UUID6
|
|
119
|
+
|
|
120
|
+
UUID6 version is generated from a host ID, sequence number, and the current time.
|
|
121
|
+
UUID version 6 is a field-compatible version of UUIDv1, reordered for improved DB locality.
|
|
122
|
+
|
|
123
|
+
### Parameters
|
|
124
|
+
|
|
125
|
+
#### Node
|
|
126
|
+
|
|
127
|
+
Node value in the form "01:23:45:67:89:AB", "01-23-45-67-89-AB", or "0123456789AB".
|
|
128
|
+
If not given, a random 48-bit sequence number is chosen.
|
|
129
|
+
|
|
130
|
+
Default value: _None_
|
|
131
|
+
ID: `node`
|
|
132
|
+
|
|
133
|
+
#### Clock sequence
|
|
134
|
+
|
|
135
|
+
If clock sequence is given, it is used as the sequence number, otherwise a random 14-bit number is chosen.
|
|
136
|
+
|
|
137
|
+
Default value: _None_
|
|
138
|
+
ID: `clock_seq`
|
|
139
|
+
|
|
140
|
+
<br>
|
|
141
|
+
|
|
142
|
+
## UUID7
|
|
143
|
+
|
|
144
|
+
UUID version 7 features a time-ordered value field derived from the
|
|
145
|
+
widely implemented and well known Unix Epoch timestamp source, the
|
|
146
|
+
number of milliseconds since midnight 1 Jan 1970 UTC, leap seconds
|
|
147
|
+
excluded, as well as improved entropy characteristics over versions
|
|
148
|
+
1 or 6.
|
|
149
|
+
|
|
150
|
+
<br>
|
|
151
|
+
|
|
152
|
+
## UUID8
|
|
153
|
+
|
|
154
|
+
UUID version 8 features a time-ordered value field derived from the
|
|
155
|
+
widely implemented and well known Unix Epoch timestamp source, the
|
|
156
|
+
number of nanoseconds since midnight 1 Jan 1970 UTC, leap seconds
|
|
157
|
+
excluded.
|
|
158
|
+
|
|
159
|
+
<br>
|
|
160
|
+
|
|
161
|
+
## UUID1 to UUID6
|
|
162
|
+
|
|
163
|
+
Generate a UUID version 6 from a UUID version 1. The input needs to be a valid UUIDv1
|
|
164
|
+
hexdecimal string.
|
|
165
|
+
|
|
166
|
+
<br>
|
|
167
|
+
|
|
168
|
+
## UUID Version
|
|
169
|
+
|
|
170
|
+
Outputs the UUID version from a UUID input string.
|
|
171
|
+
|
|
172
|
+
<br>
|
|
173
|
+
|
|
174
|
+
## UUID Convert
|
|
175
|
+
|
|
176
|
+
Convert a UUID from one format to another. The plugin accepts strings in the correct format, however, the log will show
|
|
177
|
+
a warning if the input does not comply with the standard specified in [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122) and the
|
|
178
|
+
[proposed updates](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-01.html).
|
|
179
|
+
|
|
180
|
+
### Parameters
|
|
181
|
+
|
|
182
|
+
#### From
|
|
183
|
+
|
|
184
|
+
The input format
|
|
185
|
+
|
|
186
|
+
Options:
|
|
187
|
+
|
|
188
|
+
- **UUID/32-character hexadecimal string** (*uuid_hex*):
|
|
189
|
+
|
|
190
|
+
A standard UUID or a UUID as a 32-character lowercase hexadecimal string.
|
|
191
|
+
- **128-bit integer** (_int_):
|
|
192
|
+
|
|
193
|
+
The UUID as a 128-bit integer.
|
|
194
|
+
- **URN** (_urn_):
|
|
195
|
+
|
|
196
|
+
The UUID as a URN.
|
|
197
|
+
|
|
198
|
+
Default value: _UUID/32-character lowercase hexadecimal string_
|
|
199
|
+
ID: `from_format`
|
|
200
|
+
|
|
201
|
+
#### To
|
|
202
|
+
|
|
203
|
+
The output format
|
|
204
|
+
|
|
205
|
+
Options:
|
|
206
|
+
|
|
207
|
+
- **UUID** (_uuid_):
|
|
208
|
+
|
|
209
|
+
A standard UUID.
|
|
210
|
+
- **32-character lowercase hexadecimal string** (_hex_):
|
|
211
|
+
|
|
212
|
+
The UUID as a 32-character lowercase hexadecimal string.
|
|
213
|
+
- **128-bit integer** (_int_):
|
|
214
|
+
|
|
215
|
+
The UUID as a 128-bit integer.
|
|
216
|
+
- **URN** (_urn_):
|
|
217
|
+
|
|
218
|
+
The UUID as a URN as specified in [RFC 4122](https://www.rfc-editor.org/rfc/rfc4122).
|
|
219
|
+
|
|
220
|
+
Default value: _32-character lowercase hexadecimal string_
|
|
221
|
+
ID: `to_format`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""uuid - main package"""
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
"""UUID transform plugin module"""
|
|
2
|
+
import re
|
|
3
|
+
import uuid
|
|
4
|
+
from collections.abc import Sequence
|
|
5
|
+
|
|
6
|
+
import uuid6
|
|
7
|
+
from cmem_plugin_base.dataintegration.description import Plugin, PluginParameter
|
|
8
|
+
from cmem_plugin_base.dataintegration.plugins import TransformPlugin
|
|
9
|
+
from cmem_plugin_base.dataintegration.types import BoolParameterType
|
|
10
|
+
|
|
11
|
+
from cmem_plugin_uuid.utils import (
|
|
12
|
+
clock_seq_to_int,
|
|
13
|
+
get_namespace_uuid,
|
|
14
|
+
namespace_hex,
|
|
15
|
+
node_to_int,
|
|
16
|
+
uuid3_uuid5_namespace_param,
|
|
17
|
+
uuid_convert_param_in,
|
|
18
|
+
uuid_convert_param_out,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@Plugin(
|
|
23
|
+
label="UUID1",
|
|
24
|
+
categories=["Value", "Identifier"],
|
|
25
|
+
description="Generate a UUIDv1 from a host ID, sequence number, and the " "current time",
|
|
26
|
+
documentation="""
|
|
27
|
+
UUIDv1 is generated from a host ID, sequence number, and the current
|
|
28
|
+
time.
|
|
29
|
+
|
|
30
|
+
""",
|
|
31
|
+
parameters=[
|
|
32
|
+
PluginParameter(
|
|
33
|
+
name="node",
|
|
34
|
+
label="Node (default: hardware address)",
|
|
35
|
+
description=(
|
|
36
|
+
'Node value in the form "01:23:45:67:89:AB", 01-23-45-67-89-AB", or '
|
|
37
|
+
'"0123456789AB". If not given, it is attempted to obtain the hardware '
|
|
38
|
+
"address. If this is unsuccessful, a random 48-bit number is chosen."
|
|
39
|
+
),
|
|
40
|
+
default_value=None,
|
|
41
|
+
),
|
|
42
|
+
PluginParameter(
|
|
43
|
+
name="clock_seq",
|
|
44
|
+
label="Clock sequence (default: random)",
|
|
45
|
+
description=(
|
|
46
|
+
"If clock sequence is given, it is used as the sequence number. "
|
|
47
|
+
"Otherwise a random 14-bit sequence number is chosen."
|
|
48
|
+
),
|
|
49
|
+
default_value=None,
|
|
50
|
+
),
|
|
51
|
+
],
|
|
52
|
+
)
|
|
53
|
+
class UUID1(TransformPlugin):
|
|
54
|
+
"""UUID1 Transform Plugin"""
|
|
55
|
+
|
|
56
|
+
def __init__(
|
|
57
|
+
self,
|
|
58
|
+
node: str,
|
|
59
|
+
clock_seq: str,
|
|
60
|
+
):
|
|
61
|
+
self.node = node_to_int(node) if node else None
|
|
62
|
+
self.clock_seq = clock_seq_to_int(clock_seq) if clock_seq else None
|
|
63
|
+
|
|
64
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
65
|
+
"""Transform"""
|
|
66
|
+
result = []
|
|
67
|
+
if len(inputs) != 0:
|
|
68
|
+
for collection in inputs:
|
|
69
|
+
result += [
|
|
70
|
+
str(uuid.uuid1(node=self.node, clock_seq=self.clock_seq)) for _ in collection
|
|
71
|
+
]
|
|
72
|
+
else:
|
|
73
|
+
result = [str(uuid.uuid1(node=self.node, clock_seq=self.clock_seq))]
|
|
74
|
+
return result
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@Plugin(
|
|
78
|
+
label="UUID3",
|
|
79
|
+
categories=["Value", "Identifier"],
|
|
80
|
+
description="Generate a UUIDv3",
|
|
81
|
+
documentation="""UUID3 is based on the MD5 hash of a namespace identifier (which
|
|
82
|
+
is a UUID) and a name (which is a string).""",
|
|
83
|
+
parameters=[
|
|
84
|
+
PluginParameter(
|
|
85
|
+
param_type=uuid3_uuid5_namespace_param,
|
|
86
|
+
name="namespace",
|
|
87
|
+
label="Namespace",
|
|
88
|
+
description="The namespace.",
|
|
89
|
+
default_value="",
|
|
90
|
+
),
|
|
91
|
+
PluginParameter(
|
|
92
|
+
param_type=BoolParameterType(),
|
|
93
|
+
name="namespace_as_uuid",
|
|
94
|
+
label="Namespace as UUID",
|
|
95
|
+
description=(
|
|
96
|
+
"Applies only if none of the pre-defined namespaces is selected. If "
|
|
97
|
+
"enabled, the namespace string needs to be a valid UUID. "
|
|
98
|
+
"Otherwise, the namespace UUID is a UUIDv1 derived from the MD5 hash "
|
|
99
|
+
"of the namespace string."
|
|
100
|
+
),
|
|
101
|
+
default_value=False,
|
|
102
|
+
),
|
|
103
|
+
],
|
|
104
|
+
)
|
|
105
|
+
class UUID3(TransformPlugin):
|
|
106
|
+
"""UUID3 Transform Plugin"""
|
|
107
|
+
|
|
108
|
+
def __init__(
|
|
109
|
+
self,
|
|
110
|
+
namespace: str,
|
|
111
|
+
namespace_as_uuid: bool | None,
|
|
112
|
+
):
|
|
113
|
+
self.namespace = namespace
|
|
114
|
+
self.namespace_as_uuid = namespace_as_uuid
|
|
115
|
+
|
|
116
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
117
|
+
"""Transform"""
|
|
118
|
+
result = []
|
|
119
|
+
namespace_uuid = get_namespace_uuid(
|
|
120
|
+
namespace_as_uuid=self.namespace_as_uuid,
|
|
121
|
+
namespace=self.namespace,
|
|
122
|
+
uuid_version=3,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
if len(inputs) != 0:
|
|
126
|
+
for collection in inputs:
|
|
127
|
+
for _ in collection:
|
|
128
|
+
if not self.namespace.strip():
|
|
129
|
+
result += [str(uuid.UUID(hex=namespace_hex(_, 3), version=3))]
|
|
130
|
+
else:
|
|
131
|
+
result += [str(uuid.uuid3(namespace_uuid, _))] # type: ignore[arg-type]
|
|
132
|
+
else:
|
|
133
|
+
raise ValueError("No input for UUID3")
|
|
134
|
+
return result
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@Plugin(
|
|
138
|
+
label="UUID4",
|
|
139
|
+
categories=["Value", "Identifier"],
|
|
140
|
+
description="Generate a random UUIDv4.",
|
|
141
|
+
documentation="""UUIDv4 specifies a random UUID.""",
|
|
142
|
+
)
|
|
143
|
+
class UUID4(TransformPlugin):
|
|
144
|
+
"""UUID4 Transform Plugin"""
|
|
145
|
+
|
|
146
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
147
|
+
"""Transform"""
|
|
148
|
+
result = []
|
|
149
|
+
if len(inputs) != 0:
|
|
150
|
+
for collection in inputs:
|
|
151
|
+
result += [str(uuid.uuid4()) for _ in collection]
|
|
152
|
+
else:
|
|
153
|
+
result = [str(uuid.uuid4())]
|
|
154
|
+
return result
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@Plugin(
|
|
158
|
+
label="UUID5",
|
|
159
|
+
categories=["Value", "Identifier"],
|
|
160
|
+
description="Generate a UUIDv5",
|
|
161
|
+
documentation="""UUID5 is based on the SHA1 hash of a namespace identifier (which
|
|
162
|
+
is a UUID) and a name (which is a string).""",
|
|
163
|
+
parameters=[
|
|
164
|
+
PluginParameter(
|
|
165
|
+
param_type=uuid3_uuid5_namespace_param,
|
|
166
|
+
name="namespace",
|
|
167
|
+
label="Namespace",
|
|
168
|
+
description="If 'namespace' is not given, the input string is used.",
|
|
169
|
+
default_value="",
|
|
170
|
+
),
|
|
171
|
+
PluginParameter(
|
|
172
|
+
param_type=BoolParameterType(),
|
|
173
|
+
name="namespace_as_uuid",
|
|
174
|
+
label="Namespace as UUID",
|
|
175
|
+
description=(
|
|
176
|
+
"Applies only if none of the pre-defined namespaces is selected. If "
|
|
177
|
+
"enabled, the namespace string needs to be a valid UUID. "
|
|
178
|
+
"Otherwise, the namespace UUID is a UUIDv1 derived from the SHA1 hash "
|
|
179
|
+
"of the namespace string."
|
|
180
|
+
),
|
|
181
|
+
default_value=False,
|
|
182
|
+
),
|
|
183
|
+
],
|
|
184
|
+
)
|
|
185
|
+
class UUID5(TransformPlugin):
|
|
186
|
+
"""UUID5 Transform Plugin"""
|
|
187
|
+
|
|
188
|
+
def __init__(
|
|
189
|
+
self,
|
|
190
|
+
namespace: str,
|
|
191
|
+
namespace_as_uuid: bool | None,
|
|
192
|
+
):
|
|
193
|
+
self.namespace = namespace
|
|
194
|
+
self.namespace_as_uuid = namespace_as_uuid
|
|
195
|
+
|
|
196
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
197
|
+
"""Transform"""
|
|
198
|
+
result = []
|
|
199
|
+
namespace_uuid = get_namespace_uuid(
|
|
200
|
+
namespace_as_uuid=self.namespace_as_uuid,
|
|
201
|
+
namespace=self.namespace,
|
|
202
|
+
uuid_version=5,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
if len(inputs) != 0:
|
|
206
|
+
for collection in inputs:
|
|
207
|
+
for _ in collection:
|
|
208
|
+
if not self.namespace.strip():
|
|
209
|
+
result += [str(uuid.UUID(hex=namespace_hex(_, 5), version=5))]
|
|
210
|
+
else:
|
|
211
|
+
result += [str(uuid.uuid5(namespace_uuid, _))] # type: ignore[arg-type]
|
|
212
|
+
else:
|
|
213
|
+
raise ValueError("No input for UUID5")
|
|
214
|
+
return result
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
@Plugin(
|
|
218
|
+
label="UUID6",
|
|
219
|
+
categories=["Value", "Identifier"],
|
|
220
|
+
description="Generate a UUIDv6 from a host ID, sequence number, and the " "current time",
|
|
221
|
+
documentation="""
|
|
222
|
+
UUIDv6 is generated from a host ID, sequence number, and the current
|
|
223
|
+
time.
|
|
224
|
+
|
|
225
|
+
UUIDv6 is a field-compatible version of UUIDv1, reordered for
|
|
226
|
+
improved DB locality. It is expected that UUIDv6 will primarily be
|
|
227
|
+
used in contexts where there are existing v1 UUIDs. Systems that do
|
|
228
|
+
not involve legacy UUIDv1 SHOULD consider using UUIDv7 instead.
|
|
229
|
+
""",
|
|
230
|
+
parameters=[
|
|
231
|
+
PluginParameter(
|
|
232
|
+
name="node",
|
|
233
|
+
label="Node (default: hardware address)",
|
|
234
|
+
description=(
|
|
235
|
+
'Node value in the form "01:23:45:67:89:AB", 01-23-45-67-89-AB", or '
|
|
236
|
+
'"0123456789AB". If not given, a random 48-bit number is chosen.'
|
|
237
|
+
),
|
|
238
|
+
default_value="",
|
|
239
|
+
),
|
|
240
|
+
PluginParameter(
|
|
241
|
+
name="clock_seq",
|
|
242
|
+
label="Clock sequence (default: random)",
|
|
243
|
+
description=(
|
|
244
|
+
"If clock sequence is given, it is used as the sequence number. "
|
|
245
|
+
"Otherwise a random 14-bit number is chosen."
|
|
246
|
+
),
|
|
247
|
+
default_value="",
|
|
248
|
+
),
|
|
249
|
+
],
|
|
250
|
+
)
|
|
251
|
+
class UUID6(TransformPlugin):
|
|
252
|
+
"""UUID6 Transform Plugin"""
|
|
253
|
+
|
|
254
|
+
def __init__(
|
|
255
|
+
self,
|
|
256
|
+
node: str,
|
|
257
|
+
clock_seq: str,
|
|
258
|
+
):
|
|
259
|
+
self.node = node_to_int(node) if node else None
|
|
260
|
+
self.clock_seq = clock_seq_to_int(clock_seq) if clock_seq else None
|
|
261
|
+
|
|
262
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
263
|
+
"""Transform"""
|
|
264
|
+
result = []
|
|
265
|
+
if len(inputs) != 0:
|
|
266
|
+
for collection in inputs:
|
|
267
|
+
result += [
|
|
268
|
+
str(uuid6.uuid6(node=self.node, clock_seq=self.clock_seq)) for _ in collection
|
|
269
|
+
]
|
|
270
|
+
else:
|
|
271
|
+
result = [str(uuid6.uuid6(node=self.node, clock_seq=self.clock_seq))]
|
|
272
|
+
return result
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
@Plugin(
|
|
276
|
+
label="UUID1 to UUID6",
|
|
277
|
+
categories=["Value", "Identifier"],
|
|
278
|
+
description="Generate UUIDv6 from a UUIDv1.",
|
|
279
|
+
documentation="""
|
|
280
|
+
UUIDv6 is a field-compatible version of UUIDv1, reordered for
|
|
281
|
+
improved DB locality. It is expected that UUIDv6 will primarily be
|
|
282
|
+
used in contexts where there are existing v1 UUIDs. Systems that do
|
|
283
|
+
not involve legacy UUIDv1 SHOULD consider using UUIDv7 instead.
|
|
284
|
+
""",
|
|
285
|
+
)
|
|
286
|
+
class UUID1ToUUID6(TransformPlugin):
|
|
287
|
+
"""UUID1 to UUID6 Transform Plugin"""
|
|
288
|
+
|
|
289
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
290
|
+
"""Transform"""
|
|
291
|
+
result = []
|
|
292
|
+
if len(inputs) != 0:
|
|
293
|
+
for collection in inputs:
|
|
294
|
+
for _ in collection:
|
|
295
|
+
try:
|
|
296
|
+
result += [str(uuid6.uuid1_to_uuid6(uuid.UUID(_)))]
|
|
297
|
+
except ValueError as exc:
|
|
298
|
+
raise ValueError(f"{_} is not a valid UUIDv1 string") from exc
|
|
299
|
+
else:
|
|
300
|
+
raise ValueError("No input for UUID1 to UUID6")
|
|
301
|
+
return result
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
@Plugin(
|
|
305
|
+
label="UUID7",
|
|
306
|
+
categories=["Value", "Identifier"],
|
|
307
|
+
description="Generate a UUIDv7 from a random number, and the current time.",
|
|
308
|
+
documentation="""UUIDv7 features a time-ordered value field derived from the
|
|
309
|
+
widely implemented and well known Unix Epoch timestamp source, the
|
|
310
|
+
number of milliseconds since midnight 1 Jan 1970 UTC, leap seconds
|
|
311
|
+
excluded. As well as improved entropy characteristics over versions
|
|
312
|
+
1 or 6.
|
|
313
|
+
Implementations SHOULD utilize UUIDv7 over UUIDv1 and
|
|
314
|
+
6 if possible.
|
|
315
|
+
""",
|
|
316
|
+
)
|
|
317
|
+
class UUID7(TransformPlugin):
|
|
318
|
+
"""UUID7 Transform Plugin"""
|
|
319
|
+
|
|
320
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
321
|
+
"""Transform"""
|
|
322
|
+
result = []
|
|
323
|
+
if len(inputs) != 0:
|
|
324
|
+
for collection in inputs:
|
|
325
|
+
result += [str(uuid6.uuid7()) for _ in collection]
|
|
326
|
+
else:
|
|
327
|
+
result = [str(uuid6.uuid7())]
|
|
328
|
+
return result
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
@Plugin(
|
|
332
|
+
label="UUID8",
|
|
333
|
+
categories=["Value", "Identifier"],
|
|
334
|
+
description="Generate a UUIDv8 from a random number, and the current time.",
|
|
335
|
+
documentation="""UUIDv8 features a time-ordered value field derived from the
|
|
336
|
+
widely implemented and well known Unix Epoch timestamp source, the
|
|
337
|
+
number of nanoseconds since midnight 1 Jan 1970 UTC, leap seconds
|
|
338
|
+
excluded.
|
|
339
|
+
""",
|
|
340
|
+
)
|
|
341
|
+
class UUID8(TransformPlugin):
|
|
342
|
+
"""UUID8 Transform Plugin"""
|
|
343
|
+
|
|
344
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
345
|
+
"""Transform"""
|
|
346
|
+
result = []
|
|
347
|
+
if len(inputs) != 0:
|
|
348
|
+
for collection in inputs:
|
|
349
|
+
result += [str(uuid6.uuid8()) for _ in collection]
|
|
350
|
+
else:
|
|
351
|
+
result = [str(uuid6.uuid8())]
|
|
352
|
+
return result
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
@Plugin(
|
|
356
|
+
label="UUID Convert",
|
|
357
|
+
categories=["Value", "Identifier"],
|
|
358
|
+
description="Convert a UUID string representation",
|
|
359
|
+
documentation="""Convert a UUID string with 32 hexadecimal digits to a 16-byte
|
|
360
|
+
string containing the six integer fields in big-endian byte order, a 16-byte string
|
|
361
|
+
the six integer fields in little-endian byte order, a 32-character lowercase
|
|
362
|
+
hexadecimal string, a 128-bit integer, or a URN. Strings in the correct format,
|
|
363
|
+
however, the log will show a warning if the input does not comply with the standard
|
|
364
|
+
specified in RFC 4122 and the proposed updates""",
|
|
365
|
+
parameters=[
|
|
366
|
+
PluginParameter(
|
|
367
|
+
param_type=uuid_convert_param_in,
|
|
368
|
+
name="from_format",
|
|
369
|
+
label="From",
|
|
370
|
+
description="Input string format",
|
|
371
|
+
default_value="uuid_hex",
|
|
372
|
+
),
|
|
373
|
+
PluginParameter(
|
|
374
|
+
param_type=uuid_convert_param_out,
|
|
375
|
+
name="to_format",
|
|
376
|
+
label="To",
|
|
377
|
+
description="Output string format",
|
|
378
|
+
default_value="hex",
|
|
379
|
+
),
|
|
380
|
+
],
|
|
381
|
+
)
|
|
382
|
+
class UUIDConvert(TransformPlugin):
|
|
383
|
+
"""Converts UUID representation"""
|
|
384
|
+
|
|
385
|
+
def __init__(self, from_format: str | None, to_format: str | None) -> None:
|
|
386
|
+
self.from_ = from_format
|
|
387
|
+
self.to_ = to_format
|
|
388
|
+
|
|
389
|
+
def uuid_validate(self, test_uuid: uuid.UUID, uuid_string: str) -> None:
|
|
390
|
+
"""Warning if UUID string not standard (versions 1 to 8)"""
|
|
391
|
+
pattern = r"^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
392
|
+
|
|
393
|
+
if not re.match(pattern, str(test_uuid)):
|
|
394
|
+
self.log.warning(
|
|
395
|
+
f"{uuid_string} is not a valid UUID as specified in RFC 4122 and "
|
|
396
|
+
f"the proposed updates"
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
def convert_uuid(self, uuid_string: str) -> str: # noqa: PLR0912 C901
|
|
400
|
+
"""Convert UUID string"""
|
|
401
|
+
if self.from_ == "uuid_hex":
|
|
402
|
+
try:
|
|
403
|
+
in_uuid = uuid.UUID(uuid_string)
|
|
404
|
+
except ValueError as exc:
|
|
405
|
+
raise ValueError(f"{uuid_string} is not a valid 32-bit UUID string") from exc
|
|
406
|
+
|
|
407
|
+
elif self.from_ == "int":
|
|
408
|
+
try:
|
|
409
|
+
in_uuid = uuid.UUID(int=int(uuid_string))
|
|
410
|
+
except ValueError as exc:
|
|
411
|
+
raise ValueError(
|
|
412
|
+
f"{uuid_string} is not a valid 128-bit integer UUID value"
|
|
413
|
+
) from exc
|
|
414
|
+
|
|
415
|
+
elif self.from_ == "urn":
|
|
416
|
+
if not uuid_string.lower().startswith("urn:uuid:"):
|
|
417
|
+
raise ValueError(f"{uuid_string} is not a valid UUID URN")
|
|
418
|
+
|
|
419
|
+
try:
|
|
420
|
+
in_uuid = uuid.UUID(uuid_string[9:])
|
|
421
|
+
except ValueError as exc:
|
|
422
|
+
raise ValueError(f"{uuid_string} is not a valid UUID URN") from exc
|
|
423
|
+
|
|
424
|
+
self.uuid_validate(in_uuid, uuid_string)
|
|
425
|
+
|
|
426
|
+
if self.to_ == "uuid":
|
|
427
|
+
result = str(in_uuid)
|
|
428
|
+
if self.to_ == "hex":
|
|
429
|
+
result = str(in_uuid.hex)
|
|
430
|
+
elif self.to_ == "int":
|
|
431
|
+
result = str(in_uuid.int)
|
|
432
|
+
elif self.to_ == "urn":
|
|
433
|
+
result = str(in_uuid.urn)
|
|
434
|
+
return result
|
|
435
|
+
|
|
436
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
437
|
+
"""Trasnform"""
|
|
438
|
+
result = []
|
|
439
|
+
if len(inputs) != 0:
|
|
440
|
+
for collection in inputs:
|
|
441
|
+
result += [self.convert_uuid(_) for _ in collection]
|
|
442
|
+
else:
|
|
443
|
+
raise ValueError("No input for UUID Convert")
|
|
444
|
+
return result
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
@Plugin(
|
|
448
|
+
label="UUID Version",
|
|
449
|
+
categories=["Value", "Identifier"],
|
|
450
|
+
description="Outputs UUID version number of input",
|
|
451
|
+
documentation="""Input: UUID string, output: UUID version number of input.""",
|
|
452
|
+
)
|
|
453
|
+
class UUIDVersion(TransformPlugin):
|
|
454
|
+
"""Outputs UUID version number"""
|
|
455
|
+
|
|
456
|
+
def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]:
|
|
457
|
+
"""Transform"""
|
|
458
|
+
result = []
|
|
459
|
+
if len(inputs) != 0:
|
|
460
|
+
for collection in inputs:
|
|
461
|
+
result += [str(uuid.UUID(_).version) for _ in collection]
|
|
462
|
+
else:
|
|
463
|
+
raise ValueError("No input for UUID Version")
|
|
464
|
+
return result
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""Utilities for cmem-plugin-uuid"""
|
|
2
|
+
|
|
3
|
+
import uuid
|
|
4
|
+
from binascii import unhexlify
|
|
5
|
+
from collections import OrderedDict
|
|
6
|
+
from hashlib import md5, sha1
|
|
7
|
+
|
|
8
|
+
from cmem_plugin_base.dataintegration.parameter.choice import ChoiceParameterType
|
|
9
|
+
|
|
10
|
+
uuid3_uuid5_namespace_param = ChoiceParameterType(
|
|
11
|
+
OrderedDict(
|
|
12
|
+
{
|
|
13
|
+
"namespace_url": "Namespace URL",
|
|
14
|
+
"namespace_dns": "Namespace DNS",
|
|
15
|
+
"namespace_oid": "Namespace OID",
|
|
16
|
+
"namespace_x500": "Namespace X500",
|
|
17
|
+
"": "",
|
|
18
|
+
}
|
|
19
|
+
),
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
uuid3_uuid5_namespace_param.allow_only_autocompleted_values = False
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
uuid_convert_param_in = ChoiceParameterType(
|
|
27
|
+
OrderedDict(
|
|
28
|
+
{
|
|
29
|
+
"uuid_hex": "UUID/32-char hexadecimal string",
|
|
30
|
+
"int": "128-bit integer",
|
|
31
|
+
"urn": "URN",
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
uuid_convert_param_in.allow_only_autocompleted_values = True
|
|
37
|
+
|
|
38
|
+
uuid_convert_param_out = ChoiceParameterType(
|
|
39
|
+
OrderedDict(
|
|
40
|
+
{
|
|
41
|
+
"uuid": "UUID",
|
|
42
|
+
"hex": "32-character lowercase hexadecimal string",
|
|
43
|
+
"int": "128-bit integer",
|
|
44
|
+
"urn": "URN",
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
uuid_convert_param_out.allow_only_autocompleted_values = True
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def node_to_int(node: str) -> int:
|
|
53
|
+
"""Convert a string representation of a node byte array to an integer"""
|
|
54
|
+
try:
|
|
55
|
+
byte_string = node.replace(":", "").replace("-", "")
|
|
56
|
+
byte_array = unhexlify(byte_string)
|
|
57
|
+
return int.from_bytes(byte_array, byteorder="big", signed=False)
|
|
58
|
+
except ValueError as exc:
|
|
59
|
+
raise ValueError(f"node: {exc} ({node})") from exc
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def clock_seq_to_int(clock_seq: str) -> int:
|
|
63
|
+
"""Convert a string representation of a clock_seq to an integer."""
|
|
64
|
+
try:
|
|
65
|
+
return int(clock_seq)
|
|
66
|
+
except ValueError as exc:
|
|
67
|
+
raise ValueError(f"clock_seq: {exc} ({clock_seq})") from exc
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def namespace_hex(value: str, uuid_version: int) -> str | None:
|
|
71
|
+
"""Return hex string from input value"""
|
|
72
|
+
hex_value = None
|
|
73
|
+
if uuid_version == 3: # noqa: PLR2004
|
|
74
|
+
hex_value = md5(value.encode(), usedforsecurity=False).hexdigest()
|
|
75
|
+
elif uuid_version == 5: # noqa: PLR2004
|
|
76
|
+
hex_value = sha1(value.encode(), usedforsecurity=False).hexdigest()[:32]
|
|
77
|
+
return hex_value
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def get_namespace_uuid(
|
|
81
|
+
namespace_as_uuid: bool | None,
|
|
82
|
+
namespace: str,
|
|
83
|
+
uuid_version: int,
|
|
84
|
+
) -> uuid.UUID | None:
|
|
85
|
+
"""Return namespace UUID"""
|
|
86
|
+
namespace_uuid = None
|
|
87
|
+
|
|
88
|
+
if namespace == "namespace_url":
|
|
89
|
+
namespace_uuid = uuid.NAMESPACE_URL
|
|
90
|
+
elif namespace == "namespace_dns":
|
|
91
|
+
namespace_uuid = uuid.NAMESPACE_DNS
|
|
92
|
+
elif namespace == "namespace_oid":
|
|
93
|
+
namespace_uuid = uuid.NAMESPACE_OID
|
|
94
|
+
elif namespace == "namespace_x500":
|
|
95
|
+
namespace_uuid = uuid.NAMESPACE_X500
|
|
96
|
+
elif namespace.strip():
|
|
97
|
+
if namespace_as_uuid:
|
|
98
|
+
namespace_uuid = uuid.UUID(namespace)
|
|
99
|
+
else:
|
|
100
|
+
namespace_uuid = uuid.UUID(hex=namespace_hex(namespace, uuid_version), version=1)
|
|
101
|
+
|
|
102
|
+
return namespace_uuid
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "cmem-plugin-uuid"
|
|
3
|
+
version = "1.0.0rc1"
|
|
4
|
+
license = "Apache-2.0"
|
|
5
|
+
description = "Create universally unique identifiers (UUIDs) versions 1, 3, 4, 5, 6, 7 and 8 in transformations."
|
|
6
|
+
authors = ["eccenca GmbH <cmempy-developer@eccenca.com>"]
|
|
7
|
+
classifiers = [
|
|
8
|
+
"Development Status :: 4 - Beta",
|
|
9
|
+
"Environment :: Plugins",
|
|
10
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
11
|
+
]
|
|
12
|
+
readme = "README-public.md"
|
|
13
|
+
keywords = [
|
|
14
|
+
"eccenca Corporate Memory", "plugin", "UUID"
|
|
15
|
+
]
|
|
16
|
+
homepage = "https://github.com/eccenca/cmem-plugin-uuid"
|
|
17
|
+
|
|
18
|
+
[tool.poetry.dependencies]
|
|
19
|
+
# if you need to change python version here, change it also in .python-version
|
|
20
|
+
python = "^3.11"
|
|
21
|
+
uuid6 = ">=2023.5.2"
|
|
22
|
+
|
|
23
|
+
[tool.poetry.dependencies.cmem-plugin-base]
|
|
24
|
+
version = "^4.3.0"
|
|
25
|
+
allow-prereleases = false
|
|
26
|
+
|
|
27
|
+
[tool.poetry.group.dev.dependencies]
|
|
28
|
+
genbadge = {extras = ["coverage"], version = "^1.1.1"}
|
|
29
|
+
mypy = "^1.2.0"
|
|
30
|
+
pip = ">=23.3" # Avoid safety issue 62044 for pip less than 23.3
|
|
31
|
+
pytest = "^7.3.1"
|
|
32
|
+
pytest-cov = "^4.1.0"
|
|
33
|
+
pytest-dotenv = "^0.5.2"
|
|
34
|
+
pytest-memray = { version = "^1.5.0", markers = "platform_system != 'Windows'" }
|
|
35
|
+
ruff = "^0.1.5"
|
|
36
|
+
safety = "^1.10.3"
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["poetry-core>=1.0.0","poetry-dynamic-versioning"]
|
|
40
|
+
build-backend = "poetry_dynamic_versioning.backend"
|
|
41
|
+
|
|
42
|
+
[tool.poetry-dynamic-versioning]
|
|
43
|
+
enable = false
|
|
44
|
+
vcs = "git"
|
|
45
|
+
dirty = true
|
|
46
|
+
bump = true
|
|
47
|
+
|
|
48
|
+
[tool.mypy]
|
|
49
|
+
warn_return_any = true
|
|
50
|
+
ignore_missing_imports = true
|
|
51
|
+
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
addopts = ""
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
line-length = 100
|
|
57
|
+
target-version = "py311"
|
|
58
|
+
|
|
59
|
+
[tool.ruff.format]
|
|
60
|
+
line-ending = "lf" # Use `\n` line endings for all files
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = ["ALL"]
|
|
64
|
+
ignore = [
|
|
65
|
+
"ANN101", # Missing type annotation for self in method
|
|
66
|
+
"ANN204", # Missing return type annotation for special method `__init__`
|
|
67
|
+
"COM812", # missing-trailing-comma
|
|
68
|
+
"D107", # Missing docstring in __init__
|
|
69
|
+
"D203", # [*] 1 blank line required before class docstring
|
|
70
|
+
"D211", # No blank lines allowed before class docstring
|
|
71
|
+
"D213", # Multi-line docstring summary should start at the second line
|
|
72
|
+
"D400", # First line should end with a period
|
|
73
|
+
"D415", # First line should end with a period, question mark, or exclamation point
|
|
74
|
+
"EM", # Exception texts - https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
|
|
75
|
+
"FBT", # The Boolean Trap - https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
|
|
76
|
+
"FIX002", # Allow to add TODO notes in the code
|
|
77
|
+
"G004", # Logging statement uses f-string
|
|
78
|
+
"ISC001", # single-line-implicit-string-concatenation
|
|
79
|
+
"PD", # opinionated linting for pandas code
|
|
80
|
+
"S101", # use of assert detected
|
|
81
|
+
"TRY003", # Avoid specifying long messages outside the exception class
|
|
82
|
+
]
|