1) Request for Authentication URL

    Description: User request for third party authentication details to hub.

    Direction: Application ----> soulHub

    Request Topic: NameSpaceId + "/INSTALLER/" + modelNumber + "/" + SERIAL + "/HUB_REQ"
                 e.g. "TEST_123/INSTALLER/GENfvb5fdgfgfg4/ClouzerSoulTest-51/HUB_REQ"

    Request Object:

                {
                    "type": "get_auth_details",
                    "data": {
                        "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6IklPU0NvY29hTVFUVDE0NDgifQ.b8tGxJy8WOvQBZrrjYEz8zNXmvBFBtJXB9SfQEJbVHQ",
                        "clientId": "IOSCocoaMQTT1448",
                        "requestId":"sync#sync#4xX5m7PanLLVla5LAAKWashwini.tote@clouzer.com#1658818116171r163r272",
                        "userId": "ashwini.tote@bgfhiaajiafbiicfb.cloudsbuilder.clouzer.com",
                        "dataArray": [
                            [],
                            []
                        ],
                        "queryData": {
                            "KEY_VAL":"cloudsmaintenance.clouzer.com#PRJ_HUB_1650615290768_17#DEVICE_DRIVERS_SECTION#TSK_INST_DRV_1658485538822_38",
                            "INTERFACE_ID": "ID1658485544383561334421297"
                        },
                        "CallerInfo": {
                            "source": [],
                            "caller": "soulHubAction",
                            "portalAction": true,
                            "tsEntry": 1658818056939
                        }
                    }
                }

2) checking soulPy process

    Description: Hub checks python process is running or not.

    Direction: SoulHub ----> ProcessMonitor

    process: "soulPy"

    Request Topic: "process/status/get"

    Response Topic: "process/status/get_res"

3) hub request to db for interfaces

    Description: hub needs to fetch the interfaces therefore hub request to database.

    Direction: SoulHub ----> soulPy

    Request Topic: "soulDb/fetch"

    Request Object:
            {
            "data":
                {"entity_type":"interfaces",
                    "and":{
                        "eq":{
                            "KEY_VAL":"cloudsmaintenance.clouzer.com#PRJ_HUB_1650615290768_17#DEVICE_DRIVERS_SECTION#TSK_INST_DRV_1658485538822_38"
                            }
                        }
                },
                "communicationId":"1658818056243getCredentials218",
                "CallerInfo":
                    {
                        "source":[],
                        "caller":"soulHubAction",
                        "portalAction":true,
                        "tsEntry":1658818056239
                    }
                }

    Direction: soulPy ----> soulHub

    Response Topic: "soulDb/Response"

    Response Object:

            {
                "data":
                    [
                        {
                            "INTERFACE_ID": "ID1658485544383561334421297", 
                            "LKEY_VAL": "ID1658485544383561334421297",
                            "KEY_VAL":"cloudsmaintenance.clouzer.com#PRJ_HUB_1650615290768_17#DEVICE_DRIVERS_SECTION#TSK_INST_DRV_1658485538822_38",
                            "ACTIVE_STATUS": 1, 
                            "CML_TYPE": -1, 
                            "CML_SUB_TYPE": -1, 
                            "CML_MODE": -1, 
                            "CML_TITLE": "tuya clouds", 
                            "CML_VERSION": "0.0.11", 
                            "TYPE_OF_AUTH": 3, 
                            "MODE_OF_AUTH": 2, 
                            "URL_PROVIDER": "www.tuya.com", 
                            "IS_TESTING": 1, 
                            "DRIVER_NAME": "driver-1640851091928_745", 
                            "CML_MANUFACTURER": "tuya", 
                            "entity_type": "interfaces", 
                            "CML_MANUFACTURER_ID": "tuya.clouzer.com#PRJ_ORG_WKS_1614069325662_3960"
                        }
                    ], 
                "type": "dbFetch", 
                "communicationId": "1658818056243getCredentials218", 
                "CallerInfo": 
                    {
                        "portalAction": true, 
                        "caller": "soulHubAction", 
                        "source": ["soulHub", "soulPy"]
                    }
            }

4) hub request to dapi for authentication

    Description: after fetching interfaces from db hub checks the authentication details.

    Direction: SoulHub ----> Dapi

    Driver: "Tuya"

    Request Topic: interfaceId + "/getAuthDetails" e.g. = (ID1658485544383561334421297/getAuthDetails)

    Request Object:

            {
                "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6IklPU0NvY29hTVFUVDE0NDgifQ.b8tGxJy8WOvQBZrrjYEz8zNXmvBFBtJXB9SfQEJbVHQ",
                "clientId":"IOSCocoaMQTT1448",
                "requestId":"/sync#/sync#4xX5m7PanLLVla5LAAKWashwini.tote@clouzer.com#1658818115472r11r223",
                "userId":"ashwini.tote@bgfhiaajiafbiicfb.cloudsbuilder.clouzer.com",
                "dataArray":[[],[]],
                "queryData":
                        {
                        "KEY_VAL":"cloudsmaintenance.clouzer.com#PRJ_HUB_1650615290768_17#DEVICE_DRIVERS_SECTION#TSK_INST_DRV_1658485538822_38",
                        "INTERFACE_ID":"ID1658485544383561334421297"
                        },
                "CallerInfo":
                    {
                        "source":["soulHub"],
                        "caller":"soulHubAction",
                        "portalAction":true,
                        "tsEntry":1658818056239},
                        "communicationId":"1658818056243getAuthDetails4"
                    }

    Direction: DAPI ----> soulHub

    Response Topic: "third_party_url"

    Response Object:

            {
                "data":
                    {
                        "ACTIVE_STATUS":1,
                        "STATE":"ClouzerSoulTest-51",
                        "AUTH_LOCATION":"https://openapi.tuyaus.com/login/open/tuya/login/v1/index.html?redirect_uri=https://test.clouzer.com/ApiTuyaAuth&client_id=pn3x8ttd4xsc5nuafscd&state=ClouzerSoulTest-51"},
                        "communicationId":"1658819251784getAuthDetails227"
                    }

5) hub sends rersponse to the App

    Description: Hub sends back the response after fetching authentication details from the dapi drivers

    Direction: SoulHub ----> App

    Response Topic: hubActionResponse/Installer

    Response Object:

            {
                "type":"get_auth_details_hub",
                "dataArray":
                    [
                        {
                            "ACTIVE_STATUS":1,
                            "STATE":"ClouzerSoulTest-51",
                            "AUTH_LOCATION":"https://openapi.tuyaus.com/login/open/tuya/login/v1/index.html?redirect_uri=https://test.clouzer.com/ApiTuyaAuth&client_id=pn3x8ttd4xsc5nuafscd&state=ClouzerSoulTest-51"
                        }
                    ],
                "requestId":"/sync#/sync#4xX5m7PanLLVla5LAAKWashwini.tote@clouzer.com#1658819311025r127r262",
                "CallerInfo":
                    {
                        "source":[],
                        "caller":"soulHubAction"
                    },
                "userId":"ashwini.tote@bgfhiaajiafbiicfb.cloudsbuilder.clouzer.com",
                "clientId":"IOSCocoaMQTT1448"
            }

6) Sequence Diagram

test