Skip to content

Commit f0f668d

Browse files
committed
Add device/list-devices snippets
1 parent 32cd5dc commit f0f668d

8 files changed

+117
-15
lines changed

deployed-devices/rest/devices/list-devices/list-device.3.x.js

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Get the Node helper library from https://twilio.com/docs/libraries/node
2+
const fs = require('fs');
3+
const Twilio = require('twilio').Twilio;
4+
5+
// Get your Account SID and Auth Token from https://twilio.com/console
6+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
7+
const authToken = 'your_auth_token';
8+
const client = new Twilio(accountSid, authToken);
9+
10+
const fleetSid = 'FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
11+
const fleetService = client.preview.deployed_devices.fleets(fleetSid);
12+
13+
fleetService.devices
14+
.list()
15+
.then(response => {
16+
console.log(response);
17+
})
18+
.catch(error => {
19+
console.log(error);
20+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get the Node helper library from https://twilio.com/docs/libraries/csharp
2+
using System;
3+
using System.Collections.Generic;
4+
using Twilio;
5+
using Twilio.Rest.Preview.DeployedDevices.Fleet
6+
7+
public class Example
8+
{
9+
public static void Main(string[] args)
10+
{
11+
// Get your Account SID and Auth Token from https://twilio.com/console
12+
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
13+
const string authToken = "your_auth_token";
14+
TwilioClient.Init(accountSid, authToken);
15+
16+
var device = DeviceResource.Create(
17+
pathFleetSid: "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
18+
friendlyName: "My Device #1"
19+
);
20+
21+
Console.WriteLine(device.Sid);
22+
}
23+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
// Get the Node helper library from https://twilio.com/docs/libraries/php
3+
require_once '/path/to/vendor/autoload.php'; // Loads the library
4+
5+
use Twilio\Rest\Client;
6+
7+
// Get your Account SID and Auth Token from https://twilio.com/console
8+
$accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
9+
$authToken = 'your_auth_token';
10+
$client = new Client($sid, $token);
11+
12+
$fleetSid = 'FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
13+
$fleetService = $client->preview->deployedDevices->fleets($fleetSid);
14+
15+
$devices = $fleetService->devices->list();
16+
17+
foreach ($devices as $device) {
18+
echo $device->sid;
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Get the Node helper library from https://twilio.com/docs/libraries/ruby
2+
require 'twilio-ruby'
3+
4+
# Get your Account SID and Auth Token from https://twilio.com/console
5+
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
6+
auth_token = 'your_auth_token'
7+
client = Twilio::REST::Client.new(account_sid, auth_token)
8+
9+
fleet_sid = 'FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
10+
fleet_service = client.preview.deployed_devices.fleets(fleet_sid)
11+
12+
devices = fleet_service.devices.list()
13+
14+
puts devices
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Get the Node helper library from https://twilio.com/docs/libraries/python
2+
from pathlib import Path
3+
from Twilio.rest import Client
4+
5+
# Get your Account SID and Auth Token from https://twilio.com/console
6+
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
7+
auth_token = 'your_auth_token'
8+
client = Client(account_sid, auth_token)
9+
10+
fleet_sid = 'FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
11+
fleet_service = client.preview.deployed_devices.fleets(fleet_sid)
12+
13+
devices = fleet_service.devices.list()
14+
15+
for device in devices:
16+
print(device.sid)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Get the Node helper library from https://twilio.com/docs/libraries/java
2+
import com.twilio.Twilio;
3+
import com.twilio.base.ResourceSet;
4+
import com.twilio.rest.preview.deployedDevices.fleet;
5+
import java.io.IOException;
6+
import java.nio.file.Files;
7+
import java.nio.file.Paths;
8+
9+
public class Example {
10+
// Get your Account SID and Auth Token from https://twilio.com/console
11+
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
12+
public static final String AUTH_TOKEN = "your_auth_token";
13+
14+
public static void main(String[] args) {
15+
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
16+
17+
String fleetSid = "FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
18+
19+
ResourceSet<Device> devices = new DeviceReader(fleetSid).read();
20+
21+
for (Device device: devices) {
22+
System.out.println(device.getSid());
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)