in Utils/azure-toolkit-ide-libs/azure-toolkit-ide-keyvault-lib/src/main/java/com/microsoft/azure/toolkit/ide/keyvault/KeyVaultActionsContributor.java [45:128]
public void registerActions(AzureActionManager am) {
new Action<>(ENABLE_CREDENTIAL)
.withLabel("Enable")
.withIdParam(AzResource::getResourceTypeName)
.withIdParam(AzResource::getName)
.enableWhen(s -> BooleanUtils.isFalse(s.isEnabled()))
.withHandler((s, r) -> {
OperationContext.action().setTelemetryProperty("resourceType", s.getResourceTypeName());
s.enable();
})
.register(am);
new Action<>(ENABLE_CREDENTIAL_VERSION)
.withLabel("Enable")
.withIdParam(r -> r.getCredential().getResourceTypeName())
.withIdParam(AzResource::getName)
.withIdParam(version -> version.getCredential().getName())
.enableWhen(s -> BooleanUtils.isFalse(s.isEnabled()))
.withHandler((s, r) -> {
OperationContext.action().setTelemetryProperty("resourceType", s.getResourceTypeName());
s.enable();
})
.register(am);
new Action<>(DISABLE_CREDENTIAL)
.withLabel("Disable")
.withIdParam(AzResource::getResourceTypeName)
.withIdParam(AzResource::getName)
.enableWhen(s -> BooleanUtils.isTrue(s.isEnabled()))
.withHandler((s, r) -> {
OperationContext.action().setTelemetryProperty("resourceType", s.getResourceTypeName());
s.disable();
})
.register(am);
new Action<>(DISABLE_CREDENTIAL_VERSION)
.withLabel("Disable")
.withIdParam(r -> r.getCredential().getResourceTypeName())
.withIdParam(AzResource::getName)
.withIdParam(version -> version.getCredential().getName())
.enableWhen(s -> BooleanUtils.isTrue(s.isEnabled()))
.withHandler((s, r) -> {
OperationContext.action().setTelemetryProperty("resourceType", s.getResourceTypeName());
s.disable();
})
.register(am);
new Action<>(DOWNLOAD_CREDENTIAL)
.withLabel("Download")
.withIdParam(AzResource::getResourceTypeName)
.withIdParam(AzResource::getName)
.withHandler((s, r) -> Optional.ofNullable(s.getCurrentVersion())
.ifPresent(version -> am.getAction(DOWNLOAD_CREDENTIAL_VERSION).handle(version, r)))
.register(am);
new Action<>(DOWNLOAD_CREDENTIAL_VERSION)
.withLabel("Download")
.withIdParam(r -> r.getCredential().getResourceTypeName())
.withIdParam(AzResource::getName)
.withIdParam(version -> version.getCredential().getName())
.register(am);
new Action<>(SHOW_CREDENTIAL)
.withLabel("Show")
.withIdParam(AzResource::getResourceTypeName)
.withIdParam(AzResource::getName)
.withHandler((s, r) -> Optional.ofNullable(s.getCurrentVersion())
.ifPresent(version -> am.getAction(SHOW_CREDENTIAL_VERSION).handle(version, r)))
.register(am);
new Action<>(SHOW_CREDENTIAL_VERSION)
.withLabel("Show")
.withIdParam(r -> r.getCredential().getResourceTypeName())
.withIdParam(AzResource::getName)
.withIdParam(version -> version.getCredential().getName())
.register(am);
new Action<>(GROUP_CREATE_KEY_VAULT)
.withLabel("Key Vault")
.withIdParam(AzResource::getName)
.visibleWhen(s -> s instanceof ResourceGroup)
.enableWhen(s -> s.getFormalStatus().isConnected())
.register(am);
}