otupy.profiles.xbom.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: Record

Service 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_from_service_type

Create a SId from a service type object

from_str

Create a SId from its string representation

fromdict

Builds instance from dictionary

todict

Converts to dictionary

Attributes

domain

Domain of the service (e.g. OpenStack domain).

name

The internal name used by the ServiceType to identify the resource.

namespace

Tenant/namespace of the service

subtype

Subtype for the service.

type

Main type for this service.

version

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.

domain: str = None

Domain of the service (e.g. OpenStack domain)

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 Encoder instance that is used to recursively build instances of the inner objects (the Encoder provides 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 Encoder that is being used.

Returns:

An instance of this class initialized from the dictionary values.

name: str = None

The internal name used by the ServiceType to identify the resource.

namespace: str = None

Tenant/namespace of the service

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 Encoder argument that is used to recursively serialize inner data and structures (the Encoder provides standard methods for converting base types to dictionaries)..

Parameters:

e – The Encoder that is being used.

Returns:

A dictionary compliants to the Language Specification’s serialization rules.

type: str = None

Main type for this service. This is set according to ServiceType.

version: str = None

Used to identify specific versions (this is mostly used for software