当前位置: 首页>>代码示例>>Java>>正文


Java AmazonSNSClient.setRegion方法代码示例

本文整理汇总了Java中com.amazonaws.services.sns.AmazonSNSClient.setRegion方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonSNSClient.setRegion方法的具体用法?Java AmazonSNSClient.setRegion怎么用?Java AmazonSNSClient.setRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.sns.AmazonSNSClient的用法示例。


在下文中一共展示了AmazonSNSClient.setRegion方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.amazonaws.services.sns.AmazonSNSClient; //导入方法依赖的package包/类
@Override
public void run(Webhook webhook, String login, String email, String name, String subject, String content) {

    SNSWebhookApp webhookApp = (SNSWebhookApp) webhook.getWebhookApp();
    String topicArn = webhookApp.getTopicArn();
    String awsAccount = webhookApp.getAwsAccount();
    String awsSecret = webhookApp.getAwsSecret();
    String region = webhookApp.getRegion();
    AmazonSNSClient snsClient = new AmazonSNSClient(new BasicAWSCredentials(awsAccount, awsSecret));
    snsClient.setRegion(Region.getRegion(Regions.fromName(region)));

    try {
        PublishRequest publishReq = new PublishRequest()
                .withTopicArn(topicArn)
                .withMessage(getMessage(login, email, name, subject, content));
        snsClient.publish(publishReq);

    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Cannot send notification to SNS service", e);
    } finally {
        LOGGER.log(Level.INFO, "Webhook runner terminated");
    }
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:24,代码来源:SNSWebhookRunner.java

示例2: CreateCloudFrontSecurityGroupUpdaterLambdaOperation

import com.amazonaws.services.sns.AmazonSNSClient; //导入方法依赖的package包/类
@Inject
public CreateCloudFrontSecurityGroupUpdaterLambdaOperation(final CloudFormationService cloudFormationService,
                                                           final EnvironmentMetadata environmentMetadata,
                                                           @Named(CF_OBJECT_MAPPER) final ObjectMapper cloudformationObjectMapper,
                                                           AWSLambda awsLambda,
                                                           AmazonS3 amazonS3) {

    this.cloudFormationService = cloudFormationService;
    this.cloudformationObjectMapper = cloudformationObjectMapper;
    this.environmentMetadata = environmentMetadata;
    this.awsLambda = awsLambda;
    this.amazonS3 = amazonS3;

    final Region region = Region.getRegion(Regions.US_EAST_1);
    AmazonCloudFormation amazonCloudFormation = new AmazonCloudFormationClient();
    amazonCloudFormation.setRegion(region);
    amazonSNS = new AmazonSNSClient();
    amazonSNS.setRegion(region);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:20,代码来源:CreateCloudFrontSecurityGroupUpdaterLambdaOperation.java

示例3: handleRequest

import com.amazonaws.services.sns.AmazonSNSClient; //导入方法依赖的package包/类
public String handleRequest(Context context) throws IOException {
  LambdaLogger logger = context.getLogger();
  logger.log("handleRequest start.");
  ObjectMapper mapper = new ObjectMapper();
  JsonObject json = mapper.readValue(new URL(IP_RANGE_URL), JsonObject.class);

  AmazonS3Client s3 = getS3Client();
  Properties props = getProperties();
  s3.setEndpoint(props.getProperty("s3.endpoint"));

  GetObjectRequest request = new GetObjectRequest(props.getProperty(S3_BUCKETNAME_KEY), CHECKED_FILE_NAME);
  try {
    S3Object beforeObject = s3.getObject(request);
    InputStream is = beforeObject.getObjectContent();
    JsonObject beforeJson = mapper.readValue(is, JsonObject.class);
    Optional<String> diff = beforeJson.getDiff(json);
    if (diff.isPresent()) {
      AmazonSNSClient sns = getSNSClient();
      sns.setRegion(Region.getRegion(Regions.fromName(props.getProperty("sns.region"))));
      PublishRequest publishRequest = new PublishRequest(props.getProperty("sns.topic.arn"), diff.get(), SNS_SUBJECT);
      PublishResult result = sns.publish(publishRequest);
      logger.log("send sns message. messageId = " + result.getMessageId());
    }
  } catch (AmazonS3Exception e) {
    logger.log("before checked-ip-ranges.json does not exist.");
  }
  storeCheckedIpRange(json);
  logger.log("stored checked-ip-ranges.json");
  return "success";
}
 
开发者ID:haw-itn,项目名称:aws-iprange-update-checker,代码行数:31,代码来源:RangeCheckHandler.java

示例4: createSNSClient

import com.amazonaws.services.sns.AmazonSNSClient; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:14,代码来源:SNSQueueManagerImpl.java

示例5: amazonSNSClient

import com.amazonaws.services.sns.AmazonSNSClient; //导入方法依赖的package包/类
protected AmazonSNS amazonSNSClient() {
    AmazonSNSClient snsClient = new AmazonSNSClient(amazonCredentialsProvider());
    snsClient.setRegion(getRegion());
    return snsClient;
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:6,代码来源:AmazonConfigProvider.java

示例6: amazonSNSClient

import com.amazonaws.services.sns.AmazonSNSClient; //导入方法依赖的package包/类
@Override
protected AmazonSNS amazonSNSClient() {
    AmazonSNSClient snsClient = new AmazonSNSClient(awsCredentials());
    snsClient.setRegion(getRegion());
    return snsClient;
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:7,代码来源:AmazonConfigProviderDEV.java

示例7: Internals

import com.amazonaws.services.sns.AmazonSNSClient; //导入方法依赖的package包/类
private Internals() {
	snsClient = new AmazonSNSClient();
	snsClient.setRegion(Region.getRegion(Regions.EU_WEST_1));
}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:5,代码来源:Internals.java

示例8: publishToSnsTopic

import com.amazonaws.services.sns.AmazonSNSClient; //导入方法依赖的package包/类
private void publishToSnsTopic(String topicARN, String messageBody, int badgeNum, String soundName, Boolean isDebug) throws PushSnsSenderCustomException {

        theLogger.info("publishToSnsTopic has been called for topicARN:{} with messageBody:{}, badgeNum:{}, soundName:{} and isDebug:{}", topicARN, messageBody, badgeNum, soundName, isDebug);

        //check th params
        if (topicARN == null || messageBody == null) {
            throw new PushSnsSenderCustomException("Cannot send SNS notification because topicARN or messageBody is empty!");
        }

        //create AWS credentials
        if (awsAccessKey == null || awsSecretKey == null) {
            theLogger.error("AWS credentials not configured!");
            throw new PushSnsSenderCustomException("Internal server error!");   //say something via web
        }
        else {
            awsCreds = new BasicAWSCredentials(awsAccessKey, awsSecretKey);
        }

        //create a new SNS client with credentials
        AmazonSNSClient snsClient = new AmazonSNSClient(awsCreds);
        snsClient.setRegion(Region.getRegion(Regions.US_EAST_1));

        //publish to an SNS topic
        try {

            //Request
            PublishRequest publishRequest = new PublishRequest();
            SnsAppleNotificationTemplate appleNotificationTemplate = new SnsAppleNotificationTemplate(topicARN,
                                                                                                      messageBody,
                                                                                                      badgeNum,
                                                                                                      soundName,
                                                                                                      isDebug);

            publishRequest.setMessage(appleNotificationTemplate.toSnSAppleString());
            publishRequest.setMessageStructure("json");
            publishRequest.setTopicArn(topicARN);

            PublishResult publishResult = snsClient.publish(publishRequest);

            //print MessageId of message published to SNS topic
            theLogger.info("MessageId: {} was successfully published", publishResult.getMessageId());

        }

        catch (Exception theException) {
            //theLogger.error("Cannot send SNS notification! Exception: " + theException);
            throw new PushSnsSenderCustomException("publishToSnsTopic: Cannot send SNS notification! Exception: " + theException);
        }

        finally {
            snsClient.shutdown();
        }

    }
 
开发者ID:bigMOTOR,项目名称:PushSnsSender,代码行数:55,代码来源:SnsSenderController.java


注:本文中的com.amazonaws.services.sns.AmazonSNSClient.setRegion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。