use of software.amazon.awssdk.core.client.config.ClientOverrideConfiguration in project flink by apache.
the class AWSAsyncSinkUtilTest method testCreateKinesisAsyncClient.
@Test
public void testCreateKinesisAsyncClient() {
Properties properties = TestUtil.properties(AWS_REGION, "eu-west-2");
MockAsyncClientBuilder builder = mockKinesisAsyncClientBuilder();
ClientOverrideConfiguration clientOverrideConfiguration = ClientOverrideConfiguration.builder().build();
SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder().build();
AWSAsyncSinkUtil.createAwsAsyncClient(properties, builder, httpClient, clientOverrideConfiguration);
verify(builder).overrideConfiguration(clientOverrideConfiguration);
verify(builder).httpClient(httpClient);
verify(builder).region(Region.of("eu-west-2"));
verify(builder).credentialsProvider(argThat(cp -> cp instanceof DefaultCredentialsProvider));
verify(builder, never()).endpointOverride(any());
}
use of software.amazon.awssdk.core.client.config.ClientOverrideConfiguration in project flink by apache.
the class AWSAsyncSinkUtilTest method testCreateKinesisAsyncClientWithEndpointOverride.
@Test
public void testCreateKinesisAsyncClientWithEndpointOverride() {
Properties properties = TestUtil.properties(AWS_REGION, "eu-west-2");
properties.setProperty(AWS_ENDPOINT, "https://localhost");
MockAsyncClientBuilder builder = mockKinesisAsyncClientBuilder();
ClientOverrideConfiguration clientOverrideConfiguration = ClientOverrideConfiguration.builder().build();
SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder().build();
AWSAsyncSinkUtil.createAwsAsyncClient(properties, builder, httpClient, clientOverrideConfiguration);
verify(builder).endpointOverride(URI.create("https://localhost"));
}
use of software.amazon.awssdk.core.client.config.ClientOverrideConfiguration in project aws-doc-sdk-examples by awsdocs.
the class SendNotifications method handleVoiceMessage.
public String handleVoiceMessage(String myDom) throws JDOMException, IOException {
String mobileNum = "";
List<String> listVal = new ArrayList<>();
listVal.add("application/json");
Map<String, List<String>> values = new HashMap<>();
values.put("Content-Type", listVal);
ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
PinpointSmsVoiceClient client = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
SAXBuilder builder = new SAXBuilder();
Document jdomDocument = builder.build(new InputSource(new StringReader(myDom)));
org.jdom2.Element root = jdomDocument.getRootElement();
// get a list of children elements.
List<org.jdom2.Element> students = root.getChildren("Student");
for (org.jdom2.Element element : students) {
mobileNum = element.getChildText("Phone");
sendVoiceMsg(client, mobileNum);
}
client.close();
return mobileNum;
}
use of software.amazon.awssdk.core.client.config.ClientOverrideConfiguration in project aws-doc-sdk-examples by awsdocs.
the class SendVoiceMessage method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + "SendVoiceMessage <originationNumber> <destinationNumber> \n\n" + "Where:\n" + " originationNumber - the phone number or short code that you specify has to be associated with your Amazon Pinpoint account. For best results, specify long codes in E.164 format (for example, +1-555-555-5654). " + " destinationNumber - the recipient's phone number. For best results, you should specify the phone number in E.164 format (for example, +1-555-555-5654). ";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String originationNumber = args[0];
String destinationNumber = args[1];
System.out.println("Sending a voice message");
// Set the content type to application/json
List<String> listVal = new ArrayList<>();
listVal.add("application/json");
Map<String, List<String>> values = new HashMap<>();
values.put("Content-Type", listVal);
ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
PinpointSmsVoiceClient client = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
sendVoiceMsg(client, originationNumber, destinationNumber);
client.close();
}
use of software.amazon.awssdk.core.client.config.ClientOverrideConfiguration in project aws-doc-sdk-examples by awsdocs.
the class AmazonPinpointTest method setUp.
@BeforeAll
public static void setUp() throws IOException {
// Run tests on Real AWS Resources
region = Region.US_EAST_1;
pinpoint = PinpointClient.builder().region(region).build();
s3Client = S3Client.builder().region(region).build();
// Set the VoiceClient
// Set the content type to application/json
List<String> listVal = new ArrayList<>();
listVal.add("application/json");
Map<String, List<String>> values = new HashMap<>();
values.put("Content-Type", listVal);
ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
voiceClient = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
try (InputStream input = AmazonPinpointTest.class.getClassLoader().getResourceAsStream("config.properties")) {
Properties prop = new Properties();
if (input == null) {
System.out.println("Sorry, unable to find config.properties");
return;
}
// load a properties file from class path, inside static method
prop.load(input);
// Populate the data members required for all tests
appName = prop.getProperty("appName");
bucket = prop.getProperty("bucket");
path = prop.getProperty("path");
roleArn = prop.getProperty("roleArn");
userId = prop.getProperty("userId");
s3BucketName = prop.getProperty("s3BucketName");
s3BucketName = prop.getProperty("s3BucketName");
iamExportRoleArn = prop.getProperty("iamExportRoleArn");
existingApplicationId = prop.getProperty("existingApplicationId");
filePath = prop.getProperty("filePath");
subject = prop.getProperty("subject");
senderAddress = prop.getProperty("senderAddress");
toAddress = prop.getProperty("toAddress");
originationNumber = prop.getProperty("originationNumber");
destinationNumber = prop.getProperty("destinationNumber");
message = prop.getProperty("message");
} catch (IOException ex) {
ex.printStackTrace();
}
}
Aggregations