use of retrofit2.Response in project azure-sdk-for-java by Azure.
the class HostnameSslTests method canBindHostnameAndSsl.
@Test
@Ignore("Need a domain and a certificate")
public void canBindHostnameAndSsl() throws Exception {
// hostname binding
appServiceManager.webApps().define(WEBAPP_NAME).withRegion(Region.US_WEST).withNewResourceGroup(RG_NAME).withNewWindowsPlan(PricingTier.BASIC_B1).defineHostnameBinding().withAzureManagedDomain(domain).withSubDomain(WEBAPP_NAME).withDnsRecordType(CustomHostNameDnsRecordType.CNAME).attach().create();
WebApp webApp = appServiceManager.webApps().getByResourceGroup(RG_NAME, WEBAPP_NAME);
Assert.assertNotNull(webApp);
if (!IS_MOCKED) {
Response response = curl("http://" + WEBAPP_NAME + "." + DOMAIN);
Assert.assertEquals(200, response.code());
Assert.assertNotNull(response.body().string());
}
// hostname binding shortcut
webApp.update().withManagedHostnameBindings(domain, WEBAPP_NAME + "-1", WEBAPP_NAME + "-2").apply();
if (!IS_MOCKED) {
Response response = curl("http://" + WEBAPP_NAME + "-1." + DOMAIN);
Assert.assertEquals(200, response.code());
Assert.assertNotNull(response.body().string());
response = curl("http://" + WEBAPP_NAME + "-2." + DOMAIN);
Assert.assertEquals(200, response.code());
Assert.assertNotNull(response.body().string());
}
// SSL binding
webApp.update().defineSslBinding().forHostname(WEBAPP_NAME + "." + DOMAIN).withExistingAppServiceCertificateOrder(certificateOrder).withSniBasedSsl().attach().apply();
if (!IS_MOCKED) {
Response response = null;
int retryCount = 3;
while (response == null && retryCount > 0) {
try {
response = curl("https://" + WEBAPP_NAME + "." + DOMAIN);
} catch (SSLPeerUnverifiedException e) {
retryCount--;
Thread.sleep(5000);
}
}
if (retryCount == 0) {
fail();
}
Assert.assertEquals(200, response.code());
Assert.assertNotNull(response.body().string());
}
}
use of retrofit2.Response in project azure-sdk-for-java by Azure.
the class LinuxWebAppsTests method canCRUDLinuxWebApp.
@Test
public void canCRUDLinuxWebApp() throws Exception {
// Create with new app service plan
WebApp webApp1 = appServiceManager.webApps().define(WEBAPP_NAME_1).withRegion(Region.US_WEST).withNewResourceGroup(RG_NAME_1).withNewLinuxPlan(PricingTier.BASIC_B1).withPublicDockerHubImage("wordpress").create();
Assert.assertNotNull(webApp1);
Assert.assertEquals(Region.US_WEST, webApp1.region());
AppServicePlan plan1 = appServiceManager.appServicePlans().getById(webApp1.appServicePlanId());
Assert.assertNotNull(plan1);
Assert.assertEquals(Region.US_WEST, plan1.region());
Assert.assertEquals(PricingTier.BASIC_B1, plan1.pricingTier());
Assert.assertEquals(OperatingSystem.LINUX, plan1.operatingSystem());
Assert.assertEquals(OperatingSystem.LINUX, webApp1.operatingSystem());
// Create in a new group with existing app service plan
WebApp webApp2 = appServiceManager.webApps().define(WEBAPP_NAME_2).withExistingWindowsPlan(plan1).withNewResourceGroup(RG_NAME_2).create();
Assert.assertNotNull(webApp2);
Assert.assertEquals(Region.US_WEST, webApp2.region());
Assert.assertEquals(OperatingSystem.LINUX, webApp2.operatingSystem());
// Get
WebApp webApp = appServiceManager.webApps().getByResourceGroup(RG_NAME_1, webApp1.name());
Assert.assertEquals(OperatingSystem.LINUX, webApp.operatingSystem());
webApp = appServiceManager.webApps().getById(webApp2.id());
Assert.assertEquals(OperatingSystem.LINUX, webApp.operatingSystem());
// Update
webApp1.update().withNewAppServicePlan(PricingTier.STANDARD_S2).apply();
AppServicePlan plan2 = appServiceManager.appServicePlans().getById(webApp1.appServicePlanId());
Assert.assertNotNull(plan2);
Assert.assertEquals(Region.US_WEST, plan2.region());
Assert.assertEquals(PricingTier.STANDARD_S2, plan2.pricingTier());
Assert.assertEquals(OperatingSystem.LINUX, plan2.operatingSystem());
webApp1.update().withBuiltInImage(RuntimeStack.NODEJS_6_6_0).defineSourceControl().withPublicGitRepository("https://github.com/jianghaolu/azure-site-test").withBranch("master").attach().apply();
Assert.assertNotNull(webApp);
if (!IS_MOCKED) {
Response response = curl("http://" + webApp1.defaultHostName());
Assert.assertEquals(200, response.code());
String body = response.body().string();
Assert.assertNotNull(body);
Assert.assertTrue(body.contains("Hello world from linux 4"));
}
}
use of retrofit2.Response in project azure-sdk-for-java by Azure.
the class SourceControlTests method canDeploySourceControl.
@Test
public void canDeploySourceControl() throws Exception {
// Create web app
WebApp webApp = appServiceManager.webApps().define(WEBAPP_NAME).withRegion(Region.US_WEST).withNewResourceGroup(RG_NAME).withNewWindowsPlan(PricingTier.STANDARD_S1).defineSourceControl().withPublicGitRepository("https://github.com/jianghaolu/azure-site-test").withBranch("master").attach().create();
Assert.assertNotNull(webApp);
if (!IS_MOCKED) {
Response response = curl("http://" + WEBAPP_NAME + "." + "azurewebsites.net");
Assert.assertEquals(200, response.code());
String body = response.body().string();
Assert.assertNotNull(body);
Assert.assertTrue(body.contains("Hello world from linux 4"));
}
}
use of retrofit2.Response in project azure-sdk-for-java by Azure.
the class VirtualMachineScaleSetsInner method beginDeallocateWithServiceResponseAsync.
/**
* Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates.
*
* @param resourceGroupName The name of the resource group.
* @param vmScaleSetName The name of the VM scale set.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginDeallocateWithServiceResponseAsync(String resourceGroupName, String vmScaleSetName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmScaleSetName == null) {
throw new IllegalArgumentException("Parameter vmScaleSetName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2016-04-30-preview";
final List<String> instanceIds = null;
VirtualMachineScaleSetVMInstanceIDs vmInstanceIDs = new VirtualMachineScaleSetVMInstanceIDs();
vmInstanceIDs.withInstanceIds(null);
return service.beginDeallocate(resourceGroupName, vmScaleSetName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), vmInstanceIDs, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginDeallocateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
use of retrofit2.Response in project azure-sdk-for-java by Azure.
the class VirtualMachineScaleSetsInner method beginUpdateInstancesWithServiceResponseAsync.
/**
* Upgrades one or more virtual machines to the latest SKU set in the VM scale set model.
*
* @param resourceGroupName The name of the resource group.
* @param vmScaleSetName The name of the VM scale set.
* @param instanceIds The virtual machine scale set instance ids.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the OperationStatusResponseInner object
*/
public Observable<ServiceResponse<OperationStatusResponseInner>> beginUpdateInstancesWithServiceResponseAsync(String resourceGroupName, String vmScaleSetName, List<String> instanceIds) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (vmScaleSetName == null) {
throw new IllegalArgumentException("Parameter vmScaleSetName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (instanceIds == null) {
throw new IllegalArgumentException("Parameter instanceIds is required and cannot be null.");
}
Validator.validate(instanceIds);
final String apiVersion = "2016-04-30-preview";
VirtualMachineScaleSetVMInstanceRequiredIDs vmInstanceIDs = new VirtualMachineScaleSetVMInstanceRequiredIDs();
vmInstanceIDs.withInstanceIds(instanceIds);
return service.beginUpdateInstances(resourceGroupName, vmScaleSetName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), vmInstanceIDs, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<OperationStatusResponseInner>>>() {
@Override
public Observable<ServiceResponse<OperationStatusResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<OperationStatusResponseInner> clientResponse = beginUpdateInstancesDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
Aggregations