com.microsoft.azure.management.resources.implementation.PolicyAssignmentsImpl Maven / Gradle / Ivy
/**
* 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.PolicyAssignment;
import com.microsoft.azure.management.resources.PolicyAssignments;
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.CreatableWrappersImpl;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import rx.Completable;
import rx.Observable;
import rx.functions.Func1;
/**
* The implementation for {@link ResourceGroups} and its parent interfaces.
*/
final class PolicyAssignmentsImpl
extends CreatableWrappersImpl
implements PolicyAssignments {
private final PolicyAssignmentsInner client;
/**
* Creates an instance of the implementation.
*
* @param innerClient the inner policies client
*/
PolicyAssignmentsImpl(final PolicyAssignmentsInner innerClient) {
this.client = innerClient;
}
@Override
public PagedList list() {
return wrapList(client.list());
}
@Override
public Completable deleteByIdAsync(String id) {
return client.deleteByIdAsync(id).toCompletable();
}
@Override
public PolicyAssignmentImpl define(String name) {
return wrapModel(name);
}
@Override
protected PolicyAssignmentImpl wrapModel(String name) {
return new PolicyAssignmentImpl(name,
new PolicyAssignmentInner().withDisplayName(name),
client);
}
@Override
protected PolicyAssignmentImpl wrapModel(PolicyAssignmentInner inner) {
if (inner == null) {
return null;
}
return new PolicyAssignmentImpl(inner.name(), inner, client);
}
@Override
public PagedList listByResource(String resourceId) {
return wrapList(client.listForResource(
ResourceUtils.groupFromResourceId(resourceId),
ResourceUtils.resourceProviderFromResourceId(resourceId),
ResourceUtils.relativePathFromResourceId(ResourceUtils.parentResourceIdFromResourceId(resourceId)),
ResourceUtils.resourceTypeFromResourceId(resourceId),
ResourceUtils.nameFromResourceId(resourceId)
));
}
@Override
public PolicyAssignment getById(String id) {
return getByIdAsync(id).toBlocking().last();
}
@Override
public Observable getByIdAsync(String id) {
return client.getByIdAsync(id).map(new Func1() {
@Override
public PolicyAssignment call(PolicyAssignmentInner policyAssignmentInner) {
return wrapModel(policyAssignmentInner);
}
});
}
@Override
public ServiceFuture getByIdAsync(String id, ServiceCallback callback) {
return ServiceFuture.fromBody(getByIdAsync(id), callback);
}
@Override
public PagedList listByResourceGroup(String resourceGroupName) {
return wrapList(client.listByResourceGroup(resourceGroupName));
}
@Override
public Observable listAsync() {
return wrapPageAsync(this.client.listAsync());
}
@Override
public Observable listByResourceGroupAsync(String resourceGroupName) {
return wrapPageAsync(this.client.listByResourceGroupAsync(resourceGroupName));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy