com.microsoft.azure.management.resources.implementation.ResourceGroupsImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-mgmt-resources Show documentation
Show all versions of azure-mgmt-resources Show documentation
This package contains Microsoft Azure Resource Management SDK.
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.management.resources.implementation;
import com.microsoft.azure.PagedList;
import com.microsoft.azure.management.resources.ResourceGroup;
import com.microsoft.azure.management.resources.ResourceGroups;
import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.CreatableResourcesImpl;
import com.microsoft.azure.management.resources.fluentcore.utils.Utils;
import com.microsoft.rest.ServiceFuture;
import com.microsoft.rest.ServiceCallback;
import rx.Completable;
import rx.Observable;
/**
* The implementation for ResourceGroups.
*/
final class ResourceGroupsImpl
extends CreatableResourcesImpl
implements ResourceGroups {
private final ResourceGroupsInner client;
private final ResourceManagementClientImpl serviceClient;
/**
* Creates an instance of the implementation.
*
* @param serviceClient the inner resource management client
*/
ResourceGroupsImpl(final ResourceManagementClientImpl serviceClient) {
this.serviceClient = serviceClient;
this.client = serviceClient.resourceGroups();
}
@Override
public PagedList list() {
return wrapList(client.list());
}
@Override
public PagedList listByTag(String tagName, String tagValue) {
return wrapList(client.list(Utils.createOdataFilterForTags(tagName, tagValue), null));
}
@Override
public Observable listByTagAsync(String tagName, String tagValue) {
return wrapPageAsync(client.listAsync(Utils.createOdataFilterForTags(tagName, tagValue), null));
}
@Override
public ResourceGroupImpl getByName(String name) {
return wrapModel(client.get(name));
}
@Override
public void deleteByName(String name) {
deleteByNameAsync(name).await();
}
@Override
public ServiceFuture deleteByNameAsync(String name, ServiceCallback callback) {
return ServiceFuture.fromResponse(client.deleteWithServiceResponseAsync(name), callback);
}
@Override
public Completable deleteByNameAsync(String name) {
return client.deleteAsync(name).toCompletable();
}
@Override
public ResourceGroupImpl define(String name) {
return wrapModel(name);
}
@Override
public boolean checkExistence(String name) {
return this.contain(name);
}
@Override
public boolean contain(String name) {
return client.checkExistence(name);
}
@Override
protected ResourceGroupImpl wrapModel(String name) {
return new ResourceGroupImpl(new ResourceGroupInner(), name, serviceClient);
}
@Override
protected ResourceGroupImpl wrapModel(ResourceGroupInner inner) {
if (inner == null) {
return null;
}
return new ResourceGroupImpl(inner, inner.name(), serviceClient);
}
@Override
public void beginDeleteByName(String id) {
beginDeleteByNameAsync(id).toBlocking().subscribe();
}
@Override
public ServiceFuture beginDeleteByNameAsync(String name, ServiceCallback callback) {
return ServiceFuture.fromBody(beginDeleteByNameAsync(name), callback);
}
@Override
public Observable beginDeleteByNameAsync(String name) {
return client.beginDeleteAsync(name);
}
@Override
public Completable deleteByIdAsync(String id) {
return deleteByNameAsync(ResourceUtils.nameFromResourceId(id));
}
@Override
public Observable listAsync() {
return wrapPageAsync(this.client.listAsync());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy