com.microsoft.azure.management.graphrbac.implementation.ActiveDirectoryApplicationImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-mgmt-graph-rbac Show documentation
Show all versions of azure-mgmt-graph-rbac Show documentation
This package contains Microsoft Azure Graph RBAC Management SDK. This package has been deprecated. A replacement package com.azure.resourcemanager:azure-resourcemanager-authorization is available as of 31-March-2022. We strongly encourage you to upgrade to continue receiving updates. See Migration Guide https://aka.ms/java-track2-migration-guide for guidance on upgrading. Refer to our deprecation policy https://azure.github.io/azure-sdk/policies_support.html for more details.
/**
* 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.graphrbac.implementation;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.graphrbac.ActiveDirectoryApplication;
import com.microsoft.azure.management.graphrbac.CertificateCredential;
import com.microsoft.azure.management.graphrbac.PasswordCredential;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl;
import rx.Observable;
import rx.functions.Func1;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Implementation for ServicePrincipal and its parent interfaces.
*/
@LangDefinition(ContainerName = "/Microsoft.Azure.Management.Graph.RBAC.Fluent")
class ActiveDirectoryApplicationImpl
extends CreatableUpdatableImpl
implements
ActiveDirectoryApplication,
ActiveDirectoryApplication.Definition,
ActiveDirectoryApplication.Update,
HasCredential {
private GraphRbacManager manager;
private ApplicationCreateParametersInner createParameters;
private ApplicationUpdateParametersInner updateParameters;
private Map cachedPasswordCredentials;
private Map cachedCertificateCredentials;
ActiveDirectoryApplicationImpl(ApplicationInner innerObject, GraphRbacManager manager) {
super(innerObject.displayName(), innerObject);
this.manager = manager;
this.createParameters = new ApplicationCreateParametersInner().withDisplayName(innerObject.displayName());
this.updateParameters = new ApplicationUpdateParametersInner().withDisplayName(innerObject.displayName());
}
@Override
public boolean isInCreateMode() {
return id() == null;
}
@Override
public Observable createResourceAsync() {
if (createParameters.identifierUris() == null) {
createParameters.withIdentifierUris(new ArrayList());
createParameters.identifierUris().add(createParameters.homepage());
}
return manager.inner().applications().createAsync(createParameters)
.map(innerToFluentMap(this))
.flatMap(new Func1>() {
@Override
public Observable call(ActiveDirectoryApplication application) {
return refreshCredentialsAsync();
}
});
}
@Override
public Observable updateResourceAsync() {
return manager.inner().applications().patchAsync(id(), updateParameters)
.flatMap(new Func1>() {
@Override
public Observable call(Void aVoid) {
return refreshAsync();
}
});
}
Observable refreshCredentialsAsync() {
final Observable keyCredentials = manager.inner().applications().listKeyCredentialsAsync(id())
.flatMapIterable(new Func1, Iterable>() {
@Override
public Iterable call(List keyCredentialInners) {
return keyCredentialInners;
}
})
.map(new Func1() {
@Override
public CertificateCredential call(KeyCredentialInner keyCredentialInner) {
return new CertificateCredentialImpl(keyCredentialInner);
}
})
.toMap(new Func1() {
@Override
public String call(CertificateCredential certificateCredential) {
return certificateCredential.name();
}
}).map(new Func1