Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
if (bBindUnBindDevice)
{
    logger.LogInformation("Get configuration of a device");

    // While running this sample, it is assumed that, device with name
    // "Sample-New-Device" exists and Gateway with name "TestGateway" exists
    // "Sample-New-Registry" is the registry name

    // Sample - Bind Device
    var result = await mClient.BindDeviceToGateway(4, "projects/developmentenv/locations/us-central1/registries/Sample-New-Registry", "TestGateway", "Sample-New-Device");
    if (!result)
    {
        logger.LogError("Failed To Bind Device");
    }
    else
    {
        // Actual test - UnBind Device
        result = await mClient.UnBindDeviceFromGateway(4, "projects/developmentenv/locations/us-central1/registries/Sample-New-Registry", "TestGateway", "Sample-New-Device");
        if (!result)
            logger.LogError("Failed to unbind a device");
        else
            logger.LogInformation("Successfully bind device");

    }
}

...

Code Block
{
    logger.LogInformation("Obtain list of devices for a particular registry and gateway");

    // While running this sample, it is assumed that, gateway with name
    // "associated-gateway" exists

    GatewayListOptionsModel gatewayListOptions = new GatewayListOptionsModel()
    {
        AssociationsGatewayId = "associated-gateway",
    };
    var result = await mClient.GetDevicesList(4, "projects/developmentenv/locations/us-central1/registries/Sample-New-Registry", gatewayListOptions);
    if (!result.Item1)
        logger.LogError("Failed to get list of devices");
    else
    {
        logger.LogInformation("Succeeded in getting the list of Devices");

        // Use the list
    }
}

...