...
Code Block |
---|
import os from clearblade.cloud import iot_v1 def delete_gateway(): project_id = 'YOUR_PROJECT_ID' cloud_region = 'us-central1' registry_id = 'your-registry-id' gateway_id = 'your-gateway-id' print("Delete gateway") client = iot_v1.DeviceManagerClient() device_path = client.device_path(project_id, cloud_region, registry_id, gateway_id) request = iot_v1.DeleteDeviceRequest(name=device_path) return client.delete_device(request=request) os.environ["CLEARBLADE_CONFIGURATION"] = "/path/to/your-credentials.json" delete_gateway() |
Go
Code Block |
---|
// deleteDevice deletes a device from a registry.
func deleteDevice(w io.Writer, projectID string, region string, registryID string, deviceID string) (*iot.Empty, error) {
ctx := context.Background()
service, err := iot.NewService(ctx)
if err != nil {
return nil, err
}
path := fmt.Sprintf("projects/%s/locations/%s/registries/%s/devices/%s", projectID, region, registryID, deviceID)
response, err := service.Projects.Locations.Registries.Devices.Delete(path).Do()
if err != nil {
return nil, err
}
fmt.Fprintf(w, "Deleted device: %s\n", deviceID)
return response, nil
} |