/** * Setter for Jackson to deserialize Regions enum from string * * @param region */ public void setRegion(String region) { this.region = Regions.fromName(region); } }
/** * Returns the region configured for the default AWS SDK metric collector; * or null if the default is to be used. * * @throws IllegalArgumentException when using a region not included in * {@link Regions} * * @deprecated Use {@link #getRegionName()} */ public static Regions getRegion() throws IllegalArgumentException { return Regions.fromName(region.getName()); }
/** * Returns the the KMS region explicitly specified for the AWS KMS client * when such client is internally instantiated; or null if no explicit KMS * region is specified. This KMS region parameter is ignored when the AWS * KMS client of the S3 encryption client is explicitly passed in by the * users, instead of being implicitly created. * * @Deprecated This method is not forward compatible. Throws * IllegalArguementException when a new region is encountered. * * @use {@link #getAwsKmsRegion()} instead */ @Deprecated public Regions getKmsRegion() { if (awskmsRegion == null) return null; return Regions.fromName(awskmsRegion.getName()); }
@VisibleForTesting AWSSdkClient createAWSSdkClient() { return new AWSSdkClient(this.awsClusterSecurityManager, Region.getRegion(Regions.fromName(this.awsRegion))); }
/** * Get the region */ private Region getRegion() { String regionName = fig.getPrimaryRegion(); try { Regions regions = Regions.fromName(regionName); return Region.getRegion(regions); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("INVALID PRIMARY REGION FROM CONFIGURATION " + LegacyQueueFig.USERGRID_QUEUE_REGION_LOCAL + ": " + regionName, e); } }
s3Client.setRegion(Region.getRegion(Regions.fromName(region))); s3Client.setEndpoint(endPoint); System.out.println("Connection successfully initialized");
private AmazonS3 getS3Client() throws Exception{ this.bucketName = properties.getProperty( "usergrid.binary.bucketname" ); if(bucketName == null){ logger.error( "usergrid.binary.bucketname not properly set so amazon bucket is null" ); throw new AwsPropertiesNotFoundException( "usergrid.binary.bucketname" ); } final UsergridAwsCredentialsProvider ugProvider = new UsergridAwsCredentialsProvider(); AWSCredentials credentials = ugProvider.getCredentials(); ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.HTTP); s3Client = new AmazonS3Client(credentials, clientConfig); if(regionName != null) s3Client.setRegion( Region.getRegion(Regions.fromName(regionName)) ); return s3Client; }
private URI getCreateBucketEndpoint(String requestRegion) { // Route to the default endpoint if they're not trying to specify a different one in the request. if(requestRegion == null || requestRegion.equals(clientRegion) || !clientOptions.isForceGlobalBucketAccessEnabled()) { return endpoint; } // If they enabled global bucket access and they're trying to create a bucket in a region different than the default // one specified when they created the client, it will probably fail because only us-east-1 (actually the global // endpoint) is capable of creating buckets outside of its region. Override the endpoint to which the request // is routed so that it will succeed. com.amazonaws.regions.Region targetRegion = com.amazonaws.regions.Region.getRegion(Regions.fromName(requestRegion)); return new DefaultServiceEndpointBuilder(getEndpointPrefix(), clientConfiguration.getProtocol().toString()).withRegion(targetRegion) .getServiceEndpoint(); }
Region region = null; try { Regions regions = Regions.fromName(regionName); region = Region.getRegion(regions); String strSqsRegion = queueArnEntry.getValue(); Regions sqsRegions = Regions.fromName( strSqsRegion ); Region sqsRegion = Region.getRegion( sqsRegions ); Regions snsRegions = Regions.fromName( strSnsRegion ); Region snsRegion = Region.getRegion( snsRegions );
protected void initializeRegionAndEndpoint(ProcessContext context) { // if the processor supports REGION, get the configured region. if (getSupportedPropertyDescriptors().contains(REGION)) { final String region = context.getProperty(REGION).getValue(); if (region != null) { this.region = Region.getRegion(Regions.fromName(region)); client.setRegion(this.region); } else { this.region = null; } } // if the endpoint override has been configured, set the endpoint. // (per Amazon docs this should only be configured at client creation) if (getSupportedPropertyDescriptors().contains(ENDPOINT_OVERRIDE)) { final String urlstr = StringUtils.trimToEmpty(context.getProperty(ENDPOINT_OVERRIDE).evaluateAttributeExpressions().getValue()); if (!urlstr.isEmpty()) { getLogger().info("Overriding endpoint with {}", new Object[]{urlstr}); if (urlstr.endsWith(".vpce.amazonaws.com")) { String region = parseRegionForVPCE(urlstr); this.client.setEndpoint(urlstr, this.client.getServiceName(), region); } else { this.client.setEndpoint(urlstr); } } } }
client.setEndpoint(endpoint); } else if (!region.isEmpty()) { client.setRegion(Region.getRegion(Regions.fromName(region)));
/** * Returns the region configured for the default AWS SDK metric collector; * or null if the default is to be used. * * @throws IllegalArgumentException when using a region not included in * {@link Regions} * * @deprecated Use {@link #getRegionName()} */ public static Regions getRegion() throws IllegalArgumentException { return Regions.fromName(region.getName()); }
/** * Returns the region that the client is set to operate in. * Note: This may be different from the region the client uses in its signature. * @return the region that the client is set to operate in */ public Regions getRegions() { synchronized (this) { return Regions.fromName(this.region.getName()); } }
@Override protected GenericApiGatewayClient createClient(ProcessContext context, AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration) { GenericApiGatewayClientBuilder builder = new GenericApiGatewayClientBuilder() .withCredentials(awsCredentialsProvider).withClientConfiguration(clientConfiguration) .withEndpoint(context.getProperty(PROP_AWS_GATEWAY_API_ENDPOINT).getValue()).withRegion( Region.getRegion( Regions.fromName(context.getProperty(PROP_AWS_GATEWAY_API_REGION).getValue()))); if (context.getProperty(PROP_AWS_API_KEY).isSet()) { builder = builder.withApiKey(context.getProperty(PROP_AWS_API_KEY).evaluateAttributeExpressions().getValue()); } if (providedClient != null) { builder = builder.withHttpClient(providedClient); } return builder.build(); }
private static Regions getRegions(AWSConfiguration awsConfiguration) { try { final JSONObject ccpConfig = awsConfiguration.optJsonObject("CredentialsProvider") .optJSONObject("CognitoIdentity") .getJSONObject(awsConfiguration.getConfiguration()); return Regions.fromName(ccpConfig.getString("Region")); } catch (Exception e) { throw new IllegalArgumentException("Failed to read CognitoIdentity please check your setup or awsconfiguration.json file", e); } }
public BatchedClickEventsToKinesis(BlockingQueue<ClickEvent> inputQueue) { super(inputQueue); kinesis = new AmazonKinesisClient().withRegion( Regions.fromName(REGION)); entries = new ArrayList<>(); dataSize = 0; }
public BasicClickEventsToKinesis(BlockingQueue<ClickEvent> inputQueue) { super(inputQueue); kinesis = new AmazonKinesisClient().withRegion( Regions.fromName(REGION)); }
public AggregatingClickEventsToKinesis( BlockingQueue<ClickEvent> inputQueue) { super(inputQueue); kinesis = new AmazonKinesisClient().withRegion( Regions.fromName(REGION)); reset(); }
@Test public void testFromName() { final Regions usEast1 = Regions.fromName("us-east-1"); assertEquals(usEast1, Regions.US_EAST_1); final Regions cn1 = Regions.fromName("cn-north-1"); assertEquals(cn1, Regions.CN_NORTH_1); final Regions govCloud = Regions.fromName("us-gov-west-1"); assertEquals(govCloud, Regions.GovCloud); assertEquals(usEast1.getName(), "us-east-1"); } }