Last active
September 8, 2016 01:56
-
-
Save steveperkins/f3e775ce6fead2e5a00657a4002ec217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build an authenticated client object | |
// This pattern repeats from https://www.linkedin.com/pulse/sending-sms-from-java-aws-sns-steve-perkins | |
AWSIot iotClient = AWSIotClientBuilder | |
.standard() | |
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(CLIENT_TOKEN, CLIENT_SECRET))) | |
.withRegion(Regions.US_WEST_2) | |
.build(); | |
// Send the ListThingsRequest to AWS IoT synchronously | |
ListThingsResult result = iotClient.listThings(new ListThingsRequest()); | |
List<ThingAttribute> things = result.getThings(); | |
// Now you have access to the Thing's name, thing type, version, and a map of attributes/tags | |
// Get all things of a specific type | |
String typeName = "LightsideSensor"; | |
ListThingsRequest listThingsRequest = new ListThingsRequest() | |
.withThingTypeName(typeName) | |
.withMaxResults(200); | |
ListThingsResult result = AwsClientFactory.getIotClient().listThings(listThingsRequest); | |
List<ThingAttribute> things = result.getThings(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment