Skip to content

Instantly share code, notes, and snippets.

Steve Perkins steveperkins

Block or report user

Report or block steveperkins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:e6ffe08180d2d7c7366e532ec5279551
AWSIotData iotDataClient = AWSIotDataClientBuilder
.standard()
.withRegion(Regions.US_WEST_2)
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(CLIENT_TOKEN, CLIENT_SECRET))).build();
String thingName = "plant-manager";
GetThingShadowResult getThingShadowResult = iotDataClient.getThingShadow(new GetThingShadowRequest().withThingName(thingName));
String state = new String( getThingShadowResult.getPayload().array(), StandardCharsets.UTF_8);
// state is now a JSON string representing the plant-manager Thing Shadow's state
/* {
View AWSIotClientDemo.java
// 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());
View SmsNotificationService.java
package org.lightside.notification;
import java.util.HashMap;
import java.util.Map;
import org.lightside.main.AwsClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.services.sns.model.MessageAttributeValue;
View AwsClientFactoryDemo.java
package org.lightside.demo;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.iotdata.AWSIotData;
import com.amazonaws.services.iotdata.AWSIotDataClientBuilder;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
import com.amazonaws.services.sns.AmazonSNSClient;
You can’t perform that action at this time.