Forum Discussion

rduram's avatar
rduram
Icon for Contributor rankContributor
2 months ago
Solved

Provisioning a Virtual Device in SL1 API

We are building an app that will have a component to build a virtual device, align a dynamic app and a credential to it using the SL1 API.  Looking for some guidance on how to do this as we have never done anything with device creation through the API, only /alerts creation.

  • Hello Rob,

    You can POST to /api/device, only filling out the specific fields and using a device class for virtual devices. An example payload is:

    {
      "name": "Example Virtual Device",
      "class_type": "/api/device_class/<virtual device class ID>",
      "collector_group": "/api/collector_group/1",
      "organization": "/api/organization/0"

    Replacing <virtual device class ID> with the ID of the virtual device class you want.

    Antonio Andres

    Senior Technical Support Engineer | ScienceLogic

  • Creating a virtual device can be don pretty easily:

    mutation { 
        createVirtualDevice (
          name: "test_1"
          organization: 35
          collectorGroup: 1
          deviceClass: "E4DC4FF34FEF1144051B1F2B103970F7"
        ) {
          id
        } 
      }

    Though you have first to find the organization ID and deviceClass GUID

    Quite similarly you can create credentials also with GQL there are mutations for that, for example createSoapCredential, createSshCredential etc

    Then just align the DA with updateDeviceAlignedDynamicApplication mutation request

    • rduram's avatar
      rduram
      Icon for Contributor rankContributor

      Thanks Teppo - we have not started working with GQL yet.  Is there a comparable way to do this in the REST API?  Also, since aligning the dynamic app requires a credential, how would you create a credential and include it with the DA alignment?

      • TonyAndres's avatar
        TonyAndres
        Icon for Moderator rankModerator

        Hello Rob,

        You can POST to /api/device, only filling out the specific fields and using a device class for virtual devices. An example payload is:

        {
          "name": "Example Virtual Device",
          "class_type": "/api/device_class/<virtual device class ID>",
          "collector_group": "/api/collector_group/1",
          "organization": "/api/organization/0"

        Replacing <virtual device class ID> with the ID of the virtual device class you want.

        Antonio Andres

        Senior Technical Support Engineer | ScienceLogic