diff --git a/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/ServerAdministratorResource.java b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/ServerAdministratorResource.java new file mode 100644 index 000000000000..794202fbf3d9 --- /dev/null +++ b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/ServerAdministratorResource.java @@ -0,0 +1,56 @@ +/** + * 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.mysql.v2017_12_01_preview; + +import com.microsoft.azure.arm.model.HasInner; +import com.microsoft.azure.management.mysql.v2017_12_01_preview.implementation.ServerAdministratorResourceInner; +import com.microsoft.azure.arm.resources.models.HasManager; +import com.microsoft.azure.management.mysql.v2017_12_01_preview.implementation.DBforMySQLManager; +import java.util.UUID; + +/** + * Type representing ServerAdministratorResource. + */ +public interface ServerAdministratorResource extends HasInner, HasManager { + /** + * @return the administratorType value. + */ + String administratorType(); + + /** + * @return the id value. + */ + String id(); + + /** + * @return the login value. + */ + String login(); + + /** + * @return the name value. + */ + String name(); + + /** + * @return the sid value. + */ + UUID sid(); + + /** + * @return the tenantId value. + */ + UUID tenantId(); + + /** + * @return the type value. + */ + String type(); + +} diff --git a/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/ServerAdministrators.java b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/ServerAdministrators.java new file mode 100644 index 000000000000..a4c3ceb06165 --- /dev/null +++ b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/ServerAdministrators.java @@ -0,0 +1,62 @@ +/** + * 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.mysql.v2017_12_01_preview; + +import rx.Observable; +import rx.Completable; +import com.microsoft.azure.management.mysql.v2017_12_01_preview.implementation.ServerAdministratorResourceInner; +import com.microsoft.azure.management.mysql.v2017_12_01_preview.implementation.ServerAdministratorsInner; +import com.microsoft.azure.arm.model.HasInner; + +/** + * Type representing ServerAdministrators. + */ +public interface ServerAdministrators extends HasInner { + /** + * Gets information about a AAD server administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable getAsync(String resourceGroupName, String serverName); + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable createOrUpdateAsync(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties); + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable deleteAsync(String resourceGroupName, String serverName); + + /** + * Returns a list of server Administrators. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + Observable listByServerAsync(String resourceGroupName, String serverName); + +} diff --git a/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/DBforMySQLManager.java b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/DBforMySQLManager.java index 264cf8d0cdcb..8785cd32b27c 100644 --- a/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/DBforMySQLManager.java +++ b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/DBforMySQLManager.java @@ -23,6 +23,7 @@ import com.microsoft.azure.management.mysql.v2017_12_01_preview.Databases; import com.microsoft.azure.management.mysql.v2017_12_01_preview.Configurations; import com.microsoft.azure.management.mysql.v2017_12_01_preview.LogFiles; +import com.microsoft.azure.management.mysql.v2017_12_01_preview.ServerAdministrators; import com.microsoft.azure.management.mysql.v2017_12_01_preview.LocationBasedPerformanceTiers; import com.microsoft.azure.management.mysql.v2017_12_01_preview.CheckNameAvailabilitys; import com.microsoft.azure.management.mysql.v2017_12_01_preview.ServerSecurityAlertPolicies; @@ -41,6 +42,7 @@ public final class DBforMySQLManager extends ManagerCore implements ServerAdministratorResource { + private final DBforMySQLManager manager; + + ServerAdministratorResourceImpl(ServerAdministratorResourceInner inner, DBforMySQLManager manager) { + super(inner); + this.manager = manager; + } + + @Override + public DBforMySQLManager manager() { + return this.manager; + } + + + + @Override + public String administratorType() { + return this.inner().administratorType(); + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public String login() { + return this.inner().login(); + } + + @Override + public String name() { + return this.inner().name(); + } + + @Override + public UUID sid() { + return this.inner().sid(); + } + + @Override + public UUID tenantId() { + return this.inner().tenantId(); + } + + @Override + public String type() { + return this.inner().type(); + } + +} diff --git a/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorResourceInner.java b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorResourceInner.java new file mode 100644 index 000000000000..ee2220d47934 --- /dev/null +++ b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorResourceInner.java @@ -0,0 +1,135 @@ +/** + * 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.mysql.v2017_12_01_preview.implementation; + +import java.util.UUID; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.ProxyResource; + +/** + * Represents a and external administrator to be created. + */ +@JsonFlatten +public class ServerAdministratorResourceInner extends ProxyResource { + /** + * The type of administrator. + */ + @JsonProperty(value = "properties.administratorType", required = true) + private String administratorType; + + /** + * The server administrator login value. + */ + @JsonProperty(value = "properties.login", required = true) + private String login; + + /** + * The server administrator Sid (Secure ID). + */ + @JsonProperty(value = "properties.sid", required = true) + private UUID sid; + + /** + * The server Active Directory Administrator tenant id. + */ + @JsonProperty(value = "properties.tenantId", required = true) + private UUID tenantId; + + /** + * Creates an instance of ServerAdministratorResourceInner class. + * @param login the server administrator login value. + * @param sid the server administrator Sid (Secure ID). + * @param tenantId the server Active Directory Administrator tenant id. + */ + public ServerAdministratorResourceInner() { + administratorType = "ActiveDirectory"; + } + + /** + * Get the type of administrator. + * + * @return the administratorType value + */ + public String administratorType() { + return this.administratorType; + } + + /** + * Set the type of administrator. + * + * @param administratorType the administratorType value to set + * @return the ServerAdministratorResourceInner object itself. + */ + public ServerAdministratorResourceInner withAdministratorType(String administratorType) { + this.administratorType = administratorType; + return this; + } + + /** + * Get the server administrator login value. + * + * @return the login value + */ + public String login() { + return this.login; + } + + /** + * Set the server administrator login value. + * + * @param login the login value to set + * @return the ServerAdministratorResourceInner object itself. + */ + public ServerAdministratorResourceInner withLogin(String login) { + this.login = login; + return this; + } + + /** + * Get the server administrator Sid (Secure ID). + * + * @return the sid value + */ + public UUID sid() { + return this.sid; + } + + /** + * Set the server administrator Sid (Secure ID). + * + * @param sid the sid value to set + * @return the ServerAdministratorResourceInner object itself. + */ + public ServerAdministratorResourceInner withSid(UUID sid) { + this.sid = sid; + return this; + } + + /** + * Get the server Active Directory Administrator tenant id. + * + * @return the tenantId value + */ + public UUID tenantId() { + return this.tenantId; + } + + /** + * Set the server Active Directory Administrator tenant id. + * + * @param tenantId the tenantId value to set + * @return the ServerAdministratorResourceInner object itself. + */ + public ServerAdministratorResourceInner withTenantId(UUID tenantId) { + this.tenantId = tenantId; + return this; + } + +} diff --git a/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorsImpl.java b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorsImpl.java new file mode 100644 index 000000000000..3a173baefffb --- /dev/null +++ b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorsImpl.java @@ -0,0 +1,89 @@ +/** + * 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.mysql.v2017_12_01_preview.implementation; + +import com.microsoft.azure.arm.model.implementation.WrapperImpl; +import com.microsoft.azure.management.mysql.v2017_12_01_preview.ServerAdministrators; +import rx.Observable; +import rx.functions.Func1; +import java.util.List; +import com.microsoft.azure.management.mysql.v2017_12_01_preview.ServerAdministratorResource; + +class ServerAdministratorsImpl extends WrapperImpl implements ServerAdministrators { + private final DBforMySQLManager manager; + + ServerAdministratorsImpl(DBforMySQLManager manager) { + super(manager.inner().serverAdministrators()); + this.manager = manager; + } + + public DBforMySQLManager manager() { + return this.manager; + } + + private ServerAdministratorResourceImpl wrapModel(ServerAdministratorResourceInner inner) { + return new ServerAdministratorResourceImpl(inner, manager()); + } + + @Override + public Observable getAsync(String resourceGroupName, String serverName) { + ServerAdministratorsInner client = this.inner(); + return client.getAsync(resourceGroupName, serverName) + .map(new Func1() { + @Override + public ServerAdministratorResource call(ServerAdministratorResourceInner inner) { + return new ServerAdministratorResourceImpl(inner, manager()); + } + }); + } + + @Override + public Observable createOrUpdateAsync(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties) { + ServerAdministratorsInner client = this.inner(); + return client.createOrUpdateAsync(resourceGroupName, serverName, properties) + .map(new Func1() { + @Override + public ServerAdministratorResource call(ServerAdministratorResourceInner inner) { + return new ServerAdministratorResourceImpl(inner, manager()); + } + }); + } + + @Override + public Observable deleteAsync(String resourceGroupName, String serverName) { + ServerAdministratorsInner client = this.inner(); + return client.deleteAsync(resourceGroupName, serverName) + .map(new Func1() { + @Override + public ServerAdministratorResource call(ServerAdministratorResourceInner inner) { + return new ServerAdministratorResourceImpl(inner, manager()); + } + }); + } + + @Override + public Observable listByServerAsync(String resourceGroupName, String serverName) { + ServerAdministratorsInner client = this.inner(); + return client.listByServerAsync(resourceGroupName, serverName) + .flatMap(new Func1, Observable>() { + @Override + public Observable call(List innerList) { + return Observable.from(innerList); + } + }) + .map(new Func1() { + @Override + public ServerAdministratorResource call(ServerAdministratorResourceInner inner) { + return wrapModel(inner); + } + }); + } + +} diff --git a/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorsInner.java b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorsInner.java new file mode 100644 index 000000000000..b57ca0f94cf4 --- /dev/null +++ b/mysql/resource-manager/v2017_12_01_preview/src/main/java/com/microsoft/azure/management/mysql/v2017_12_01_preview/implementation/ServerAdministratorsInner.java @@ -0,0 +1,592 @@ +/** + * 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.mysql.v2017_12_01_preview.implementation; + +import com.microsoft.azure.arm.collection.InnerSupportsDelete; +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in ServerAdministrators. + */ +public class ServerAdministratorsInner implements InnerSupportsDelete { + /** The Retrofit service to perform REST calls. */ + private ServerAdministratorsService service; + /** The service client containing this operation class. */ + private MySQLManagementClientImpl client; + + /** + * Initializes an instance of ServerAdministratorsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ServerAdministratorsInner(Retrofit retrofit, MySQLManagementClientImpl client) { + this.service = retrofit.create(ServerAdministratorsService.class); + this.client = client; + } + + /** + * The interface defining all the services for ServerAdministrators to be + * used by Retrofit to perform actually REST calls. + */ + interface ServerAdministratorsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.mysql.v2017_12_01_preview.ServerAdministrators get" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/Administrators/activeDirectory") + Observable> get(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Query("api-version") String apiVersion, @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.mysql.v2017_12_01_preview.ServerAdministrators createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/Administrators/activeDirectory") + Observable> createOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Query("api-version") String apiVersion, @Body ServerAdministratorResourceInner properties, @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.mysql.v2017_12_01_preview.ServerAdministrators beginCreateOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/Administrators/activeDirectory") + Observable> beginCreateOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Query("api-version") String apiVersion, @Body ServerAdministratorResourceInner properties, @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.mysql.v2017_12_01_preview.ServerAdministrators delete" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/Administrators/activeDirectory", method = "DELETE", hasBody = true) + Observable> delete(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Query("api-version") String apiVersion, @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.mysql.v2017_12_01_preview.ServerAdministrators beginDelete" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/Administrators/activeDirectory", method = "DELETE", hasBody = true) + Observable> beginDelete(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Query("api-version") String apiVersion, @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.mysql.v2017_12_01_preview.ServerAdministrators listByServer" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/servers/{serverName}/administrators") + Observable> listByServer(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("serverName") String serverName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Gets information about a AAD server administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @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 ServerAdministratorResourceInner object if successful. + */ + public ServerAdministratorResourceInner get(String resourceGroupName, String serverName) { + return getWithServiceResponseAsync(resourceGroupName, serverName).toBlocking().single().body(); + } + + /** + * Gets information about a AAD server administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @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 getAsync(String resourceGroupName, String serverName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getWithServiceResponseAsync(resourceGroupName, serverName), serviceCallback); + } + + /** + * Gets information about a AAD server administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerAdministratorResourceInner object + */ + public Observable getAsync(String resourceGroupName, String serverName) { + return getWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1, ServerAdministratorResourceInner>() { + @Override + public ServerAdministratorResourceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets information about a AAD server administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerAdministratorResourceInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String serverName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(this.client.subscriptionId(), resourceGroupName, serverName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @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 ServerAdministratorResourceInner object if successful. + */ + public ServerAdministratorResourceInner createOrUpdate(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, properties).toBlocking().last().body(); + } + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @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 createOrUpdateAsync(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, properties), serviceCallback); + } + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable createOrUpdateAsync(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, properties).map(new Func1, ServerAdministratorResourceInner>() { + @Override + public ServerAdministratorResourceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (properties == null) { + throw new IllegalArgumentException("Parameter properties is required and cannot be null."); + } + Validator.validate(properties); + Observable> observable = service.createOrUpdate(this.client.subscriptionId(), resourceGroupName, serverName, this.client.apiVersion(), properties, this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @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 ServerAdministratorResourceInner object if successful. + */ + public ServerAdministratorResourceInner beginCreateOrUpdate(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties) { + return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, properties).toBlocking().single().body(); + } + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @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 beginCreateOrUpdateAsync(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, properties), serviceCallback); + } + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerAdministratorResourceInner object + */ + public Observable beginCreateOrUpdateAsync(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties) { + return beginCreateOrUpdateWithServiceResponseAsync(resourceGroupName, serverName, properties).map(new Func1, ServerAdministratorResourceInner>() { + @Override + public ServerAdministratorResourceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Creates or update active directory administrator on an existing server. The update action will overwrite the existing administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @param properties The required parameters for creating or updating an AAD server administrator. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerAdministratorResourceInner object + */ + public Observable> beginCreateOrUpdateWithServiceResponseAsync(String resourceGroupName, String serverName, ServerAdministratorResourceInner properties) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + if (properties == null) { + throw new IllegalArgumentException("Parameter properties is required and cannot be null."); + } + Validator.validate(properties); + return service.beginCreateOrUpdate(this.client.subscriptionId(), resourceGroupName, serverName, this.client.apiVersion(), properties, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginCreateOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginCreateOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @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 ServerAdministratorResourceInner object if successful. + */ + public ServerAdministratorResourceInner delete(String resourceGroupName, String serverName) { + return deleteWithServiceResponseAsync(resourceGroupName, serverName).toBlocking().last().body(); + } + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @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 deleteAsync(String resourceGroupName, String serverName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, serverName), serviceCallback); + } + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable deleteAsync(String resourceGroupName, String serverName) { + return deleteWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1, ServerAdministratorResourceInner>() { + @Override + public ServerAdministratorResourceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable for the request + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String serverName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Observable> observable = service.delete(this.client.subscriptionId(), resourceGroupName, serverName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()); + return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType()); + } + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @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 ServerAdministratorResourceInner object if successful. + */ + public ServerAdministratorResourceInner beginDelete(String resourceGroupName, String serverName) { + return beginDeleteWithServiceResponseAsync(resourceGroupName, serverName).toBlocking().single().body(); + } + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @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 beginDeleteAsync(String resourceGroupName, String serverName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(beginDeleteWithServiceResponseAsync(resourceGroupName, serverName), serviceCallback); + } + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerAdministratorResourceInner object + */ + public Observable beginDeleteAsync(String resourceGroupName, String serverName) { + return beginDeleteWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1, ServerAdministratorResourceInner>() { + @Override + public ServerAdministratorResourceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Deletes AAD Administrator. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the ServerAdministratorResourceInner object + */ + public Observable> beginDeleteWithServiceResponseAsync(String resourceGroupName, String serverName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.beginDelete(this.client.subscriptionId(), resourceGroupName, serverName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = beginDeleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse beginDeleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(202, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Returns a list of server Administrators. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @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 List<ServerAdministratorResourceInner> object if successful. + */ + public List listByServer(String resourceGroupName, String serverName) { + return listByServerWithServiceResponseAsync(resourceGroupName, serverName).toBlocking().single().body(); + } + + /** + * Returns a list of server Administrators. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @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> listByServerAsync(String resourceGroupName, String serverName, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listByServerWithServiceResponseAsync(resourceGroupName, serverName), serviceCallback); + } + + /** + * Returns a list of server Administrators. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<ServerAdministratorResourceInner> object + */ + public Observable> listByServerAsync(String resourceGroupName, String serverName) { + return listByServerWithServiceResponseAsync(resourceGroupName, serverName).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + + /** + * Returns a list of server Administrators. + * + * @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + * @param serverName The name of the server. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<ServerAdministratorResourceInner> object + */ + public Observable>> listByServerWithServiceResponseAsync(String resourceGroupName, String serverName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (serverName == null) { + throw new IllegalArgumentException("Parameter serverName is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listByServer(this.client.subscriptionId(), resourceGroupName, serverName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByServerDelegate(response); + List items = null; + if (result.body() != null) { + items = result.body().items(); + } + ServiceResponse> clientResponse = new ServiceResponse>(items, result.response()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByServerDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., CloudException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +}