Commit ee1873b0 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

clean up the documentation

parent 8d17061e
""" This module implements a factory for managing and creating digital twins."""
""" This module implements a factory for managing and creating Digital Twins according to Forest Modeling Language 4.0."""
from ml.app_logger import APP_LOGGER
from ml.tools import remove_namespace
......@@ -150,7 +150,7 @@
from ml.fml40.features.functionalities.transports_logs import TransportsLogs
# TODO: Get rid of this global variable
# TODO: automatically get all classes in modul
# TODO: automatically get all classes in module
DT_FACTORY = {}
import sys, inspect
......@@ -212,12 +212,12 @@ def build(thing, attributes):
:param thing: ml40 thing instance
:type thing: object
:param attributes: attributes in ml40 thing json
:param attributes: attributes in ml40 thing JSON
:type attributes: dict
"""
if not isinstance(attributes, dict):
APP_LOGGER.critical("Attributes is no valid json")
APP_LOGGER.critical("Attributes is no valid JSON")
return
roles = attributes.get("roles", [])
for role in roles:
......@@ -307,9 +307,9 @@ def create_thing(model, grant_type="password",
secret="", username=None, password=None,
is_broker_rest=False, is_broker=False, is_repo=False):
"""
Creates and launches a ml40 thing with the connection to S³I
Creates and launches a thing which connects to the S3I
:param model: JSON of a ml40::thing model
:param model: edge-device or S³I Repository specified JSON entry
:type model: dict
:param grant_type: grant type of OAuth2.0, which can be password or client_credentials
:type grant_type: str
......
"""This module implements the Feature class according to the forest
modeling language 4.0."""
"""This module implements the Feature class according to the Forest
Modeling Language 4.0."""
import sys
import os
......@@ -44,6 +44,7 @@ def class_name(self, value):
"""Sets __class_name to value.
:param value: New class name
:type value: str
"""
# !!! What about the namespace?
......@@ -67,6 +68,7 @@ def name(self, value):
"""Sets __name to value.
:param value: New name
:type value: str
"""
......@@ -74,7 +76,7 @@ def name(self, value):
@property
def identifier(self):
"""Returns the object's indentifier.
"""Returns the feature's local identifier.
:returns: Identifier
:rtype: str
......@@ -89,6 +91,7 @@ def identifier(self, value):
to __identifier.
:param value: Proposal of the identifier
:type value: str
"""
self.__identifier = ID(value).identifier
......@@ -116,7 +119,7 @@ def subFeatures(self, value):
self.__subFeatures = value
def to_json(self):
"""Returns a json representation of this feature. Note that this
"""Returns a JSON representation of this feature. Note that this
function works recursively.
:returns: Json representation
......
"""This modules provides the ID class which can be used to build s3i
"""This modules provides the ID class which can be used to build S3I
specific identifiers."""
import uuid
......
"""This module implements the role class."""
"""This module implements the role class according to Forest Modeling Language 4.0."""
import sys
from abc import ABC
......@@ -27,10 +27,10 @@ def __init__(self, name="", identifier=""):
@property
def class_name(self):
"""Sets __class_name to value.
:param value: New class name
"""Adds the prefix ml40:: to the class name and returns it.
:returns: class name of the object
:rtype: str
"""
return self.__class_name
......@@ -57,7 +57,7 @@ def name(self, value):
@property
def identifier(self):
"""Returns the object's identifier.
"""Returns the role's local identifier.
:returns: Identifier
:rtype: str
......@@ -77,6 +77,9 @@ def identifier(self, value):
self.__identifier = ID(value).identifier
def to_json(self):
"""Returns a JSON representation of this role.
"""
self.__json_out = {
"class": self.__class_name,
"identifier": self.__identifier,
......
......@@ -30,7 +30,7 @@ class BaseVariable:
class Thing:
"""The thing class represents a customizable runtime environment for
operating digital twins complying the forest modeling language (fml40)."""
operating Digital Twins complying the Forest Modeling Language (fml40)."""
def __init__(
self,
......@@ -43,6 +43,26 @@ def __init__(
username=None,
password=None,
):
"""
Constructor
:param model: edge-device or S³I Repository specified JSON entry, like config file for Digital Twins
:type model: dict
:param client_secret: OAuth 2.0 specified client secret, generated in the S³I IdentityProvider
:type client_secret: str
:param grant_type: OAuth 2.0 specified grant type to issue a JWT. Here the grant type can be password or client_credentials
:type grant_type: str
:param is_broker: whether broker interface is enabled in the ml40::thing instance
:type is_broker: bool
:param is_broker_rest: Whether the connection with the S³I Broker is established via HTTP REST
:type is_broker_rest: bool
:param is_repo: Whether the thing uses the S³I Repository to launch its Digital Twin in the cloud
:type is_repo: bool
:param username: OAuth 2.0 specified username, registered in the S³I IdentityProvider. If the grant_type is set as password, the username is required
:type username: str
:param password: OAuth 2.0 specified password, registered in the S³I IdentityProvider. If the grant_type is set as password, the password is required
"""
self.__model = model
self.__thing_id = model.get("thingId", "")
......@@ -85,7 +105,7 @@ def __init__(
@property
def model(self):
"""Returns the specification from which this thing has been constructed from.
"""Returns the specification JSON from which this thing has been constructed from.
:returns: Representation of a ml40 compliant thing.
:rtype: dict
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment