# Powerwise documentation ## Connect to DigitalOcean ### 1. Prerequisites While you can create, resize, and destroy clusters and node pools here in the control panel, all other administrative tasks require command-line tools from your local machine or a remote management server: #### kubectl, the official Kubernetes client. Use version 1.17.1 of kubectl to ensure you are within one minor version of your cluster's Kubernetes version. #### doctl, the official DigitalOcean command-line tool. Use the latest version. You can install these while your cluster is being provisioned. ### 2. Download the configuration file Download the configuration file To connect to your cluster from the command line, you need a configuration file on your administration machine that contains an authentication certificate and other connection information. #### Automated certificate management (Recommended) For automated certificate renewal and multiple-cluster management, use `doctl` to fetch your configuration files. How to Connect to Your Kubernetes Cluster provides detailed guidance. #### Quick connect with manual certificate management If you're just trying out Kubernetes with a single cluster, you can download the cluster configuration file to your `~/.kube` directory now. The authentication certificate is good for one week, after which you will need to re-download it. You can use the following command from within the .kube directory: `cd ~/.kube && kubectl --kubeconfig="k8s-1-14-1-do-4-fra1-1562139351785-kubeconfig.yaml" get nodes` ## Connect to Kubernetes Dashoard ### Getting Started **IMPORTANT**: Read the Access Control guide before performing any further steps. The default Dashboard deployment contains a minimal set of RBAC privileges needed to run. To deploy Dashboard, execute following command: ``` $ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml ``` To access Dashboard from your local workstation you must create a secure channel to your Kubernetes cluster. Run the following command: ``` $ kubectl proxy ``` Now access Dashboard at: ``` http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/. ``` ### 1. Creating sample user for kubernetes Dashboard In this guide, we will find out how to create a new user using Service Account mechanism of Kubernetes, grant this user admin permissions and login to Dashboard using bearer token tied to this user. **IMPORTANT**: Make sure that you know what you are doing before proceeding. Granting admin privileges to Dashboard's Service Account might be a security risk. Copy following snippets for `ServiceAccount` and `ClusterRoleBinding` to new manifest file like `dashboard-adminuser.yaml` and use `kubectl apply -f dashboard-adminuser.yaml` to create them. ### 2. Create Service Account We are creating Service Account with name `admin-user` in namespace `kubernetes-dashboard` first. ``` apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kubernetes-dashboard ``` ### 3. Create ClusterRoleBinding In most cases after provisioning our cluster using `kops` or `kubeadm` or any other popular tool, the `ClusterRole` `admin-Role` already exists in the cluster. We can use it and create only `ClusterRoleBinding` for our `ServiceAccount`. **NOTE**: `apiVersion` of `ClusterRoleBinding` resource may differ between Kubernetes versions. Prior to Kubernetes v1.8 the `apiVersion` was `rbac.authorization.k8s.io/v1beta1`. ``` apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: admin-user roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: admin-user namespace: kubernetes-dashboard ``` ### 4. Bearer Token Now we need to find token we can use to log in. Execute following command: ``` kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}') ``` It should print something like: ``` Name: admin-user-token-v57nw Namespace: kubernetes-dashboard Labels: <none> Annotations: kubernetes.io/service-account.name: admin-user kubernetes.io/service-account.uid: 0303243c-4040-4a58-8a47-849ee9ba79c1 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1066 bytes namespace: 20 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXY1N253Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIwMzAzMjQzYy00MDQwLTRhNTgtOGE0Ny04NDllZTliYTc5YzEiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.Z2JrQlitASVwWbc-s6deLRFVk5DWD3P_vjUFXsqVSY10pbjFLG4njoZwh8p3tLxnX_VBsr7_6bwxhWSYChp9hwxznemD5x5HLtjb16kI9Z7yFWLtohzkTwuFbqmQaMoget_nYcQBUC5fDmBHRfFvNKePh_vSSb2h_aYXa8GV5AcfPQpY7r461itme1EXHQJqv-SN-zUnguDguCTjD80pFZ_CmnSE1z9QdMHPB8hoB4V68gtswR1VLa6mSYdgPwCHauuOobojALSaMc3RH7MmFUumAgguhqAkX3Omqd3rJbYOMRuMjhANqd08piDC3aIabINX6gP5-Tuuw2svnV6NYQ ``` ![](https://i.imgur.com/kJHlBXS.png) Click `Sign in` button and that's it. You are now logged in as an admin. ![](https://i.imgur.com/ScC3YAU.png) ### Connect to a single service: If we have an open connection with Kubernethes #### get serviceslist `kubectl get pods` #### response all service list ``` NAME READY STATUS RESTARTS AGE adminmongo-deployment-ff97749b5-mp86h 1/1 Running 0 1d client-deployment-57d9dbdf9-tzws9 1/1 Running 0 2d mailer-deployment-7f49c9dff5-kp4rh 1/1 Running 0 2d mongo-deployment-854967bd64-g6rsp 1/1 Running 0 1d my-nginx-nginx-ingress-controller-5988884c58-vsv95 1/1 Running 0 1d my-nginx-nginx-ingress-default-backend-7f89d88bcd-67mpd 1/1 Running 0 1d powerwise-mq-rabbitmq-0 1/1 Running 0 1d server-deployment-55bb465c89-txmb2 1/1 Running 0 1d ``` #### To connect with single service: `kubectl port-forward PODNAME PORT:PORT` ##### local services ports ``` adminmongo - 8082 mongoDB - 27017 graphQL Api - 4000 reactJS - 3000 ``` # GraphQL Api doc PowerWise graphQl Api documentation #### Api endpoint: https://panel.powerwise.cloud/api/api ## GraphQL Authorization mutation request >login ( email: String! password: String! ): AuthPayload > request example: ``` login( email: "test@test.com" password: "password123" ){ token user{ _id } } ``` response example for Type: `AuthPayload` > type AuthPayload { token: String! user: User } > ``` { "data": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1ZDg5YmM2YzdjMTM5MDAwNmU0NmU5ZDciLCJpYXQiOjE1NzAxMDgzMDV9.v-fK3YwS9enBJFj4aKK_aCXia-wFEY-zGGVn3VCWixY" "login": { "user": { "_id": "5d89bc6c7c1390006e46e9d7" }, } } } ``` Add token `FROM RESPONSE` to header: ``` { "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1ZDg5YmM2YzdjMTM5MDAwNmU0NmU5ZDciLCJpYXQiOjE1NzAxMDgzMDV9.v-fK3YwS9enBJFj4aKK_aCXia-wFEY-zGGVn3VCWixY" } ``` ## GraphQL Queries ### Show all organization with groups and users query **Query request** >showMyOrg( _id: ID! ): Org! > **Organization TYPE** > type Org { _id: ID! orgName: String! admin: [User] users: [User] groups: [Group] maxLevels: Int! colorLayout: String levels: [OrgLevels] organizationTime: String TimeFormat: String } > **Request example:** ``` showMyOrg(_id: "ID1234567899876543321"){ _id orgName admin{ _id } users{ _id } groups{ groupName } maxLevels colorLayout levels } ``` Response example for Type: `Org` ``` { "data": { "showMyOrg": { "_id": "5d4b13a9abd0e000a9bf2cf1", "orgName": "ORG_NAME", "admin": [ { "_id": "5d7804c4af233d001a4d3dbe" }, { "_id": "5d81e5040d6ccf002671bf13" } ], "users": [ { "_id": "5d7b5c890e1784001afdeef9" } ], "groups": [ { "groupName": "ABC2", "role": { "_id": "5d792ea80e1784001afdeed7" } }, { "groupName": "ABC1", "role": { "_id": "5d7b5b2a0e1784001afdeee2" } }, ], "maxLevels": 2, "colorLayout": "blue", "levels": [ { "level": 1 }, { "level": 2 } ] } } } ``` ### Show all Users in organization with role permissions **Query request** > getOrgUsers( _id: ID! ): [User]! > **User Type** >type User { _id: ID! name: String email: String token: String lang: String roles: [Role] resetPasswordExpires: String organization: Org } > **Request example:** ``` query{ getOrgUsers(_id: "5d89bc7a7c1390006e46e9d8"){ _id name email } } ``` Response example for Type: User ``` { "data": { "getOrgUsers": [ { "_id": "5d89bc6c7c1390006e46e9d7", "name": "John Doe1", "email": "John.it@gmail.com" }, { "_id": "5d89c64f3c967f006a813bea", "name": "John Doe2", "email": "John2.it@gmail.com" } ] } } ``` ### Show all devices assigned to the organization **Query request** >allOrgThing ( orgID: String! ): [Thing!]! > **Thing type** >type Thing { _id: ID! orgID: String! deviceID: String! producent: String typ: String serial: String medium: String fw: String configuration: String modemTyp: String fwModem: String tarifGroup: String currentGear: String voltageTransmission: String multiplicand: String measurementType: String yearOfProduction: String legalizationPeriodYear: String legalizationPeriodMonth: String legalDate: String assemblyDate: String assemblyTime: String dismantlingDate: String dismantlingTime: String secureCount: String powerConnect: String contractedPower: String lastUpdateTime: String profile: [ProfileType] tags: [String] object: ObjectType } > **Request example:** ``` query{ allOrgThing(orgID: "5d89bc7a7c1390006e46e9d8"){ _id deviceID typ producent medium tags object { _id objectName } } } ``` response example for Type: `Thing` ``` { "data": { "allOrgThing": [ { "_id": "5d9593aabc25d2007c9909f8", "deviceID": "urn:lo:nsid:METCOM_MCS301:80003000", "typ": "LZQJ-XC", "producent": "EMH", "medium": "ELECTRICITY", "tags": [ "tag1", "tag2" ], "object": { "_id": "5d9594eabc25d2007c9909ff", "objectName": "Zone A" } } ] } } ``` ### Show all raports assigned to the organization **Query request** >allOrgRaports( orgID: String! ): [Raport!]! > **Raport Type** > type Raport { _id: ID! raportName: String author: User orgID: Org! mailTo: [User]! rangeMin: String! rangeMax: String! sendDay: String! status: String! type: String! things: [String]! } > **Request example:** ``` query{ allOrgRaports(orgID: "5d4b13a9abd0e000a9bf2cf1"){ raportName rangeMin rangeMax status mailTo{ email } author{ name email } things } } ``` Response example for Type: `Raport` ``` { "data": { "allOrgRaports": [ { "raportName": "test_lp_1", "rangeMin": "2019-09-07", "rangeMax": "2019-09-08", "status": "sent", "mailTo": [ { "email": "John.it@gmail.com" }, { "email": "John2.it@gmail.com" } ], "author": { "name": "John Doe", "email": "John.it@gmail.com" }, "things": [ "{ _id: 5d77c6e14a8efb001a536b20, deviceID: 'urn:lo:nsid:ELSTER1440_SIM:89072400' }" ] }] ``` ### Show all nested child group **Query request** >showMyGroup( _id: ID! ): [GroupNest]! > **Group Type** >type GroupNest { _id: ID groupName: String orgID: Org! users: [User] tags: [String] parent: Group parentID: String role: Role level: Int! child: [GroupNest] object: ObjectType } > **Request example:** ``` query{ showMyGroup(_id: "5d4b13a9abd0e000a9bf2cf1"){ _id groupName level things child{ _id groupName level things } } } ``` Response example for Type: `Group` ``` { "data": { "showMyGroup": [ { "_id": "5d9594eabc25d2007c9909ff", "groupName": "[GDN] Odział Główny", "level": 1, "things": [ "5d9593aabc25d2007c9909f8" ], "child": [ { "_id": "5d947cac1b242000acb50278", "groupName": "", "level": 2, "things": [ "5d91ff15f4ec73059ea92c2d" ] } ] } ] } } ``` ### Show all groups by level **Query request** >allGroupLevel( _id: ID! level: Int ): [Group]! > **Group Type** >type Group { _id: ID groupName: String orgID: Org! tags: [String] parent: Group parentID: String role: Role level: Int child: [Group] children: [Group] object: ObjectType } **Request example:** ``` query{ allGroupLevel( _id: "5d89bd16d9e8350086cfb845" level: 1 ){ _id groupName level object{ device{ deviceID } } } } ``` Response example for Type: `Group` ``` { "data": { "allGroupLevel": [ { "_id": "5d947ca31b242000acb50274", "groupName": "[WROC] Odział Główny", "level": 1, "object": [ "device" { "deviceID": "urn:lo:nsid:ELSTER1440_SIM:89072314" } ] }, { "_id": "5d947ca31b242000acb50274", "groupName": "[GDN] Odział Główny", "level": 1, "object": [ "device" { "deviceID": "urn:lo:nsid:ELSTER1440_SIM:89072314" } ] } ] } } ``` ### Show all data about selected things from LiveObject by model and date range **Query request** > getMultipleThings( streamId: [String]! model: String! dateMin: String dateMax: String ): [ThingInfo] > **ThingInfo Type** >type ThingInfo { model: String value: Data timestamp: String streamId: String } > **Request example:** ``` query{ getMultipleThings( streamId: ["urn:lo:nsid:ELSTER1440_SIM:89072314", "urn:lo:nsid:ELSTER1440_SIM:89072400"] model: "DAILY_PROFILE" dateMin: "2019-07-01" dateMax: "2019-09-01" ){ model streamId timestamp value{ data{ obis value } } } } ``` Response example for Type: `ThingInfo` ``` { "data": { "getMultipleThings": [ { "model": "DAILY_PROFILE", "streamId": "urn:lo:nsid:ELSTER1440_SIM:89072314", "timestamp": "2019-09-01T03:31:04Z", "value": { "data": [ { "obis": "1.8.0", "value": 16190.658 }, { "obis": "15.8.0", "value": 16190.658 }, { "obis": "3.8.0", "value": 69.445 }, { "obis": "4.8.0", "value": 991.89 } ] } }, { "model": "DAILY_PROFILE", "streamId": "urn:lo:nsid:ELSTER1440_SIM:89072400", "timestamp": "2019-09-01T01:39:01Z", "value": { "data": [ { "obis": "1.8.0", "value": 15890.432 }, { "obis": "15.8.0", "value": 15890.432 }, { "obis": "3.8.0", "value": 23.543 }, { "obis": "4.8.0", "value": 890.234 } ] } }, ] } } ``` ### Show all object in Organization **Query request** >getAllOrgObject( >orgID: "5d947ca31b242000acb50274" >): [ObjectType]! > **ObjectType Type** >type ObjectType { _id: ID objectName: String orgID: String! things: [ObjectThings] address: String ppe: String payName: String recipientName: String addresLocal: String yardage: String objectCode: String virtual: Boolean tags: [String] group: Group >} > ``` query { getAllOrgObject(orgID: "5d947ca31b242000acb50274"){ _id objectName ppe address tags things{ device { deviceID } } } } ``` ### Show all data about selected things from LiveObject for hours **Query request** >getFullHoursForMultipleThings( streamId: [String]! dateMin: String dateMax: String >): [ThingInfo] **ThingInfo Type** >type ThingInfo { model: String value: Data timestamp: String streamId: String } > ``` query { getFullHoursForMultipleThings( streamId: ["urn:lo:nsid:EMH_LZQJ-XC:8842089"] dateMin: "2019-02-07" dateMax: "2019-10-07" ){ timestamp streamId value{ data { obis value unit } } } } ``` Response example for Type: `ThingInfo` ``` { "data": { "getFullHoursForMultipleThings": [ { "timestamp": "2019-10-07T21:00:00Z", "streamId": "urn:lo:nsid:EMH_LZQJ-XC:8842089", "value": { "data": [ { "obis": "1.8.0", "value": 366.011, "unit": "kWh" }, { "obis": "1.5.0", "value": 0.084, "unit": "W" }, { "obis": "5.8.0", "value": 0.252, "unit": "kvarh" }, { "obis": "8.8.0", "value": 135.098, "unit": "kvarh" } ] } }, ... ``` ### Show all items assigned to your organization **Query request** >getOrgThingsFromLO( orgName: String! orgID: String! ): OrgThingsFromLo > **OrgThingsFromLo Type** >type OrgThingsFromLo { things: [Thing] data: [ThingLo] } > **Request example:** ``` query{ getOrgThingsFromLO( orgName: "/ORANGE" orgID: "5d89bc7a7c1390006e46e9d8" ){ things{ deviceID payerName recevierName } data{ key } } } ``` Response example for Type: `OrgThingsFromLo` ``` { "data": { "getOrgThingsFromLO": { "things": [ { "deviceID": "urn:lo:nsid:METCOM_MCS301:80003000", "payerName": "PySENSE Sp. z o.o.", "recevierName": "PySENSE Sp. z o.o." } ], "data": [ { "key": "urn:lo:nsid:METCOM_MCS301:80003000" }, { "key": "urn:lo:nsid:METCOM_MCS301:80002000" }, { "key": "urn:lo:nsid:APATOR_NORAX3:93526371" } ] } } } ``` ## GraphQL Mutations ### Create new organization **Mutation request** #### required - Super Admin User >createOrg( orgName: String! admin: UserInput! ): Org! > **Mutation example** ``` mutation{ createOrg( orgName: "FIVEDOTTWELVE" admin: "5d89bc6c7c1390006e46e9d7" ){ orgName } } ``` ### Update organization #### required - Super Admin User **Mutation request** > updateOrg( _id: ID! colorLayout: String! maxLevels: Int levels: [LevelsInput] organizationTime: String TimeFormat: TimeFormat ): Org! > **Mutation example** ``` mutation{ updateOrg( _id: "5d9afa0ee03bc3007ce4f22b" colorLayout: "red" maxLevels: 2 organizationTime: "Poland" TimeFormat: "12h" ){ orgName maxLevels colorLayout TimeFormat organizationTime } } ``` ### Add user to organization with permissions **Mutation request** #### required - Organization Admin User >addUserWithPermission( name: String! email: String! roleType: String! orgID: String! arrayOfRole: [String]! ): User > **Mutation example** ``` mutation{ addUserWithPermission( name: "John Doe" email: "john.doe1@gmail.com" roleType: "ADMIN_ORG" orgID: "5d9afa0ee03bc3007ce4f22b" arrayOfRole: [] ){ name email } } ``` ### Edit user organization with permissions **Mutation request** #### required - Organization Admin User > editUserPermission( changeUserId: ID! newEmail: String! newName: String! roleType: String! orgID: String! newArrayOfRole: [String]! ): User > **Mutation example** ``` mutation{ editUserPermission( orgID: "5d9afa0ee03bc3007ce4f22b" changeUserId: "5d89c64f3c967f006a813bea" newName: "John Doe" newEmail: "john.doe1@gmail.com" roleType: "USER" newArrayOfRole: ["5d9b07c4307fda00944ede74"] ){ name email } } ``` ### Remove user organization with permissions **Mutation request** #### required - Organization Admin User > removeUserWithPermission( removeUserId: ID! orgID: String! Email: String! ): User > **Mutation example** ``` mutation{ removeUserWithPermission( removeUserId: "5d89c64f3c967f006a813bea" orgID: "5d9afa0ee03bc3007ce4f22b" Email: "john.doe1@gmail.com" ){ name email } } ``` ### Add group to organization **Mutation request** #### required - Organization Admin User >createGroup( groupName: String! orgID: String! parent: String object: String ): Group! > **Mutation example** ``` mutation{ createGroup( groupName: "group name" orgID: "5d9afa0ee03bc3007ce4f22b" parent: "parentID" # if child group object: "5d9afa0ee03bc3007ce4f22b" # add object to group by id ){ groupName level } } ``` ### Update group **Mutation request** #### required - Organization Admin User >updateGroup( _id: String! groupName: String! parent: String object: String ): Group > **Mutation example** ``` mutation{ updateGroup( _id: "5d9afa0ee03bc3007ce4f22b" groupName: "group name" parent: "parentID" # if child group object: "5d9afa0ee03bc3007ce4f22b" # edit object to group by id ){ groupName level } } ``` ### Add object to organization **Mutation request** > createObject( objectName: String! orgID: String! ppe: String address: String tags: [String] things: [ThingsObjectInput] addresLocal: String payName: String recipientName: String objectCode: String yardage: String virtual: Boolean > ): ObjectType! **Mutation example** ``` mutation{ createObject( objectName: "object1" orgID: "hjg123hdjh13bdj2h3vd" ppe: "000000000000000001" address: "Gdańska 1" tags: ["tag1", "tag2"] things: [ { thingID: "0001" rangeMin: "2019-08-01" rangeMinTime: "15:40" rangeMax: "2026-08-01" rangeMaxTime: "16:00" device: "5e4c01f88da9c60026f01b3c" } ] recipientName: "FDT", addresLocal: "S2", recipientName: "FDT" objectCode: "001" yardage: "400m" virtual: false ){ objectName orgID ppe tags things{ device{ deviceID } } addresLocal } } ``` ### Update Object **Mutation request** >mutation{ updateObject( _id: ID! objectName: String ppe: String address: String tags: [String] things: [ThingsObjectInput] addresLocal: String payName: String recipientName: String objectCode: String yardage: String virtual: Boolean ): ObjectType! } **Mutation example** ``` mutation{ updateObject( _id: "hjg123hdjh13bdj2h3vd" objectName: "object1" ppe: "000000000000000001" address: "Gdańska 1" tags: ["tag1", "tag2"] things: [ { thingID: "0001" rangeMin: "2019-08-01" rangeMinTime: "15:40" rangeMax: "2026-08-01" rangeMaxTime: "16:00" device: "5e4c01f88da9c60026f01b3c" } ] recipientName: "FDT", addresLocal: "S2", recipientName: "FDT" objectCode: "001" yardage: "400m" virtual: false ){ objectName orgID ppe tags things{ device{ deviceID } } addresLocal } } ``` ### Create raport **Mutation request** >createRaport( data: { raportName: String! orgID: String mailTo: [UserMailInput]! rangeMin: String! rangeMax: String! type: String! sendDay: String! cyclic: String things: [ThingInputDevice]! } ): Raport! > **Mutation example** ``` mutation{ createRaport( data: { raportName: "PROFILE 15 Orange" type: "LOAD_PROFILE_15" orgID: "5d9afa0ee03bc3007ce4f22b" mailTo: {email: "mateusz.mitek95@gmail.com"} rangeMin: "2019-08-01" rangeMax: "2019-09-01" sendDay: "2019-09-10" things: [{deviceID: "deviceID"}] } ){ raportName type mailTo{ email } } } ``` ### Add thing to group ##### Data from StaticProfile is required to add a meter to the group **Mutation request** #### required - Organization Admin User >createThing( orgID: String! deviceID: String! tags: [String] data: ThingData! staticData: StaticData assemblyDate: String dismantlingDate: String ): Thing! > **Thing Type** > type Thing: { _id: ID! orgID: String! deviceID: String! producent: String typ: String serial: String medium: String fw: String configuration: String modemTyp: String fwModem: String tarifGroup: String currentGear: String voltageTransmission: String multiplicand: String measurementType: String yearOfProduction: String legalizationPeriodYear: String legalizationPeriodMonth: String legalDate: String assemblyDate: String assemblyTime: String dismantlingDate: String dismantlingTime: String secureCount: String powerConnect: String contractedPower: String lastUpdateTime: String profile: [ProfileType] tags: [String] object: ObjectType } > **StaticData Type** >type StaticData { producent: String typ: String serial: String medium: String dataModels: [ProfileValueInput] modemTyp: String fwModem: String streamId: String } > **Mutation example** ``` mutation{ createThing( orgID: "5d9afa0ee03bc3007ce4f22b" deviceID: "urn:lo:nsid:METCOM_MCS301:80003000" data: { tarifGroup: "C21" currentGear: "250/5" voltageTransmission: "none" multiplicand: "40" measurementType: "2" yearOfProduction: "2019" legalizationPeriodYear: "8" legalizationPeriodMonth: "12" legalDate: "2021" assemblyTime: "00:00" } staticData: { producent: "METCOM" typ: "RS485" serial: "80001000", model: "MCS301", protocol: "IEC", modemTyp: "PM-XE910-485", fw: "2.48", dataModels: [{ DP:["1.8.0","15.8.0","3.8.0","4.8.0"], LP15:["1.8.0","15.8.0","3.8.0","4.8.0"], MP:["1.8.0","15.8.0","3.8.0","4.8.0"] } ] } ){ tarifGroup currentGear multiplicand profile{ option values } } } ``` ### Edit thing **Mutation request** #### required - Organization Admin User >updateThing( _id: ID! data: ThingData! profiles: [ProfilesChange] tags: [String] assemblyDate: String dismantlingDate: String ): Thing! > **Mutation example** ``` mutation{ updateThing( _id: "5d9afa0ee03bc3007ce4f22b" data: { tarifGroup: "C21" currentGear: "250/5" voltageTransmission: "none" multiplicand: "40" measurementType: "2" yearOfProduction: "2019" legalizationPeriodYear: "8" legalizationPeriodMonth: "12" legalDate: "2021" assemblyTime: "00:00" } ){ tarifGroup currentGear multiplicand profile{ option values } } } ``` ### Create Obis **Mutation request** #### required - Super Admin User >createObis( dataMedium: String dataChannel: String measurmentValue: String measurmentMethod: String tarif: String medium: String obis: String obisLong: String descEng: String descPol: String calculated: Boolean hasAdditionalDate: Boolean ): Obis! > **Mutation example** ``` mutation { createObis( dataMedium: "1" dataChannel: "1" measurmentValue: "1" measurmentMethod: "6" tarif: "0" obis: "1.6.0" obisLong: "1-1:1.6.0" medium: "electricityObjects" descEng: "Maximum Demand Active Power+" descPol: "Całkowita Moc Maksymalna Pobrana (A+)" calculated: false hasAdditionalDate: true ){ dataMedium dataChannel measurmentValue measurmentMethod tarif obis obisLong medium descEng descPol calculated hasAdditionalDate } } ``` ### Update Obis **Mutation request** #### required - Super Admin User updateObis( dataMedium: String dataChannel: String measurmentValue: String measurmentMethod: String tarif: String medium: String obis: String obisLong: String descEng: String descPol: String calculated: Boolean hasAdditionalDate: Boolean ): Obis! **Mutation example** ``` mutation { updateObis( dataMedium: "1" dataChannel: "1" measurmentValue: "1" measurmentMethod: "6" tarif: "0" obis: "1.6.0" obisLong: "1-1:1.6.0" medium: "electricityObjects" descEng: "Maximum Demand Active Power+" descPol: "Całkowita Moc Maksymalna Pobrana (A+)" calculated: false hasAdditionalDate: true ){ dataMedium dataChannel measurmentValue measurmentMethod tarif obis obisLong medium descEng descPol calculated hasAdditionalDate } } ``` ### Delete Obis **Mutation request** #### required - Super Admin User deleteObis( _id: ID! ): Obis **Mutation example** ``` mutation { updateObis( _id: "5d9afa0ee03bc3007ce4f22b" ){ obis } } ``` # GraphQL Schema Types > type AuthPayload { token: String! user: User } >type Data { data: [Payload] } >input GetThings { thing: ThingInputDevice! dateMIN: String dateMAX: String type: String } >type Group { _id: ID groupName: String orgID: Org! users: [User] tags: [Tag] parent: Group role: Role level: Int! child: [Group] things: [Thing] } > >input GroupInput { _id: ID! } > >type GroupNest { _id: ID groupName: String orgID: Org! users: [User] tags: [Tag] parent: Group role: Role level: Int! child: [GroupNest] things: [String] } > >input LevelsInput { name: String! level: Int } > >type Meter { protocol: String serial: String producer: String model: String medium: String interface: String } >type Modem { fw: String ipv4: String port: String imei: String producer: String model: String } >type Org { _id: ID! orgName: String! admin: [User] users: [User] groups: [Group] maxLevels: Int! colorLayout: String levels: [OrgLevels] } >input OrgInput { _id: ID! } > >type OrgLevels { _id: ID! level: Int! name: String } > type OrgThingsFromLo { things: [Thing] data: [ThingLo] } > >type Payload { obis: String! value: Float! unit: String! } > >type ProfileType { option: String values: [String] } > >input ProfileValueInput { DP: [String] LP15: [String] LP10: [String] MP: [String] } > >type ProfileValues { DP: [String] LP15: [String] LP10: [String] MP: [String] } > >type Raport { _id: ID! raportName: String author: User orgID: Org! mailTo: [User]! rangeMin: String! rangeMax: String! sendDay: String! status: String! type: String! things: [String]! } > >input RaportInput { raportName: String! orgID: String mailTo: [UserMailInput]! rangeMin: String! rangeMax: String! type: String! sendDay: String! cyclic: String things: [ThingInputDevice]! } > >type Role { _id: ID! userReadWrite: [User] userRead: [User] group: Group orgID: Org } > >input StaticData { producent: String typ: String serial: String model: String protocol: String modemTyp: String fw: String dataModels: [ProfileValueInput] } > >type StaticProfile { model: String value: StaticValues timestamp: String streamId: String } > >type StaticValues { meter: Meter profiles: [ProfileValues] modem: Modem device: String } > >type Tag { _id: ID! tagName: String! } > >input TagInput { tagName: String! } > >type Thing { _id: ID! orgID: String group: Group deviceID: String tags: [Tag] type: String! payerName: String recevierName: String code: String objectName: String address: String localNr: String space: String ppe: String tarif: String caseOpt: String measurementType: String productionDate: String legalDate: String legalRange: String installDate: String uninstallDate: String secureCount: String powerConnect: String contractedPower: String status: String lastUpdateTime: String profile: [ProfileType] } > >input ThingData { payerName: String recevierName: String code: String objectName: String address: String localNr: String space: String ppe: String tarif: String caseOpt: String measurementType: String productionDate: String legalDate: String legalRange: String secureCount: String powerConnect: String contractedPower: String status: String } > >type ThingInfo { model: String value: Data timestamp: String streamId: String } > >input ThingInput { _id: ID! } > >input ThingInputDevice { deviceID: String! } > >type ThingLo { key: String doc_count: String } > >input UpdateGroupInput { _id: ID! groupName: String! tags: [TagInput] users: [UserInput] } > >type User { _id: ID! name: String email: String token: String lang: String roles: [Role] resetPasswordExpires: String organization: Org } > >input UserInput { _id: ID! } > >input UserMailInput { email: String! } >