This module contains various utilty functions to handle, test and manipulate IDs.
There are no ACME CSE internal dependencies. This heelps to keep the module small and standalone.
| Function | csi |
Get the csi from an unstructured CSE-relative, SP-relative, or absolute ID. |
| Function | csi |
Return the csi from a SP-relative resource ID. It is assumed that the passed ri is in SP-relative format. |
| Function | get |
Get AE-ID-Stem or CSE-ID from the originator (in case SP-relative or Absolute was used). |
| Function | get |
Get the SP-ID from an Absolute resource ID. If the ID is not in absolute format, None is returned. |
| Function | has |
Test that an ID only contains characters from the unreserved character set of RFC 3986. |
| Function | is |
Test whether a URI is in absolute format. |
| Function | is |
Test whether a URI is in CSE-relative format. |
| Function | is |
Test whether a URI is a CSE-ID. |
| Function | is |
Test whether a URI is SP-Relative. |
| Function | is |
Test whether a URI is in structured format. |
| Function | is |
Test for valid AE-ID format. |
| Function | is |
Test for valid CSE-ID format. |
| Function | is |
Test for a valid ID. |
| Function | is |
Test for a valid path. A path is a string that does not start with a slash and does not contain spaces and invalid characters. It may contain slashes, but not at the beginning. |
| Function | is |
Test for valid SP-ID format. |
| Function | local |
Test whether an ID is a resource ID of the local CSE. |
| Function | no |
Remove the namespace part of an identifier and return the remainder. |
| Function | originator |
Convert an originator to a resource ID. The originator is expected to be in CSE-relative, SP-relative or absolute format. |
| Function | to |
Convert an ID to absolute format. |
| Function | to |
Convert an id to CSE-Relative format. |
| Function | to |
Add the CSI to an originator (if not already present). |
| Function | unique |
Create a new AE ID. An AE ID must always start with either "S" or "C". |
| Function | unique |
Generate a unique ID. This is for the moment just a large random number. NO check for uniqueness is done. |
| Function | unique |
Generate a unique resource ID. Beside a random number it can have a prefix. |
| Function | unique |
Generate a unique resource name. A resource name has a prefix and a random alpha-numeric string. |
| Function | _random |
Generate an ID. Prevent certain patterns in the ID. |
| Variable | _ae |
Regular expression to test for valid AE-ID format. |
| Variable | _csi |
Regular expression to test for valid CSE-ID format (unreserved characters in IDs according to RFC 3986). |
| Variable | _random |
Character set for random IDs. |
| Variable | _spid |
Regular expression to test for valid SP-ID format (unreserved characters in IDs according to RFC 3986). |
| Variable | _unreserved |
Regular expression to test for unreserved characters. |
Get the csi from an unstructured CSE-relative, SP-relative, or absolute ID.
| Parameters | |
id:str | unstructured ID. |
| Returns | |
tuple[ | Tuple (CSE ID (no leading slashes) without any SP-ID or CSE-ID, list of path elements). If the ID is None or empty, the return value is ('', []). |
Return the csi from a SP-relative resource ID. It is assumed that the passed ri is in SP-relative format.
| Parameters | |
ri:str | A SP-relative resource ID |
| Returns | |
str | None | The csi of the resource ID, or None |
Get AE-ID-Stem or CSE-ID from the originator (in case SP-relative or Absolute was used).
| Parameters | |
originator:str | An originator. |
idbool | None | Indicator that only the CSE-local resource ID is provided. |
| Returns | |
str | Resource ID. |
Get the SP-ID from an Absolute resource ID. If the ID is not in absolute format, None is returned.
| Parameters | |
id:str | An Absolute resource ID. |
| Returns | |
str | The SP-ID of the resource ID without leading slashes, or None if the ID is not in absolute format. |
Test that an ID only contains characters from the unreserved character set of RFC 3986.
| Parameters | |
id:str | the ID to check. |
| Returns | |
bool | Boolean |
Test whether a URI is in absolute format.
| Parameters | |
uri:str | The URI to check |
| Returns | |
bool | Boolean if the URI is in absolute format |
Test whether a URI is in CSE-relative format.
| Parameters | |
uri:str | The URI to check |
| Returns | |
bool | Boolean if the URI is in CSE-relative format |
Test whether a URI is a CSE-ID.
| Parameters | |
uri:str | The URI to check |
| Returns | |
bool | Boolean if the URI is a CSE-ID |
Test whether a URI is in structured format.
| Parameters | |
uri:str | The URI to check |
| Returns | |
bool | Boolean if the URI is in structured format |
Test for valid AE-ID format.
It takes SP-Relative AEI's into account.
| Parameters | |
aei:str | The AE-ID to check |
| Returns | |
bool | Boolean |
Test for a valid ID.
| Parameters | |
id:str | The ID to check |
allowbool | None | Indicate whether an ID can be empty. |
| Returns | |
bool | Boolean |
Test for a valid path. A path is a string that does not start with a slash and does not contain spaces and invalid characters. It may contain slashes, but not at the beginning.
| Parameters | |
id:str | The ID to check |
| Returns | |
bool | Boolean |
Test whether an ID is a resource ID of the local CSE.
| Parameters | |
ri:str | A resource ID in CSE-relative, SP-relative, or absolute notation. |
| Returns | |
str | None | If the ID targets a local resource then the CSE-relative form of the resource ID is returned, or None otherwise. |
Remove the namespace part of an identifier and return the remainder.
Example
'm2m:cnt' -> 'cnt'
| Parameters | |
id:str | String with the identifier. May be prefixed with a domain. |
| Returns | |
str | String that only contains the ID |
Convert an originator to a resource ID. The originator is expected to be in CSE-relative, SP-relative or absolute format.
| Parameters | |
originator:str | An originator in CSE-relative, SP-relative or absolute format. |
| Returns | |
str | A resource ID in CSE-relative format. |
Convert an ID to absolute format.
| Parameters | |
id:str | An ID in CSE-Relative or SP-Relative format. |
spstr | None | Optional SP-ID. If not provided, the CSE-ID is used. |
| Returns | |
str | An ID in absolute format. |
Convert an id to CSE-Relative format.
| Parameters | |
id:str | An ID in SP-relative or absolute format. |
| Returns | |
str | An ID in CSE-Relative format. |
Add the CSI to an originator (if not already present).
| Parameters | |
id:str | A string with the originator or resource ID to convert. |
| Returns | |
str | A string in the format /<csi>/<id>. |
Create a new AE ID. An AE ID must always start with either "S" or "C".
| Parameters | |
prefix:str | None | "S" or "C" |
| Returns | |
str | String with the AE ID |
Generate a unique ID. This is for the moment just a large random number. NO check for uniqueness is done.
| Returns | |
str | String with the identifier |
Generate a unique resource ID. Beside a random number it can have a prefix.
| Parameters | |
prefix:str | None | Prefix for the ID |
| Returns | |
str | String with the new ID |
Generate a unique resource name. A resource name has a prefix and a random alpha-numeric string.
| Parameters | |
prefix:str | String prefix. If it contains a domain then that is removed |
| Returns | |
str | String with the resource name |
Regular expression to test for valid CSE-ID format (unreserved characters in IDs according to RFC 3986).
Regular expression to test for valid SP-ID format (unreserved characters in IDs according to RFC 3986).