예제 #1
0
    def __init__(self,
                 host,
                 port=None,
                 username=None,
                 password=None,
                 vertical="onesaitplatform"):
        """
        Class AuthClient to login and refresh token of OnesaitPlatform

        @param host               Onesaitplatform host
        @param port               Onesaitplatform port
        @param username           Onesaitplatform username
        @param password           Onesaitplatform password
        @param vertical           Onesaitplatform vertical (default=''onesaitplatform')
        """
        Client.__init__(self, host, port=port)
        self.username = username
        self.password = password
        self.vertical = vertical
        self.token = None

        log.info("Created client with controlpanel-auth \
                 host:{}, path:{}, username:{}, vertical:{}".format(
            host, self.__control_panel_path, username, vertical))
        self.add_to_debug_trace("Created client with controlpanel-auth \
                 host:{}, path:{}, username:{}, vertical:{}".format(
            host, self.__control_panel_path, username, vertical))
    def __init__(self,
                 host,
                 port=None,
                 iot_client=config.IOT_CLIENT,
                 iot_client_token=config.IOT_CLIENT_TOKEN):
        """
        Class IotBrokerClient to connect with Iot-Broker of OnesaitPlatform

        @param host               Onesaitplatform host
        @param iot_client         Onesaitplatform Iot-Client
        @param iot_client_token   Onesaitplatform iot-Client-Token
        """
        #super().__init__(host, port=port) # only python > 3
        Client.__init__(self, host, port=port)  # python > 2.7 & <= 3.7.1
        self.iot_client = iot_client
        self.iot_clientId = iot_client + ":PythonClient"
        self.iot_client_token = iot_client_token
        self.session_key = None

        log.info("Created client with iot-broker \
                 host:{}, path:{}, client:{}, token:{}".format(
            host, self.__iot_broker_path, iot_client, iot_client_token))
        self.add_to_debug_trace("Created client with \
                                iot-broker host:{}, path:{}, \
                                client:{}, token:{}".format(
            host, self.__iot_broker_path, iot_client, iot_client_token))
예제 #3
0
 def __init__(self,
              host,
              model_endpoint,
              model_version,
              token=None,
              port=None):  #, protocol="http", avoid_ssl_certificate=False):
     Client.__init__(self, host, port=port)  # python > 2.7 & <= 3.7.1
     self.__model_endpoint = self.__parse_input_model_endpoint(
         model_endpoint)
     self.__model_version = self.__parse_input_model_version(model_version)
     self.token = token
예제 #4
0
    def __init__(self, host, port=None):
        """
        Class ApiManagerClient to connect with Api-Manager and APIs of OnesaitPlatform

        @param host               Onesaitplatform host
        """
        #super().__init__(host, port=port) # only python > 3
        Client.__init__(self, host, port=port) # python > 2.7 & <= 3.7.1
        self.token = None
        log.info("Connection Params: "  + self.host + "/(" + self.api_manager_path + " - " + self.api_caller_path + ")")
        self.add_to_debug_trace("Connection Params: "  + self.host + "/(" + self.api_manager_path + " - " + self.api_caller_path + ")")
예제 #5
0
    def from_json(json_object):
        """
        Creates a object from json-dict/ json-string

        @param json_object    json.dict/ json-string

        @return client        client object
        """
        client = None
        try:
            if type(json_object) == str:
                json_object = json.loads(json_object)

            json_object_keys = list(json_object.keys())

            client = Client(host=json_object['host'])
            if "port" in json_object_keys:
                client.port = json_object['port']
            if "protocol" in json_object_keys:
                client.protocol = json_object['protocol']
            if "is_connected" in json_object_keys:
                client.is_connected = json_object['is_connected']
            if "proxies" in json_object_keys:
                client.proxies = json_object['proxies']
            if "timeout" in json_object_keys:
                client.timeout = json_object['timeout']
            if "avoid_ssl_certificate" in json_object_keys:
                client.avoid_ssl_certificate = json_object[
                    'avoid_ssl_certificate']
            if "raise_exceptions" in json_object_keys:
                client.raise_exceptions = json_object['raise_exceptions']
            if "model_endpoint" in json_object_keys:
                client.model_endpoint = json_object['model_endpoint']
            if "model_version" in json_object_keys:
                client.model_version = json_object['model_version']
            if "token" in json_object_keys:
                client.token = json_object['token']

            log.info("Imported json {}".format(json_object))
            client.add_to_debug_trace("Imported json {}".format(json_object))

        except Exception as e:
            log.error("Not possible to import object from json: {}".format(e))

        return client