use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-sdk-for-java by Azure.
the class TestNSG method createResource.
@Override
public NetworkSecurityGroup createResource(NetworkSecurityGroups nsgs) throws Exception {
final String newName = "nsg" + this.testId;
final String resourceGroupName = "rg" + this.testId;
final String nicName = "nic" + this.testId;
final Region region = Region.US_WEST;
final SettableFuture<NetworkSecurityGroup> nsgFuture = SettableFuture.create();
// Create
Observable<Indexable> resourceStream = nsgs.define(newName).withRegion(region).withNewResourceGroup(resourceGroupName).defineRule("rule1").allowOutbound().fromAnyAddress().fromPort(80).toAnyAddress().toPort(80).withProtocol(SecurityRuleProtocol.TCP).attach().defineRule("rule2").allowInbound().fromAnyAddress().fromAnyPort().toAnyAddress().toPortRange(22, 25).withAnyProtocol().withPriority(200).withDescription("foo!!").attach().createAsync();
Utils.<NetworkSecurityGroup>rootResource(resourceStream).subscribe(new Subscriber<NetworkSecurityGroup>() {
@Override
public void onCompleted() {
System.out.print("completed");
}
@Override
public void onError(Throwable throwable) {
nsgFuture.setException(throwable);
}
@Override
public void onNext(NetworkSecurityGroup networkSecurityGroup) {
nsgFuture.set(networkSecurityGroup);
}
});
NetworkSecurityGroup nsg = nsgFuture.get();
NetworkInterface nic = nsgs.manager().networkInterfaces().define(nicName).withRegion(region).withExistingResourceGroup(resourceGroupName).withNewPrimaryNetwork("10.0.0.0/28").withPrimaryPrivateIPAddressDynamic().withExistingNetworkSecurityGroup(nsg).create();
nsg.refresh();
// Verify
Assert.assertTrue(nsg.region().equals(region));
Assert.assertTrue(nsg.securityRules().size() == 2);
// Confirm NIC association
Assert.assertEquals(1, nsg.networkInterfaceIds().size());
Assert.assertTrue(nsg.networkInterfaceIds().contains(nic.id()));
return nsg;
}
use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-sdk-for-java by Azure.
the class AzureTests method testApplicationGatewaysInParallel.
@Test
public void testApplicationGatewaysInParallel() throws Exception {
String rgName = SdkContext.randomResourceName("rg", 13);
Region region = Region.US_EAST;
Creatable<ResourceGroup> resourceGroup = azure.resourceGroups().define(rgName).withRegion(region);
List<Creatable<ApplicationGateway>> agCreatables = new ArrayList<>();
agCreatables.add(azure.applicationGateways().define(SdkContext.randomResourceName("ag", 13)).withRegion(Region.US_EAST).withNewResourceGroup(resourceGroup).defineRequestRoutingRule("rule1").fromPrivateFrontend().fromFrontendHttpPort(80).toBackendHttpPort(8080).toBackendIPAddress("10.0.0.1").toBackendIPAddress("10.0.0.2").attach());
agCreatables.add(azure.applicationGateways().define(SdkContext.randomResourceName("ag", 13)).withRegion(Region.US_EAST).withNewResourceGroup(resourceGroup).defineRequestRoutingRule("rule1").fromPrivateFrontend().fromFrontendHttpPort(80).toBackendHttpPort(8080).toBackendIPAddress("10.0.0.3").toBackendIPAddress("10.0.0.4").attach());
CreatedResources<ApplicationGateway> created = azure.applicationGateways().create(agCreatables);
List<ApplicationGateway> ags = new ArrayList<>();
List<String> agIds = new ArrayList<>();
for (Creatable<ApplicationGateway> creatable : agCreatables) {
ApplicationGateway ag = created.get(creatable.key());
Assert.assertNotNull(ag);
ags.add(ag);
agIds.add(ag.id());
}
azure.applicationGateways().stop(agIds);
for (ApplicationGateway ag : ags) {
Assert.assertEquals(ApplicationGatewayOperationalState.STOPPED, ag.refresh().operationalState());
}
azure.applicationGateways().start(agIds);
for (ApplicationGateway ag : ags) {
Assert.assertEquals(ApplicationGatewayOperationalState.RUNNING, ag.refresh().operationalState());
}
azure.applicationGateways().deleteByIds(agIds);
for (String id : agIds) {
Assert.assertNull(azure.applicationGateways().getById(id));
}
azure.resourceGroups().beginDeleteByName(rgName);
}
use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-sdk-for-java by Azure.
the class AzureTests method listLocations.
/**
* Tests location listing.
* @throws Exception
*/
@Test
public void listLocations() throws Exception {
Subscription subscription = azure.getCurrentSubscription();
Assert.assertNotNull(subscription);
for (Location location : subscription.listLocations()) {
Region region = Region.findByLabelOrName(location.name());
Assert.assertNotNull(region);
Assert.assertEquals(region, location.region());
Assert.assertEquals(region.name().toLowerCase(), location.name().toLowerCase());
}
Location location = subscription.getLocationByRegion(Region.US_WEST);
Assert.assertNotNull(location);
Assert.assertTrue(Region.US_WEST.name().equalsIgnoreCase(location.name()));
}
use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-sdk-for-java by Azure.
the class TestCdn method createResource.
@Override
public CdnProfile createResource(CdnProfiles profiles) throws Exception {
final Region region = Region.US_EAST;
final String groupName = "rg" + this.testId;
final String cdnProfileName = "cdnProfile" + this.testId;
final String cdnEndpointName = "cdnEndpoint" + this.testId;
final String cdnOriginHostName = "mylinuxapp.azurewebsites.net";
CdnProfile cdnProfile = profiles.define(cdnProfileName).withRegion(region).withNewResourceGroup(groupName).withStandardAkamaiSku().defineNewEndpoint(cdnEndpointName).withOrigin(cdnOriginHostName).withGeoFilter("/path/videos", GeoFilterActions.BLOCK, CountryIsoCode.ARGENTINA).withGeoFilter("/path/images", GeoFilterActions.BLOCK, CountryIsoCode.BELGIUM).withContentTypeToCompress("text/plain").withCompressionEnabled(true).withQueryStringCachingBehavior(QueryStringCachingBehavior.BYPASS_CACHING).withHttpsAllowed(true).withHttpsPort(444).withHttpAllowed(false).withHttpPort(85).attach().create();
Assert.assertTrue(cdnProfile.sku().name().equals(SkuName.STANDARD_AKAMAI));
Assert.assertNotNull(cdnProfile.endpoints());
Assert.assertEquals(1, cdnProfile.endpoints().size());
CdnEndpoint endpoint = cdnProfile.endpoints().get(cdnEndpointName);
Assert.assertNotNull(endpoint);
Assert.assertEquals(cdnOriginHostName, endpoint.originHostName());
Assert.assertEquals(444, endpoint.httpsPort());
Assert.assertEquals(85, endpoint.httpPort());
Assert.assertFalse(endpoint.isHttpAllowed());
Assert.assertTrue(endpoint.isHttpsAllowed());
Assert.assertTrue(endpoint.isCompressionEnabled());
Assert.assertEquals(QueryStringCachingBehavior.BYPASS_CACHING, endpoint.queryStringCachingBehavior());
Assert.assertNotNull(endpoint.geoFilters());
Assert.assertEquals(QueryStringCachingBehavior.BYPASS_CACHING, endpoint.queryStringCachingBehavior());
for (ResourceUsage usage : profiles.listResourceUsage()) {
Assert.assertNotNull(usage);
Assert.assertEquals("profile", usage.resourceType());
}
for (EdgeNode node : profiles.listEdgeNodes()) {
Assert.assertNotNull(node);
}
for (ResourceUsage usage : cdnProfile.listResourceUsage()) {
Assert.assertNotNull(usage);
Assert.assertEquals("endpoint", usage.resourceType());
}
for (CdnEndpoint ep : cdnProfile.endpoints().values()) {
for (ResourceUsage usage : ep.listResourceUsage()) {
Assert.assertNotNull(usage);
Assert.assertTrue("customdomain".equals(usage.resourceType()) || "geofilter".equals(usage.resourceType()));
}
}
return cdnProfile;
}
use of com.microsoft.azure.management.resources.fluentcore.arm.Region in project azure-tools-for-java by Microsoft.
the class AzureNewDockerConfigPage method updateDockerLocationGroup.
private void updateDockerLocationGroup(Composite mainContainer) {
AzureDockerSubscription currentSubscription = getCurrentSubscription();
dockerLocationComboBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String region = dockerLocationComboBox.getText();
if (!region.equals(SELECT_REGION)) {
Region regionObj = Region.findByLabelOrName(region);
String selectedRegion = regionObj != null ? regionObj.name() : region;
if (preferredLocation == null && selectedRegion != null) {
// remove the SELECT_REGION entry (first entry in the
// list)
dockerLocationComboBox.remove(SELECT_REGION);
}
preferredLocation = selectedRegion;
updateDockerSelectVnetComboBox(mainContainer, currentSubscription, selectedRegion);
setPageComplete(doValidate());
} else {
updateDockerSelectVnetComboBox(mainContainer, currentSubscription, null);
setPageComplete(false);
}
updateDockerHostVMSizeComboBox(mainContainer, dockerHostVMPreferredSizesCheckBox.getSelection());
}
});
updateDockerLocationComboBox(mainContainer, currentSubscription);
}
Aggregations