All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.azure.management.powerbi.implementation.WorkspaceCollectionsInner Maven / Gradle / Ivy

There is a newer version: 1.10.0-beta
Show newest version
/**
 * 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.powerbi.implementation;

import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsGet;
import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete;
import retrofit2.Retrofit;
import com.google.common.reflect.TypeToken;
import com.microsoft.azure.management.powerbi.AccessKeyName;
import com.microsoft.azure.management.powerbi.ErrorException;
import com.microsoft.azure.management.powerbi.UpdateWorkspaceCollectionRequest;
import com.microsoft.azure.management.powerbi.WorkspaceCollectionAccessKey;
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 java.util.Map;
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.PATCH;
import retrofit2.http.Path;
import retrofit2.http.POST;
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 WorkspaceCollections.
 */
public class WorkspaceCollectionsInner implements InnerSupportsGet, InnerSupportsDelete {
    /** The Retrofit service to perform REST calls. */
    private WorkspaceCollectionsService service;
    /** The service client containing this operation class. */
    private PowerBIEmbeddedManagementClientImpl client;

    /**
     * Initializes an instance of WorkspaceCollectionsInner.
     *
     * @param retrofit the Retrofit instance built from a Retrofit Builder.
     * @param client the instance of the service client containing this operation class.
     */
    public WorkspaceCollectionsInner(Retrofit retrofit, PowerBIEmbeddedManagementClientImpl client) {
        this.service = retrofit.create(WorkspaceCollectionsService.class);
        this.client = client;
    }

    /**
     * The interface defining all the services for WorkspaceCollections to be
     * used by Retrofit to perform actually REST calls.
     */
    interface WorkspaceCollectionsService {
        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.powerbi.WorkspaceCollections getByResourceGroup" })
        @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBI/workspaceCollections/{workspaceCollectionName}")
        Observable> getByResourceGroup(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("workspaceCollectionName") String workspaceCollectionName, @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.powerbi.WorkspaceCollections create" })
        @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBI/workspaceCollections/{workspaceCollectionName}")
        Observable> create(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("workspaceCollectionName") String workspaceCollectionName, @Query("api-version") String apiVersion, @Body CreateWorkspaceCollectionRequestInner body, @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.powerbi.WorkspaceCollections update" })
        @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBI/workspaceCollections/{workspaceCollectionName}")
        Observable> update(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("workspaceCollectionName") String workspaceCollectionName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body UpdateWorkspaceCollectionRequest body, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.powerbi.WorkspaceCollections delete" })
        @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBI/workspaceCollections/{workspaceCollectionName}", method = "DELETE", hasBody = true)
        Observable> delete(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("workspaceCollectionName") String workspaceCollectionName, @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.powerbi.WorkspaceCollections beginDelete" })
        @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBI/workspaceCollections/{workspaceCollectionName}", method = "DELETE", hasBody = true)
        Observable> beginDelete(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("workspaceCollectionName") String workspaceCollectionName, @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.powerbi.WorkspaceCollections checkNameAvailability" })
        @POST("subscriptions/{subscriptionId}/providers/Microsoft.PowerBI/locations/{location}/checkNameAvailability")
        Observable> checkNameAvailability(@Path("subscriptionId") String subscriptionId, @Path("location") String location, @Query("api-version") String apiVersion, @Body CheckNameRequestInner body, @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.powerbi.WorkspaceCollections listByResourceGroup" })
        @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBI/workspaceCollections")
        Observable> listByResourceGroup(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @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.powerbi.WorkspaceCollections listBySubscription" })
        @GET("subscriptions/{subscriptionId}/providers/Microsoft.PowerBI/workspaceCollections")
        Observable> listBySubscription(@Path("subscriptionId") String subscriptionId, @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.powerbi.WorkspaceCollections getAccessKeys" })
        @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBI/workspaceCollections/{workspaceCollectionName}/listKeys")
        Observable> getAccessKeys(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("workspaceCollectionName") String workspaceCollectionName, @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.powerbi.WorkspaceCollections regenerateKey" })
        @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBI/workspaceCollections/{workspaceCollectionName}/regenerateKey")
        Observable> regenerateKey(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("workspaceCollectionName") String workspaceCollectionName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body WorkspaceCollectionAccessKey body, @Header("User-Agent") String userAgent);

        @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.powerbi.WorkspaceCollections migrate" })
        @POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/moveResources")
        Observable> migrate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Query("api-version") String apiVersion, @Body MigrateWorkspaceCollectionRequestInner body, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

    }

    /**
     * Retrieves an existing Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the WorkspaceCollectionInner object if successful.
     */
    public WorkspaceCollectionInner getByResourceGroup(String resourceGroupName, String workspaceCollectionName) {
        return getByResourceGroupWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).toBlocking().single().body();
    }

    /**
     * Retrieves an existing Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @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 getByResourceGroupAsync(String resourceGroupName, String workspaceCollectionName, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(getByResourceGroupWithServiceResponseAsync(resourceGroupName, workspaceCollectionName), serviceCallback);
    }

    /**
     * Retrieves an existing Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionInner object
     */
    public Observable getByResourceGroupAsync(String resourceGroupName, String workspaceCollectionName) {
        return getByResourceGroupWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).map(new Func1, WorkspaceCollectionInner>() {
            @Override
            public WorkspaceCollectionInner call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Retrieves an existing Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionInner object
     */
    public Observable> getByResourceGroupWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName 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.getByResourceGroup(this.client.subscriptionId(), resourceGroupName, workspaceCollectionName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = getByResourceGroupDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse getByResourceGroupDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Creates a new Power BI Workspace Collection with the specified properties. A Power BI Workspace Collection contains one or more workspaces, and can be used to provision keys that provide API access to those workspaces.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param body Create workspace collection request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the WorkspaceCollectionInner object if successful.
     */
    public WorkspaceCollectionInner create(String resourceGroupName, String workspaceCollectionName, CreateWorkspaceCollectionRequestInner body) {
        return createWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, body).toBlocking().single().body();
    }

    /**
     * Creates a new Power BI Workspace Collection with the specified properties. A Power BI Workspace Collection contains one or more workspaces, and can be used to provision keys that provide API access to those workspaces.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param body Create workspace collection request
     * @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 createAsync(String resourceGroupName, String workspaceCollectionName, CreateWorkspaceCollectionRequestInner body, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(createWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, body), serviceCallback);
    }

    /**
     * Creates a new Power BI Workspace Collection with the specified properties. A Power BI Workspace Collection contains one or more workspaces, and can be used to provision keys that provide API access to those workspaces.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param body Create workspace collection request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionInner object
     */
    public Observable createAsync(String resourceGroupName, String workspaceCollectionName, CreateWorkspaceCollectionRequestInner body) {
        return createWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, body).map(new Func1, WorkspaceCollectionInner>() {
            @Override
            public WorkspaceCollectionInner call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Creates a new Power BI Workspace Collection with the specified properties. A Power BI Workspace Collection contains one or more workspaces, and can be used to provision keys that provide API access to those workspaces.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param body Create workspace collection request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionInner object
     */
    public Observable> createWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName, CreateWorkspaceCollectionRequestInner body) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName 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 (body == null) {
            throw new IllegalArgumentException("Parameter body is required and cannot be null.");
        }
        Validator.validate(body);
        return service.create(this.client.subscriptionId(), resourceGroupName, workspaceCollectionName, this.client.apiVersion(), body, this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = createDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse createDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Update an existing Power BI Workspace Collection with the specified properties.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the WorkspaceCollectionInner object if successful.
     */
    public WorkspaceCollectionInner update(String resourceGroupName, String workspaceCollectionName) {
        return updateWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).toBlocking().single().body();
    }

    /**
     * Update an existing Power BI Workspace Collection with the specified properties.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @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 updateAsync(String resourceGroupName, String workspaceCollectionName, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, workspaceCollectionName), serviceCallback);
    }

    /**
     * Update an existing Power BI Workspace Collection with the specified properties.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionInner object
     */
    public Observable updateAsync(String resourceGroupName, String workspaceCollectionName) {
        return updateWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).map(new Func1, WorkspaceCollectionInner>() {
            @Override
            public WorkspaceCollectionInner call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Update an existing Power BI Workspace Collection with the specified properties.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionInner object
     */
    public Observable> updateWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        final Map tags = null;
        UpdateWorkspaceCollectionRequest body = new UpdateWorkspaceCollectionRequest();
        body.withTags(null);
        return service.update(this.client.subscriptionId(), resourceGroupName, workspaceCollectionName, this.client.apiVersion(), this.client.acceptLanguage(), body, this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = updateDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    /**
     * Update an existing Power BI Workspace Collection with the specified properties.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param tags the Map<String, String> value
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the WorkspaceCollectionInner object if successful.
     */
    public WorkspaceCollectionInner update(String resourceGroupName, String workspaceCollectionName, Map tags) {
        return updateWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, tags).toBlocking().single().body();
    }

    /**
     * Update an existing Power BI Workspace Collection with the specified properties.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param tags the Map<String, String> value
     * @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 updateAsync(String resourceGroupName, String workspaceCollectionName, Map tags, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, tags), serviceCallback);
    }

    /**
     * Update an existing Power BI Workspace Collection with the specified properties.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param tags the Map<String, String> value
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionInner object
     */
    public Observable updateAsync(String resourceGroupName, String workspaceCollectionName, Map tags) {
        return updateWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, tags).map(new Func1, WorkspaceCollectionInner>() {
            @Override
            public WorkspaceCollectionInner call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Update an existing Power BI Workspace Collection with the specified properties.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param tags the Map<String, String> value
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionInner object
     */
    public Observable> updateWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName, Map tags) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        Validator.validate(tags);
        UpdateWorkspaceCollectionRequest body = new UpdateWorkspaceCollectionRequest();
        body.withTags(tags);
        return service.update(this.client.subscriptionId(), resourceGroupName, workspaceCollectionName, this.client.apiVersion(), this.client.acceptLanguage(), body, this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = updateDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse updateDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Delete a Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     */
    public void delete(String resourceGroupName, String workspaceCollectionName) {
        deleteWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).toBlocking().last().body();
    }

    /**
     * Delete a Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @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 workspaceCollectionName, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, workspaceCollectionName), serviceCallback);
    }

    /**
     * Delete a Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable for the request
     */
    public Observable deleteAsync(String resourceGroupName, String workspaceCollectionName) {
        return deleteWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).map(new Func1, Void>() {
            @Override
            public Void call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Delete a Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable for the request
     */
    public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName 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, workspaceCollectionName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
        return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType());
    }

    /**
     * Delete a Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     */
    public void beginDelete(String resourceGroupName, String workspaceCollectionName) {
        beginDeleteWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).toBlocking().single().body();
    }

    /**
     * Delete a Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @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 workspaceCollectionName, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(beginDeleteWithServiceResponseAsync(resourceGroupName, workspaceCollectionName), serviceCallback);
    }

    /**
     * Delete a Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable beginDeleteAsync(String resourceGroupName, String workspaceCollectionName) {
        return beginDeleteWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).map(new Func1, Void>() {
            @Override
            public Void call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Delete a Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable> beginDeleteWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName 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, workspaceCollectionName, 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 ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
                .register(202, new TypeToken() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Verify the specified Power BI Workspace Collection name is valid and not already in use.
     *
     * @param location Azure location
     * @param body Check name availability request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the CheckNameResponseInner object if successful.
     */
    public CheckNameResponseInner checkNameAvailability(String location, CheckNameRequestInner body) {
        return checkNameAvailabilityWithServiceResponseAsync(location, body).toBlocking().single().body();
    }

    /**
     * Verify the specified Power BI Workspace Collection name is valid and not already in use.
     *
     * @param location Azure location
     * @param body Check name availability request
     * @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 checkNameAvailabilityAsync(String location, CheckNameRequestInner body, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(checkNameAvailabilityWithServiceResponseAsync(location, body), serviceCallback);
    }

    /**
     * Verify the specified Power BI Workspace Collection name is valid and not already in use.
     *
     * @param location Azure location
     * @param body Check name availability request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the CheckNameResponseInner object
     */
    public Observable checkNameAvailabilityAsync(String location, CheckNameRequestInner body) {
        return checkNameAvailabilityWithServiceResponseAsync(location, body).map(new Func1, CheckNameResponseInner>() {
            @Override
            public CheckNameResponseInner call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Verify the specified Power BI Workspace Collection name is valid and not already in use.
     *
     * @param location Azure location
     * @param body Check name availability request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the CheckNameResponseInner object
     */
    public Observable> checkNameAvailabilityWithServiceResponseAsync(String location, CheckNameRequestInner body) {
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (location == null) {
            throw new IllegalArgumentException("Parameter location 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 (body == null) {
            throw new IllegalArgumentException("Parameter body is required and cannot be null.");
        }
        Validator.validate(body);
        return service.checkNameAvailability(this.client.subscriptionId(), location, this.client.apiVersion(), body, this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = checkNameAvailabilityDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse checkNameAvailabilityDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Retrieves all existing Power BI workspace collections in the specified resource group.
     *
     * @param resourceGroupName Azure resource group
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException 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<WorkspaceCollectionInner> object if successful.
     */
    public List listByResourceGroup(String resourceGroupName) {
        return listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body();
    }

    /**
     * Retrieves all existing Power BI workspace collections in the specified resource group.
     *
     * @param resourceGroupName Azure resource group
     * @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> listByResourceGroupAsync(String resourceGroupName, final ServiceCallback> serviceCallback) {
        return ServiceFuture.fromResponse(listByResourceGroupWithServiceResponseAsync(resourceGroupName), serviceCallback);
    }

    /**
     * Retrieves all existing Power BI workspace collections in the specified resource group.
     *
     * @param resourceGroupName Azure resource group
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the List<WorkspaceCollectionInner> object
     */
    public Observable> listByResourceGroupAsync(String resourceGroupName) {
        return listByResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1>, List>() {
            @Override
            public List call(ServiceResponse> response) {
                return response.body();
            }
        });
    }

    /**
     * Retrieves all existing Power BI workspace collections in the specified resource group.
     *
     * @param resourceGroupName Azure resource group
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the List<WorkspaceCollectionInner> object
     */
    public Observable>> listByResourceGroupWithServiceResponseAsync(String resourceGroupName) {
        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 (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.listByResourceGroup(this.client.subscriptionId(), resourceGroupName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1, Observable>>>() {
                @Override
                public Observable>> call(Response response) {
                    try {
                        ServiceResponse> result = listByResourceGroupDelegate(response);
                        ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response());
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse> listByResourceGroupDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken>() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Retrieves all existing Power BI workspace collections in the specified subscription.
     *
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException 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<WorkspaceCollectionInner> object if successful.
     */
    public List listBySubscription() {
        return listBySubscriptionWithServiceResponseAsync().toBlocking().single().body();
    }

    /**
     * Retrieves all existing Power BI workspace collections in the specified subscription.
     *
     * @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> listBySubscriptionAsync(final ServiceCallback> serviceCallback) {
        return ServiceFuture.fromResponse(listBySubscriptionWithServiceResponseAsync(), serviceCallback);
    }

    /**
     * Retrieves all existing Power BI workspace collections in the specified subscription.
     *
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the List<WorkspaceCollectionInner> object
     */
    public Observable> listBySubscriptionAsync() {
        return listBySubscriptionWithServiceResponseAsync().map(new Func1>, List>() {
            @Override
            public List call(ServiceResponse> response) {
                return response.body();
            }
        });
    }

    /**
     * Retrieves all existing Power BI workspace collections in the specified subscription.
     *
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the List<WorkspaceCollectionInner> object
     */
    public Observable>> listBySubscriptionWithServiceResponseAsync() {
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() 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.listBySubscription(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1, Observable>>>() {
                @Override
                public Observable>> call(Response response) {
                    try {
                        ServiceResponse> result = listBySubscriptionDelegate(response);
                        ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response());
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse> listBySubscriptionDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory()., ErrorException>newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken>() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Retrieves the primary and secondary access keys for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the WorkspaceCollectionAccessKeysInner object if successful.
     */
    public WorkspaceCollectionAccessKeysInner getAccessKeys(String resourceGroupName, String workspaceCollectionName) {
        return getAccessKeysWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).toBlocking().single().body();
    }

    /**
     * Retrieves the primary and secondary access keys for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @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 getAccessKeysAsync(String resourceGroupName, String workspaceCollectionName, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(getAccessKeysWithServiceResponseAsync(resourceGroupName, workspaceCollectionName), serviceCallback);
    }

    /**
     * Retrieves the primary and secondary access keys for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionAccessKeysInner object
     */
    public Observable getAccessKeysAsync(String resourceGroupName, String workspaceCollectionName) {
        return getAccessKeysWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).map(new Func1, WorkspaceCollectionAccessKeysInner>() {
            @Override
            public WorkspaceCollectionAccessKeysInner call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Retrieves the primary and secondary access keys for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionAccessKeysInner object
     */
    public Observable> getAccessKeysWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName 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.getAccessKeys(this.client.subscriptionId(), resourceGroupName, workspaceCollectionName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = getAccessKeysDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse getAccessKeysDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Regenerates the primary or secondary access key for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the WorkspaceCollectionAccessKeysInner object if successful.
     */
    public WorkspaceCollectionAccessKeysInner regenerateKey(String resourceGroupName, String workspaceCollectionName) {
        return regenerateKeyWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).toBlocking().single().body();
    }

    /**
     * Regenerates the primary or secondary access key for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @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 regenerateKeyAsync(String resourceGroupName, String workspaceCollectionName, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(regenerateKeyWithServiceResponseAsync(resourceGroupName, workspaceCollectionName), serviceCallback);
    }

    /**
     * Regenerates the primary or secondary access key for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionAccessKeysInner object
     */
    public Observable regenerateKeyAsync(String resourceGroupName, String workspaceCollectionName) {
        return regenerateKeyWithServiceResponseAsync(resourceGroupName, workspaceCollectionName).map(new Func1, WorkspaceCollectionAccessKeysInner>() {
            @Override
            public WorkspaceCollectionAccessKeysInner call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Regenerates the primary or secondary access key for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionAccessKeysInner object
     */
    public Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        final AccessKeyName keyName = null;
        WorkspaceCollectionAccessKey body = new WorkspaceCollectionAccessKey();
        body.withKeyName(null);
        return service.regenerateKey(this.client.subscriptionId(), resourceGroupName, workspaceCollectionName, this.client.apiVersion(), this.client.acceptLanguage(), body, this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = regenerateKeyDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    /**
     * Regenerates the primary or secondary access key for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param keyName Key name. Possible values include: 'key1', 'key2'
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     * @return the WorkspaceCollectionAccessKeysInner object if successful.
     */
    public WorkspaceCollectionAccessKeysInner regenerateKey(String resourceGroupName, String workspaceCollectionName, AccessKeyName keyName) {
        return regenerateKeyWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, keyName).toBlocking().single().body();
    }

    /**
     * Regenerates the primary or secondary access key for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param keyName Key name. Possible values include: 'key1', 'key2'
     * @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 regenerateKeyAsync(String resourceGroupName, String workspaceCollectionName, AccessKeyName keyName, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(regenerateKeyWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, keyName), serviceCallback);
    }

    /**
     * Regenerates the primary or secondary access key for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param keyName Key name. Possible values include: 'key1', 'key2'
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionAccessKeysInner object
     */
    public Observable regenerateKeyAsync(String resourceGroupName, String workspaceCollectionName, AccessKeyName keyName) {
        return regenerateKeyWithServiceResponseAsync(resourceGroupName, workspaceCollectionName, keyName).map(new Func1, WorkspaceCollectionAccessKeysInner>() {
            @Override
            public WorkspaceCollectionAccessKeysInner call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Regenerates the primary or secondary access key for the specified Power BI Workspace Collection.
     *
     * @param resourceGroupName Azure resource group
     * @param workspaceCollectionName Power BI Embedded Workspace Collection name
     * @param keyName Key name. Possible values include: 'key1', 'key2'
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable to the WorkspaceCollectionAccessKeysInner object
     */
    public Observable> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String workspaceCollectionName, AccessKeyName keyName) {
        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 (workspaceCollectionName == null) {
            throw new IllegalArgumentException("Parameter workspaceCollectionName is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        WorkspaceCollectionAccessKey body = new WorkspaceCollectionAccessKey();
        body.withKeyName(keyName);
        return service.regenerateKey(this.client.subscriptionId(), resourceGroupName, workspaceCollectionName, this.client.apiVersion(), this.client.acceptLanguage(), body, this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = regenerateKeyDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse regenerateKeyDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

    /**
     * Migrates an existing Power BI Workspace Collection to a different resource group and/or subscription.
     *
     * @param resourceGroupName Azure resource group
     * @param body Workspace migration request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @throws ErrorException thrown if the request is rejected by server
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
     */
    public void migrate(String resourceGroupName, MigrateWorkspaceCollectionRequestInner body) {
        migrateWithServiceResponseAsync(resourceGroupName, body).toBlocking().single().body();
    }

    /**
     * Migrates an existing Power BI Workspace Collection to a different resource group and/or subscription.
     *
     * @param resourceGroupName Azure resource group
     * @param body Workspace migration request
     * @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 migrateAsync(String resourceGroupName, MigrateWorkspaceCollectionRequestInner body, final ServiceCallback serviceCallback) {
        return ServiceFuture.fromResponse(migrateWithServiceResponseAsync(resourceGroupName, body), serviceCallback);
    }

    /**
     * Migrates an existing Power BI Workspace Collection to a different resource group and/or subscription.
     *
     * @param resourceGroupName Azure resource group
     * @param body Workspace migration request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable migrateAsync(String resourceGroupName, MigrateWorkspaceCollectionRequestInner body) {
        return migrateWithServiceResponseAsync(resourceGroupName, body).map(new Func1, Void>() {
            @Override
            public Void call(ServiceResponse response) {
                return response.body();
            }
        });
    }

    /**
     * Migrates an existing Power BI Workspace Collection to a different resource group and/or subscription.
     *
     * @param resourceGroupName Azure resource group
     * @param body Workspace migration request
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
    public Observable> migrateWithServiceResponseAsync(String resourceGroupName, MigrateWorkspaceCollectionRequestInner body) {
        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 (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        if (body == null) {
            throw new IllegalArgumentException("Parameter body is required and cannot be null.");
        }
        Validator.validate(body);
        return service.migrate(this.client.subscriptionId(), resourceGroupName, this.client.apiVersion(), body, this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1, Observable>>() {
                @Override
                public Observable> call(Response response) {
                    try {
                        ServiceResponse clientResponse = migrateDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }

    private ServiceResponse migrateDelegate(Response response) throws ErrorException, IOException, IllegalArgumentException {
        return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter())
                .register(200, new TypeToken() { }.getType())
                .registerError(ErrorException.class)
                .build(response);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy