/** * The Synchronous SNS client is used for creating topics and subscribing queues. */ private AmazonSNSClient createSNSClient( final Region region ) { final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider(); final AmazonSNSClient sns = new AmazonSNSClient( ugProvider.getCredentials(), clientConfiguration ); sns.setRegion( region ); return sns; }
new AsyncTask<Void, Void, Void>(){ @Override protected Void doInBackground(Void... params) { AWSCredentials awsCredentials = new BasicAWSCredentials("access Key", "secret Key"); AmazonSNSClient pushClient = new AmazonSNSClient(awsCredentials); CreatePlatformEndpointRequest platformEndpointRequest = new CreatePlatformEndpointRequest(); platformEndpointRequest.setToken(regToken); platformEndpointRequest.setPlatformApplicationArn(platformApplicationArn); pushClient.setRegion(Region.getRegion(Regions.Region_Name)); CreatePlatformEndpointResult result = pushClient.createPlatformEndpoint(platformEndpointRequest); Log.e("Registration result",result.toString()); return null; }
AmazonSNSClient snsClient = new AmazonSNSClient(new DefaultAWSCredentialsProviderChain()); snsClient.setRegion(Region.getRegion(Regions.US_WEST_2)); List<Topic> topicArns = new ArrayList<>(); ListTopicsResult result = snsClient.listTopics(); topicArns.addAll(result.getTopics()); while (result.getNextToken() != null) { result = snsClient.listTopics(result.getNextToken()); topicArns.addAll(result.getTopics()); } for (Topic topic : topicArns) { System.out.println(topic.getTopicArn()); } snsClient.shutdown();
snsClient.setRegion(Region.getRegion(Regions.EU_WEST_1));
private void updateSNSFunction(Arn bindingArn, LambdaFunctionDefinition d) throws Exception { AmazonSNSClient client = createServiceFor(AmazonSNSClient.class); client.setRegion(Region.getRegion(Regions.fromName(bindingArn.getRegion()))); SubscribeRequest req = new SubscribeRequest().withTopicArn(bindingArn.getSourceArn()).withProtocol("lambda").withEndpoint(d.getArn()); final SubscribeResult subscribe = client.subscribe(req); getLog().info("Subscribed topic arn " + bindingArn.getSourceArn() + " to function " + d.getArn() + ": " + subscribe); // TODO: Unsubscribe older versions }
client.setRegion(Region.getRegion(Regions.EU_WEST_1)); client.addRequestHandler(mHandler); return client;
public StreamMonitor(AutoscalingConfiguration config) throws Exception { this.config = config; Region setRegion = Region.getRegion(Regions.fromName(this.config.getRegion())); this.scaler = new StreamScaler(setRegion); this.cloudWatchClient = new AmazonCloudWatchClient(new DefaultAWSCredentialsProviderChain()); this.cloudWatchClient.setRegion(setRegion); this.kinesisClient = new AmazonKinesisClient(new DefaultAWSCredentialsProviderChain()); this.kinesisClient.setRegion(setRegion); this.snsClient = new AmazonSNSClient(new DefaultAWSCredentialsProviderChain()); this.snsClient.setRegion(setRegion); }