Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. public class Application extends Controller {
  2.  
  3. static AWSIotClient awsIotClient;
  4.  
  5. private static void init() {
  6. AWSCredentials credentials = null;
  7. try {
  8. credentials = new ProfileCredentialsProvider().getCredentials();
  9. } catch (Exception e) {
  10. throw new AmazonClientException(
  11. "Cannot load the credentials from the credential profiles file. " +
  12. "Please make sure that your credentials file is at the correct " +
  13. "location (~/.aws/credentials), and is in valid format.",
  14. e);
  15. }
  16. awsIotClient = new AWSIotClient(credentials);
  17. Region usEast1 = Region.getRegion(Regions.US_EAST_1);
  18. awsIotClient.setRegion(usEast1);
  19. Logger.info("Creds init");
  20. }
  21.  
  22. public static Result index() {
  23. init();
  24. CreateTopicRuleRequest another_test = new CreateTopicRuleRequest();
  25. another_test.setRuleName("test");
  26. TopicRulePayload topicRulePayload = new TopicRulePayload();
  27. topicRulePayload.setDescription("A test rule");
  28. topicRulePayload.setSql("SELECT state.reported.turbineStatus FROM '$aws/things/turbine1/shadow/update/accepted' WHERE state.reported.turbineStatus=true");
  29. topicRulePayload.setActions(); // stuck here
  30. another_test.setTopicRulePayload(topicRulePayload);
  31. CreateTopicRuleResult test = awsIotClient.createTopicRule(another_test);
  32.  
  33. return ok(index.render("iot"));
  34. }
  35.  
  36. }
  37.  
  38. public static Result index() {
  39. init();
  40. CreateTopicRuleRequest another_test = new CreateTopicRuleRequest();
  41. another_test.setRuleName("test");
  42. TopicRulePayload topicRulePayload = new TopicRulePayload();
  43. topicRulePayload.setDescription("A test rule");
  44. topicRulePayload.setSql("SELECT state.reported.turbineStatus FROM '$aws/things/turbine1/shadow/update/accepted' WHERE state.reported.turbineStatus=true");
  45. ArrayList<Action> actionList = new ArrayList();
  46. Action action = new Action();
  47. S3Action s3 = new S3Action();
  48. s3.setRoleArn("arn:aws:iam::442759113924:role/sushant");
  49. s3.setBucketName("bajra-iot-test");
  50. s3.setKey("bajra-iot-test");
  51.  
  52. action.setS3(s3);
  53. actionList.add(action);
  54. topicRulePayload.setActions(actionList);
  55. another_test.setTopicRulePayload(topicRulePayload);
  56. CreateTopicRuleResult test = awsIotClient.createTopicRule(another_test);
  57.  
  58. return ok(index.render("iot"));
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement