Search in sources :

Example 1 with DatabaseAccountRegenerateKeyParameters

use of com.microsoft.azure.management.documentdb.DatabaseAccountRegenerateKeyParameters in project azure-sdk-for-java by Azure.

the class DatabaseAccountsInner method regenerateKeyWithServiceResponseAsync.

/**
     * Regenerates an access key for the specified Azure DocumentDB database account.
     *
     * @param resourceGroupName Name of an Azure resource group.
     * @param accountName DocumentDB database account name.
     * @param keyKind The access key to regenerate. Possible values include: 'primary', 'secondary', 'primaryReadonly', 'secondaryReadonly'
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the observable for the request
     */
public Observable<ServiceResponse<Void>> regenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, KeyKind keyKind) {
    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 (accountName == null) {
        throw new IllegalArgumentException("Parameter accountName 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 (keyKind == null) {
        throw new IllegalArgumentException("Parameter keyKind is required and cannot be null.");
    }
    DatabaseAccountRegenerateKeyParameters keyToRegenerate = new DatabaseAccountRegenerateKeyParameters();
    keyToRegenerate.withKeyKind(keyKind);
    Observable<Response<ResponseBody>> observable = service.regenerateKey(this.client.subscriptionId(), resourceGroupName, accountName, this.client.apiVersion(), this.client.acceptLanguage(), keyToRegenerate, this.client.userAgent());
    return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() {
    }.getType());
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) DatabaseAccountRegenerateKeyParameters(com.microsoft.azure.management.documentdb.DatabaseAccountRegenerateKeyParameters) TypeToken(com.google.common.reflect.TypeToken)

Example 2 with DatabaseAccountRegenerateKeyParameters

use of com.microsoft.azure.management.documentdb.DatabaseAccountRegenerateKeyParameters in project azure-sdk-for-java by Azure.

the class DatabaseAccountsInner method beginRegenerateKeyWithServiceResponseAsync.

/**
     * Regenerates an access key for the specified Azure DocumentDB database account.
     *
     * @param resourceGroupName Name of an Azure resource group.
     * @param accountName DocumentDB database account name.
     * @param keyKind The access key to regenerate. Possible values include: 'primary', 'secondary', 'primaryReadonly', 'secondaryReadonly'
     * @throws IllegalArgumentException thrown if parameters fail the validation
     * @return the {@link ServiceResponse} object if successful.
     */
public Observable<ServiceResponse<Void>> beginRegenerateKeyWithServiceResponseAsync(String resourceGroupName, String accountName, KeyKind keyKind) {
    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 (accountName == null) {
        throw new IllegalArgumentException("Parameter accountName 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 (keyKind == null) {
        throw new IllegalArgumentException("Parameter keyKind is required and cannot be null.");
    }
    DatabaseAccountRegenerateKeyParameters keyToRegenerate = new DatabaseAccountRegenerateKeyParameters();
    keyToRegenerate.withKeyKind(keyKind);
    return service.beginRegenerateKey(this.client.subscriptionId(), resourceGroupName, accountName, this.client.apiVersion(), this.client.acceptLanguage(), keyToRegenerate, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {

        @Override
        public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<Void> clientResponse = beginRegenerateKeyDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) DatabaseAccountRegenerateKeyParameters(com.microsoft.azure.management.documentdb.DatabaseAccountRegenerateKeyParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

DatabaseAccountRegenerateKeyParameters (com.microsoft.azure.management.documentdb.DatabaseAccountRegenerateKeyParameters)2 ServiceResponse (com.microsoft.rest.ServiceResponse)2 Response (retrofit2.Response)2 TypeToken (com.google.common.reflect.TypeToken)1 ResponseBody (okhttp3.ResponseBody)1 Observable (rx.Observable)1