otupy.profiles.ctxd.data.service.SId
- class SId(sid: str = None, type: str = None, subtype: str = None, domain: str = None, namespace: str = None, name: str = None, version: str = None)
Bases:
RecordService Identifier
This is a reference to the service, using the following schema:
<type>:<subtype>/<domain>/<namespace>/<name>@<version>
Some fields might not be set; in this case they are not present or equal to None.
The service identifier is conceveid to avoid collisions as much as possible; services that are visible in two different scopes (e.g., Kubernetes pods and namespace should create the same identifier in different places (i.e., Kubernets and linux server.
Methods
Create a SId from a service type object
Create a SId from its string representation
Builds instance from dictionary
Converts to dictionary
Attributes
Domain of the service (e.g. OpenStack domain).
The internal name used by the ServiceType to identify the resource.
Tenant/namespace of the service
Subtype for the service.
Main type for this service.
Used to identify specific versions (this is mostly used for software
- __init__(sid: str = None, type: str = None, subtype: str = None, domain: str = None, namespace: str = None, name: str = None, version: str = None)
Initialize a Sid
The init function is specifically conceived to support the otupy serialization mechanism. Other helpers are provided to automatically instantiate the fields for a Sid.
- static create_from_service_type(service_type: object, domain=None, namespace=None)
Create a SId from a service type object
Create a SId by taking the type from the name used to register a ServiceType, and the subtype from a method that should be exposed by the object, if available. It uses the same name of the service_type and tries to get a version from it. domain and namespace are expected as input.
- @:param service_type: Any object that is registered as a ServiceType. We expect the class
itself to be provided, but we also manage a ServiceType.
@:param domain: Anything can be used to represent a domain internal to the scope. @:param namespace: Anyting that is used to separate names or resources within the domain. @:return: A SId object built in a standard way.
- static from_str(sid: str)
Create a SId from its string representation
@:param sid: A string following the SId format @:return: A SId class
- classmethod fromdict(dic, e)
Builds instance from dictionary
It is used during deserialization to create an otupy instance from the text message. It takes an
Encoderinstance that is used to recursively build instances of the inner objects (theEncoderprovides standard methods to create instances of base objects like strings, integers, boolean).- Parameters:
dic – The intermediary dictionary representation from which the object is built.
e – The
Encoderthat is being used.
- Returns:
An instance of this class initialized from the dictionary values.
- subtype: str = None
Subtype for the service. This typically derives from specific settings of the ServiceType.
- todict(e)
Converts to dictionary
It is used to convert this object to an intermediary representation during serialization. It takes an
Encoderargument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..- Parameters:
e – The
Encoderthat is being used.- Returns:
A dictionary compliants to the Language Specification’s serialization rules.