Skip to content

Commit

Permalink
Generated from 9fecbb9feb0b8ea3cbba6a02e84973b2bdf11378 (#250)
Browse files Browse the repository at this point in the history
remvoing extra async operations
  • Loading branch information
AutorestCI authored Mar 13, 2018
1 parent 27915c3 commit 3d1ee7f
Show file tree
Hide file tree
Showing 6 changed files with 434 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.management.containerinstance;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The size of the terminal.
*/
public class ContainerExecRequestTerminalSize {
/**
* The row size of the terminal.
*/
@JsonProperty(value = "row")
private Integer row;

/**
* The column size of the terminal.
*/
@JsonProperty(value = "column")
private Integer column;

/**
* Get the row value.
*
* @return the row value
*/
public Integer row() {
return this.row;
}

/**
* Set the row value.
*
* @param row the row value to set
* @return the ContainerExecRequestTerminalSize object itself.
*/
public ContainerExecRequestTerminalSize withRow(Integer row) {
this.row = row;
return this;
}

/**
* Get the column value.
*
* @return the column value
*/
public Integer column() {
return this.column;
}

/**
* Set the column value.
*
* @param column the column value to set
* @return the ContainerExecRequestTerminalSize object itself.
*/
public ContainerExecRequestTerminalSize withColumn(Integer column) {
this.column = column;
return this;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.management.containerinstance.implementation;

import com.microsoft.azure.management.containerinstance.ContainerExecRequestTerminalSize;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The start container exec request.
*/
public class ContainerExecRequestInner {
/**
* The command to be executed.
*/
@JsonProperty(value = "command")
private String command;

/**
* The size of the terminal.
*/
@JsonProperty(value = "terminalSize")
private ContainerExecRequestTerminalSize terminalSize;

/**
* Get the command value.
*
* @return the command value
*/
public String command() {
return this.command;
}

/**
* Set the command value.
*
* @param command the command value to set
* @return the ContainerExecRequestInner object itself.
*/
public ContainerExecRequestInner withCommand(String command) {
this.command = command;
return this;
}

/**
* Get the terminalSize value.
*
* @return the terminalSize value
*/
public ContainerExecRequestTerminalSize terminalSize() {
return this.terminalSize;
}

/**
* Set the terminalSize value.
*
* @param terminalSize the terminalSize value to set
* @return the ContainerExecRequestInner object itself.
*/
public ContainerExecRequestInner withTerminalSize(ContainerExecRequestTerminalSize terminalSize) {
this.terminalSize = terminalSize;
return this;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.management.containerinstance.implementation;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The information for the container exec command.
*/
public class ContainerExecResponseInner {
/**
* The uri for the exec websocket.
*/
@JsonProperty(value = "webSocketUri")
private String webSocketUri;

/**
* The password to start the exec command.
*/
@JsonProperty(value = "password")
private String password;

/**
* Get the webSocketUri value.
*
* @return the webSocketUri value
*/
public String webSocketUri() {
return this.webSocketUri;
}

/**
* Set the webSocketUri value.
*
* @param webSocketUri the webSocketUri value to set
* @return the ContainerExecResponseInner object itself.
*/
public ContainerExecResponseInner withWebSocketUri(String webSocketUri) {
this.webSocketUri = webSocketUri;
return this;
}

/**
* Get the password value.
*
* @return the password value
*/
public String password() {
return this.password;
}

/**
* Set the password value.
*
* @param password the password value to set
* @return the ContainerExecResponseInner object itself.
*/
public ContainerExecResponseInner withPassword(String password) {
this.password = password;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ interface ContainerGroupsService {
@PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}")
Observable<Response<ResponseBody>> createOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("containerGroupName") String containerGroupName, @Query("api-version") String apiVersion, @Body ContainerGroupInner containerGroup, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups beginCreateOrUpdate" })
@PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}")
Observable<Response<ResponseBody>> beginCreateOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("containerGroupName") String containerGroupName, @Query("api-version") String apiVersion, @Body ContainerGroupInner containerGroup, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.containerinstance.ContainerGroups update" })
@PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}")
Observable<Response<ResponseBody>> update(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("containerGroupName") String containerGroupName, @Query("api-version") String apiVersion, @Body Resource resource, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
Expand Down Expand Up @@ -435,7 +439,7 @@ private ServiceResponse<ContainerGroupInner> getByResourceGroupDelegate(Response
* @return the ContainerGroupInner object if successful.
*/
public ContainerGroupInner createOrUpdate(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).toBlocking().single().body();
return createOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).toBlocking().last().body();
}

/**
Expand All @@ -461,7 +465,7 @@ public ServiceFuture<ContainerGroupInner> createOrUpdateAsync(String resourceGro
* @param containerGroupName The name of the container group.
* @param containerGroup The properties of the container group to be created or updated.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ContainerGroupInner object
* @return the observable for the request
*/
public Observable<ContainerGroupInner> createOrUpdateAsync(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) {
return createOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).map(new Func1<ServiceResponse<ContainerGroupInner>, ContainerGroupInner>() {
Expand All @@ -480,7 +484,7 @@ public ContainerGroupInner call(ServiceResponse<ContainerGroupInner> response) {
* @param containerGroupName The name of the container group.
* @param containerGroup The properties of the container group to be created or updated.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ContainerGroupInner object
* @return the observable for the request
*/
public Observable<ServiceResponse<ContainerGroupInner>> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) {
if (this.client.subscriptionId() == null) {
Expand All @@ -499,68 +503,53 @@ public Observable<ServiceResponse<ContainerGroupInner>> createOrUpdateWithServic
throw new IllegalArgumentException("Parameter containerGroup is required and cannot be null.");
}
Validator.validate(containerGroup);
return service.createOrUpdate(this.client.subscriptionId(), resourceGroupName, containerGroupName, this.client.apiVersion(), containerGroup, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ContainerGroupInner>>>() {
@Override
public Observable<ServiceResponse<ContainerGroupInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<ContainerGroupInner> clientResponse = createOrUpdateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

private ServiceResponse<ContainerGroupInner> createOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<ContainerGroupInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<ContainerGroupInner>() { }.getType())
.register(201, new TypeToken<ContainerGroupInner>() { }.getType())
.registerError(CloudException.class)
.build(response);
Observable<Response<ResponseBody>> observable = service.createOrUpdate(this.client.subscriptionId(), resourceGroupName, containerGroupName, this.client.apiVersion(), containerGroup, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<ContainerGroupInner>() { }.getType());
}

/**
* Update container groups.
* Updates container group tags with specified values.
* Create or update container groups.
* Create or update container groups with specified configurations.
*
* @param resourceGroupName The name of the resource group.
* @param containerGroupName The name of the container group.
* @param containerGroup The properties of the container group to be created or updated.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws CloudException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ContainerGroupInner object if successful.
*/
public ContainerGroupInner update(String resourceGroupName, String containerGroupName) {
return updateWithServiceResponseAsync(resourceGroupName, containerGroupName).toBlocking().single().body();
public ContainerGroupInner beginCreateOrUpdate(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).toBlocking().single().body();
}

/**
* Update container groups.
* Updates container group tags with specified values.
* Create or update container groups.
* Create or update container groups with specified configurations.
*
* @param resourceGroupName The name of the resource group.
* @param containerGroupName The name of the container group.
* @param containerGroup The properties of the container group to be created or updated.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<ContainerGroupInner> updateAsync(String resourceGroupName, String containerGroupName, final ServiceCallback<ContainerGroupInner> serviceCallback) {
return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, containerGroupName), serviceCallback);
public ServiceFuture<ContainerGroupInner> beginCreateOrUpdateAsync(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup, final ServiceCallback<ContainerGroupInner> serviceCallback) {
return ServiceFuture.fromResponse(beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup), serviceCallback);
}

/**
* Update container groups.
* Updates container group tags with specified values.
* Create or update container groups.
* Create or update container groups with specified configurations.
*
* @param resourceGroupName The name of the resource group.
* @param containerGroupName The name of the container group.
* @param containerGroup The properties of the container group to be created or updated.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ContainerGroupInner object
*/
public Observable<ContainerGroupInner> updateAsync(String resourceGroupName, String containerGroupName) {
return updateWithServiceResponseAsync(resourceGroupName, containerGroupName).map(new Func1<ServiceResponse<ContainerGroupInner>, ContainerGroupInner>() {
public Observable<ContainerGroupInner> beginCreateOrUpdateAsync(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) {
return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, containerGroupName, containerGroup).map(new Func1<ServiceResponse<ContainerGroupInner>, ContainerGroupInner>() {
@Override
public ContainerGroupInner call(ServiceResponse<ContainerGroupInner> response) {
return response.body();
Expand All @@ -569,15 +558,16 @@ public ContainerGroupInner call(ServiceResponse<ContainerGroupInner> response) {
}

/**
* Update container groups.
* Updates container group tags with specified values.
* Create or update container groups.
* Create or update container groups with specified configurations.
*
* @param resourceGroupName The name of the resource group.
* @param containerGroupName The name of the container group.
* @param containerGroup The properties of the container group to be created or updated.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the ContainerGroupInner object
*/
public Observable<ServiceResponse<ContainerGroupInner>> updateWithServiceResponseAsync(String resourceGroupName, String containerGroupName) {
public Observable<ServiceResponse<ContainerGroupInner>> beginCreateOrUpdateWithServiceResponseAsync(String resourceGroupName, String containerGroupName, ContainerGroupInner containerGroup) {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
Expand All @@ -590,13 +580,16 @@ public Observable<ServiceResponse<ContainerGroupInner>> updateWithServiceRespons
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
final Resource resource = null;
return service.update(this.client.subscriptionId(), resourceGroupName, containerGroupName, this.client.apiVersion(), resource, this.client.acceptLanguage(), this.client.userAgent())
if (containerGroup == null) {
throw new IllegalArgumentException("Parameter containerGroup is required and cannot be null.");
}
Validator.validate(containerGroup);
return service.beginCreateOrUpdate(this.client.subscriptionId(), resourceGroupName, containerGroupName, this.client.apiVersion(), containerGroup, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ContainerGroupInner>>>() {
@Override
public Observable<ServiceResponse<ContainerGroupInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<ContainerGroupInner> clientResponse = updateDelegate(response);
ServiceResponse<ContainerGroupInner> clientResponse = beginCreateOrUpdateDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
Expand All @@ -605,6 +598,14 @@ public Observable<ServiceResponse<ContainerGroupInner>> call(Response<ResponseBo
});
}

private ServiceResponse<ContainerGroupInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<ContainerGroupInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<ContainerGroupInner>() { }.getType())
.register(201, new TypeToken<ContainerGroupInner>() { }.getType())
.registerError(CloudException.class)
.build(response);
}

/**
* Update container groups.
* Updates container group tags with specified values.
Expand Down Expand Up @@ -678,6 +679,9 @@ public Observable<ServiceResponse<ContainerGroupInner>> updateWithServiceRespons
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
if (resource == null) {
throw new IllegalArgumentException("Parameter resource is required and cannot be null.");
}
Validator.validate(resource);
return service.update(this.client.subscriptionId(), resourceGroupName, containerGroupName, this.client.apiVersion(), resource, this.client.acceptLanguage(), this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ContainerGroupInner>>>() {
Expand Down
Loading

0 comments on commit 3d1ee7f

Please sign in to comment.