Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support getting by name & version for keys and secrets #645

Merged
merged 1 commit into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.microsoft.azure.management.apigeneration.Beta.SinceVersion;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByNameAsync;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing;
Expand All @@ -24,7 +25,24 @@ public interface Keys extends
SupportsCreating<Key.DefinitionStages.Blank>,
SupportsDeletingById,
SupportsGettingById<Key>,
SupportsGettingByNameAsync<Key>,
SupportsListing<Key> {
/**
* Gets a Key Vault key.
* @param name the name of the key
* @param version the version of the key
* @return the key
*/
Key getByNameAndVersion(String name, String version);

/**
* Gets a Key Vault key.
* @param name the name of the key
* @param version the version of the key
* @return the key
*/
Observable<Key> getByNameAndVersionAsync(String name, String version);

/**
* Restores a backup key into a Key Vault key.
* @param backup the backup key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import com.microsoft.azure.management.apigeneration.Beta.SinceVersion;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByNameAsync;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeletingById;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing;
import rx.Observable;

/**
* Entry point for Key Vault secrets API.
Expand All @@ -23,5 +25,21 @@ public interface Secrets extends
SupportsCreating<Secret.DefinitionStages.Blank>,
SupportsDeletingById,
SupportsGettingById<Secret>,
SupportsGettingByNameAsync<Secret>,
SupportsListing<Secret> {
/**
* Gets a Key Vault secret.
* @param name the name of the secret
* @param version the version of the secret
* @return the secret
*/
Secret getByNameAndVersion(String name, String version);

/**
* Gets a Key Vault secret.
* @param name the name of the secret
* @param version the version of the secret
* @return the secret
*/
Observable<Secret> getByNameAndVersionAsync(String name, String version);
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@ protected Observable<Key> typeConvertAsync(KeyItem keyItem) {
}.toObservable();
}

@Override
public Key getByNameAndVersion(String name, String version) {
return wrapModel(inner.getKey(vault.vaultUri(), name, version));
}

@Override
public Observable<Key> getByNameAndVersionAsync(final String name, final String version) {
return new KeyVaultFutures.ServiceFutureConverter<KeyBundle, Key>() {

@Override
ServiceFuture<KeyBundle> callAsync() {
return inner.getKeyAsync(vault.vaultUri(), name, version, null);
}

@Override
Key wrapModel(KeyBundle keyBundle) {
return KeysImpl.this.wrapModel(keyBundle);
}
}.toObservable();
}

@Override
public Key restore(byte[] backup) {
return wrapModel(vault.client().restoreKey(vault.vaultUri(), backup));
Expand All @@ -155,4 +176,25 @@ protected Key wrapModel(KeyBundle keyBundle) {
}
}.toObservable();
}

@Override
public Observable<Key> getByNameAsync(final String name) {
return new KeyVaultFutures.ServiceFutureConverter<KeyBundle, Key>() {

@Override
ServiceFuture<KeyBundle> callAsync() {
return inner.getKeyAsync(vault.vaultUri(), name, null);
}

@Override
Key wrapModel(KeyBundle keyBundle) {
return KeysImpl.this.wrapModel(keyBundle);
}
}.toObservable();
}

@Override
public Key getByName(String name) {
return wrapModel(inner.getKey(vault.vaultUri(), name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,46 @@ protected Observable<Secret> typeConvertAsync(SecretItem secretItem) {
}
}.toObservable();
}

@Override
public Observable<Secret> getByNameAsync(final String name) {
return new KeyVaultFutures.ServiceFutureConverter<SecretBundle, Secret>() {

@Override
ServiceFuture<SecretBundle> callAsync() {
return inner.getSecretAsync(vault.vaultUri(), name, null);
}

@Override
Secret wrapModel(SecretBundle o) {
return null;
}
}.toObservable();
}

@Override
public Secret getByName(String name) {
return wrapModel(inner.getSecret(vault.vaultUri(), name));
}

@Override
public Secret getByNameAndVersion(String name, String version) {
return wrapModel(inner.getSecret(vault.vaultUri(), name, version));
}

@Override
public Observable<Secret> getByNameAndVersionAsync(final String name, final String version) {
return new KeyVaultFutures.ServiceFutureConverter<SecretBundle, Secret>() {

@Override
ServiceFuture<SecretBundle> callAsync() {
return inner.getSecretAsync(vault.vaultUri(), name, version, null);
}

@Override
Secret wrapModel(SecretBundle o) {
return null;
}
}.toObservable();
}
}