1

What I want to achieve is to have a global fragment with a custom data. This data-fragment must be accessible any time from a central source and it can be different between tenants. This data will be required for all devices

I have two ideas

The tenant: What is the best way to save custom data into the tenant fragment? I have tried using the below request but with not luck.

PUT /tenant/tenants/tenant1 HTTP/1.1
Host: tenant1.enterpise.com
Content-Type: application/json
Accept: application/json
Authorization: Basic 

{
 "customFragment:{
  "forms":[
     {
      "type": ....,
      "inputa" : ...
     },
     .....
   ],
   "products":[
     {
      "name": ....,
      "stock" : ...
     }
   ],
   .....
  }
}

What can I do?

Using a managementObject with the custom data fragment.

May I use a management object into the database in order to achieve this? Will I be charge if this management object has not the isDevice property?

Thanks in advance!

Jorge
  • 238
  • 1
  • 10

1 Answers1

2

Both approaches are valid here

Storing it inside the tenant object

Your request is (almost) correct but this request cannot be executed with a user of tenant1. A tenant can not update its own tenant object. You need to execute this request from the parent tenant (either the management tenant or if it is subtenant of another tenant you can also do it from there). Now for the almost part: For tenants you cannot directly create arbitrary fragments. You need to put your custom data into a fragment called "customProperties". What you put inside that fragment is then again up to you.

{
   "customProperties" : {
        "test": "test",
        "abc": {
            "test": 1
        }
   }
}

For accessing this data you can use the API /tenant/currentTenant. This API is always available for every authenticated user regardless of access rights. It will return the tenant information (including the customProperties). This API is also read only, it is like the /user/currentUser API.

Storing inside a managedObject

In the inventory API you can add a fragment "c8y_Global" to an object. This will make this managedObject available for every user regardless of access rights (you still need valid credentials to the tenant of course.

{
   "c8y_Global": {},
   "myConfig": {
        ...
   }
}

Regarding the charging better check directly with your platform provider but usually only devices are part of the charging and this would not be considered a device. Dashboards are btw also just such kind of managedObjects with this c8y_Global flag.

TyrManuZ
  • 2,039
  • 1
  • 14
  • 23