use of okhttp3.Request in project azure-sdk-for-java by Azure.
the class AuthenticationTests method canCRUDWebAppWithAuthentication.
@Test
@Ignore("Need facebook developer account")
public void canCRUDWebAppWithAuthentication() throws Exception {
// Create with new app service plan
WebApp webApp1 = appServiceManager.webApps().define(WEBAPP_NAME_1).withRegion(Region.US_WEST).withNewResourceGroup(RG_NAME_1).withNewWindowsPlan(PricingTier.BASIC_B1).defineAuthentication().withDefaultAuthenticationProvider(BuiltInAuthenticationProvider.FACEBOOK).withFacebook("appId", "appSecret").attach().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());
Request request = new Request.Builder().url("http://" + webApp1.defaultHostName()).get().build();
String response = new OkHttpClient.Builder().readTimeout(1, TimeUnit.MINUTES).build().newCall(request).execute().body().string();
Assert.assertTrue(response.contains("do not have permission"));
// Update
webApp1.update().updateAuthentication().withAnonymousAuthentication().parent().apply();
request = new Request.Builder().url("http://" + webApp1.defaultHostName()).get().build();
response = new OkHttpClient.Builder().readTimeout(1, TimeUnit.MINUTES).build().newCall(request).execute().body().string();
Assert.assertFalse(response.contains("do not have permission"));
}
use of okhttp3.Request in project azure-sdk-for-java by Azure.
the class JobSchedulesImpl method patchAsync.
/**
* Updates the properties of the specified job schedule.
*
* @param jobScheduleId The id of the job schedule to update.
* @param jobSchedulePatchParameter The parameters for the request.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if callback is null
* @return the {@link Call} object
*/
public ServiceCall patchAsync(String jobScheduleId, JobSchedulePatchParameter jobSchedulePatchParameter, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
if (serviceCallback == null) {
throw new IllegalArgumentException("ServiceCallback is required for async calls.");
}
if (jobScheduleId == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter jobScheduleId is required and cannot be null."));
return null;
}
if (jobSchedulePatchParameter == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter jobSchedulePatchParameter is required and cannot be null."));
return null;
}
if (this.client.apiVersion() == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
return null;
}
Validator.validate(jobSchedulePatchParameter, serviceCallback);
final JobSchedulePatchOptions jobSchedulePatchOptions = null;
Integer timeout = null;
String clientRequestId = null;
Boolean returnClientRequestId = null;
DateTime ocpDate = null;
String ifMatch = null;
String ifNoneMatch = null;
DateTime ifModifiedSince = null;
DateTime ifUnmodifiedSince = null;
DateTimeRfc1123 ocpDateConverted = null;
if (ocpDate != null) {
ocpDateConverted = new DateTimeRfc1123(ocpDate);
}
DateTimeRfc1123 ifModifiedSinceConverted = null;
if (ifModifiedSince != null) {
ifModifiedSinceConverted = new DateTimeRfc1123(ifModifiedSince);
}
DateTimeRfc1123 ifUnmodifiedSinceConverted = null;
if (ifUnmodifiedSince != null) {
ifUnmodifiedSinceConverted = new DateTimeRfc1123(ifUnmodifiedSince);
}
Call<ResponseBody> call = service.patch(jobScheduleId, jobSchedulePatchParameter, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.userAgent());
final ServiceCall serviceCall = new ServiceCall(call);
call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
serviceCallback.success(patchDelegate(response));
} catch (BatchErrorException | IOException exception) {
serviceCallback.failure(exception);
}
}
});
return serviceCall;
}
use of okhttp3.Request in project azure-sdk-for-java by Azure.
the class JobSchedulesImpl method updateAsync.
/**
* Updates the properties of the specified job schedule.
*
* @param jobScheduleId The id of the job schedule to update.
* @param jobScheduleUpdateParameter The parameters for the request.
* @param jobScheduleUpdateOptions Additional parameters for the operation
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if callback is null
* @return the {@link Call} object
*/
public ServiceCall updateAsync(String jobScheduleId, JobScheduleUpdateParameter jobScheduleUpdateParameter, JobScheduleUpdateOptions jobScheduleUpdateOptions, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
if (serviceCallback == null) {
throw new IllegalArgumentException("ServiceCallback is required for async calls.");
}
if (jobScheduleId == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter jobScheduleId is required and cannot be null."));
return null;
}
if (jobScheduleUpdateParameter == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter jobScheduleUpdateParameter is required and cannot be null."));
return null;
}
if (this.client.apiVersion() == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
return null;
}
Validator.validate(jobScheduleUpdateParameter, serviceCallback);
Validator.validate(jobScheduleUpdateOptions, serviceCallback);
Integer timeout = null;
if (jobScheduleUpdateOptions != null) {
timeout = jobScheduleUpdateOptions.timeout();
}
String clientRequestId = null;
if (jobScheduleUpdateOptions != null) {
clientRequestId = jobScheduleUpdateOptions.clientRequestId();
}
Boolean returnClientRequestId = null;
if (jobScheduleUpdateOptions != null) {
returnClientRequestId = jobScheduleUpdateOptions.returnClientRequestId();
}
DateTime ocpDate = null;
if (jobScheduleUpdateOptions != null) {
ocpDate = jobScheduleUpdateOptions.ocpDate();
}
String ifMatch = null;
if (jobScheduleUpdateOptions != null) {
ifMatch = jobScheduleUpdateOptions.ifMatch();
}
String ifNoneMatch = null;
if (jobScheduleUpdateOptions != null) {
ifNoneMatch = jobScheduleUpdateOptions.ifNoneMatch();
}
DateTime ifModifiedSince = null;
if (jobScheduleUpdateOptions != null) {
ifModifiedSince = jobScheduleUpdateOptions.ifModifiedSince();
}
DateTime ifUnmodifiedSince = null;
if (jobScheduleUpdateOptions != null) {
ifUnmodifiedSince = jobScheduleUpdateOptions.ifUnmodifiedSince();
}
DateTimeRfc1123 ocpDateConverted = null;
if (ocpDate != null) {
ocpDateConverted = new DateTimeRfc1123(ocpDate);
}
DateTimeRfc1123 ifModifiedSinceConverted = null;
if (ifModifiedSince != null) {
ifModifiedSinceConverted = new DateTimeRfc1123(ifModifiedSince);
}
DateTimeRfc1123 ifUnmodifiedSinceConverted = null;
if (ifUnmodifiedSince != null) {
ifUnmodifiedSinceConverted = new DateTimeRfc1123(ifUnmodifiedSince);
}
Call<ResponseBody> call = service.update(jobScheduleId, jobScheduleUpdateParameter, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.userAgent());
final ServiceCall serviceCall = new ServiceCall(call);
call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
serviceCallback.success(updateDelegate(response));
} catch (BatchErrorException | IOException exception) {
serviceCallback.failure(exception);
}
}
});
return serviceCall;
}
use of okhttp3.Request in project azure-sdk-for-java by Azure.
the class JobsImpl method patchAsync.
/**
* Updates the properties of a job.
*
* @param jobId The id of the job whose properties you want to update.
* @param jobPatchParameter The parameters for the request.
* @param jobPatchOptions Additional parameters for the operation
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if callback is null
* @return the {@link Call} object
*/
public ServiceCall patchAsync(String jobId, JobPatchParameter jobPatchParameter, JobPatchOptions jobPatchOptions, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
if (serviceCallback == null) {
throw new IllegalArgumentException("ServiceCallback is required for async calls.");
}
if (jobId == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter jobId is required and cannot be null."));
return null;
}
if (jobPatchParameter == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter jobPatchParameter is required and cannot be null."));
return null;
}
if (this.client.apiVersion() == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
return null;
}
Validator.validate(jobPatchParameter, serviceCallback);
Validator.validate(jobPatchOptions, serviceCallback);
Integer timeout = null;
if (jobPatchOptions != null) {
timeout = jobPatchOptions.timeout();
}
String clientRequestId = null;
if (jobPatchOptions != null) {
clientRequestId = jobPatchOptions.clientRequestId();
}
Boolean returnClientRequestId = null;
if (jobPatchOptions != null) {
returnClientRequestId = jobPatchOptions.returnClientRequestId();
}
DateTime ocpDate = null;
if (jobPatchOptions != null) {
ocpDate = jobPatchOptions.ocpDate();
}
String ifMatch = null;
if (jobPatchOptions != null) {
ifMatch = jobPatchOptions.ifMatch();
}
String ifNoneMatch = null;
if (jobPatchOptions != null) {
ifNoneMatch = jobPatchOptions.ifNoneMatch();
}
DateTime ifModifiedSince = null;
if (jobPatchOptions != null) {
ifModifiedSince = jobPatchOptions.ifModifiedSince();
}
DateTime ifUnmodifiedSince = null;
if (jobPatchOptions != null) {
ifUnmodifiedSince = jobPatchOptions.ifUnmodifiedSince();
}
DateTimeRfc1123 ocpDateConverted = null;
if (ocpDate != null) {
ocpDateConverted = new DateTimeRfc1123(ocpDate);
}
DateTimeRfc1123 ifModifiedSinceConverted = null;
if (ifModifiedSince != null) {
ifModifiedSinceConverted = new DateTimeRfc1123(ifModifiedSince);
}
DateTimeRfc1123 ifUnmodifiedSinceConverted = null;
if (ifUnmodifiedSince != null) {
ifUnmodifiedSinceConverted = new DateTimeRfc1123(ifUnmodifiedSince);
}
Call<ResponseBody> call = service.patch(jobId, jobPatchParameter, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.userAgent());
final ServiceCall serviceCall = new ServiceCall(call);
call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
serviceCallback.success(patchDelegate(response));
} catch (BatchErrorException | IOException exception) {
serviceCallback.failure(exception);
}
}
});
return serviceCall;
}
use of okhttp3.Request in project azure-sdk-for-java by Azure.
the class PoolsImpl method resizeAsync.
/**
* Changes the number of compute nodes that are assigned to a pool.
*
* @param poolId The id of the pool to resize.
* @param poolResizeParameter The parameters for the request.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if callback is null
* @return the {@link Call} object
*/
public ServiceCall resizeAsync(String poolId, PoolResizeParameter poolResizeParameter, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
if (serviceCallback == null) {
throw new IllegalArgumentException("ServiceCallback is required for async calls.");
}
if (poolId == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
return null;
}
if (poolResizeParameter == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter poolResizeParameter is required and cannot be null."));
return null;
}
if (this.client.apiVersion() == null) {
serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
return null;
}
Validator.validate(poolResizeParameter, serviceCallback);
final PoolResizeOptions poolResizeOptions = null;
Integer timeout = null;
String clientRequestId = null;
Boolean returnClientRequestId = null;
DateTime ocpDate = null;
String ifMatch = null;
String ifNoneMatch = null;
DateTime ifModifiedSince = null;
DateTime ifUnmodifiedSince = null;
DateTimeRfc1123 ocpDateConverted = null;
if (ocpDate != null) {
ocpDateConverted = new DateTimeRfc1123(ocpDate);
}
DateTimeRfc1123 ifModifiedSinceConverted = null;
if (ifModifiedSince != null) {
ifModifiedSinceConverted = new DateTimeRfc1123(ifModifiedSince);
}
DateTimeRfc1123 ifUnmodifiedSinceConverted = null;
if (ifUnmodifiedSince != null) {
ifUnmodifiedSinceConverted = new DateTimeRfc1123(ifUnmodifiedSince);
}
Call<ResponseBody> call = service.resize(poolId, poolResizeParameter, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, ifMatch, ifNoneMatch, ifModifiedSinceConverted, ifUnmodifiedSinceConverted, this.client.userAgent());
final ServiceCall serviceCall = new ServiceCall(call);
call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
serviceCallback.success(resizeDelegate(response));
} catch (BatchErrorException | IOException exception) {
serviceCallback.failure(exception);
}
}
});
return serviceCall;
}
Aggregations