Skip to content

Commit

Permalink
renaming StorageAccount#refreshKeys() as getKeys() and removing keys(…
Browse files Browse the repository at this point in the history
…) and the caching logic altogether as it seems redundant from the user scenario perspective
  • Loading branch information
unknown authored and unknown committed Sep 21, 2016
1 parent c4ae77e commit 42395de
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package com.microsoft.azure.management.storage;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.apigeneration.LangMethodDefinition;
import com.microsoft.azure.management.apigeneration.LangMethodDefinition.LangMethodType;
import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource;
Expand All @@ -25,7 +25,7 @@
/**
* An immutable client-side representation of an Azure storage account.
*/
@LangDefinition
@Fluent
public interface StorageAccount extends
GroupableResource,
Refreshable<StorageAccount>,
Expand Down Expand Up @@ -98,19 +98,13 @@ public interface StorageAccount extends
*/
AccessTier accessTier();

/**
* @return the access keys for this storage account
*/
@LangMethodDefinition(AsType = LangMethodType.Method)
List<StorageAccountKey> keys();

/**
* Fetch the up-to-date access keys from Azure for this storage account.
*
* @return the access keys for this storage account
*/
@LangMethodDefinition(AsType = LangMethodType.Method)
List<StorageAccountKey> refreshKeys();
List<StorageAccountKey> getKeys();

/**
* Regenerates the access keys for this storage account.
Expand All @@ -121,14 +115,9 @@ public interface StorageAccount extends
@LangMethodDefinition(AsType = LangMethodType.Method)
List<StorageAccountKey> regenerateKey(String keyName);

/**************************************************************
* Fluent interfaces to provision a StorageAccount
**************************************************************/

/**
* Container interface for all the definitions that need to be implemented.
*/
@LangDefinition(ContainerName = "~/StorageAccount.Definition", ContainerFileName = "IDefinition")
interface Definition extends
DefinitionStages.Blank,
DefinitionStages.WithGroup,
Expand All @@ -139,7 +128,6 @@ interface Definition extends
/**
* Grouping of all the storage account definition stages.
*/
@LangDefinition(ContainerName = "~/StorageAccount.Definition", ContainerFileName = "IDefinition", IsContainerOnly = true)
interface DefinitionStages {
/**
* The first stage of the storage account definition.
Expand Down Expand Up @@ -273,7 +261,6 @@ interface WithCreateAndAccessTier extends DefinitionStages.WithCreate {
/**
* Grouping of all the storage account update stages.
*/
@LangDefinition(ContainerName = "~/StorageAccount.Update", ContainerFileName = "IUpdate", IsContainerOnly = true)
interface UpdateStages {
/**
* A storage account update stage allowing to change the parameters.
Expand Down Expand Up @@ -361,7 +348,6 @@ interface WithAccessTier {
/**
* The template for a storage account update operation, containing all the settings that can be modified.
*/
@LangDefinition(ContainerName = "~/StorageAccount.Update", ContainerFileName = "IUpdate")
interface Update extends
Appliable<StorageAccount>,
UpdateStages.WithSku,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package com.microsoft.azure.management.storage;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup;
import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById;
Expand All @@ -19,7 +19,7 @@
/**
* Entry point for storage accounts management API.
*/
@LangDefinition(ContainerName = "~/")
@Fluent
public interface StorageAccounts extends
SupportsListing<StorageAccount>,
SupportsCreating<StorageAccount.DefinitionStages.Blank>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

package com.microsoft.azure.management.storage;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.resources.fluentcore.model.Wrapper;
import com.microsoft.azure.management.storage.implementation.UsageInner;

/**
* An immutable client-side representation of an Azure storage resource usage info object.
*/
@LangDefinition(ContainerName = "~/")
@Fluent
public interface StorageUsage extends Wrapper<UsageInner> {
/**
* @return the unit of measurement. Possible values include: 'Count',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

package com.microsoft.azure.management.storage;

import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing;

/**
* Entry point for storage resource usage management API.
*/
@LangDefinition(ContainerName = "~/")
@Fluent
public interface Usages extends SupportsListing<StorageUsage> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class StorageAccountImpl

private PublicEndpoints publicEndpoints;
private AccountStatuses accountStatuses;
private List<StorageAccountKey> cachedAccountKeys;
private StorageAccountCreateParametersInner createParameters;
private StorageAccountUpdateParametersInner updateParameters;

Expand Down Expand Up @@ -112,27 +111,17 @@ public AccessTier accessTier() {
}

@Override
public List<StorageAccountKey> keys() {
if (cachedAccountKeys == null) {
cachedAccountKeys = refreshKeys();
}
return cachedAccountKeys;
}

@Override
public List<StorageAccountKey> refreshKeys() {
public List<StorageAccountKey> getKeys() {
StorageAccountListKeysResultInner response =
this.client.listKeys(this.resourceGroupName(), this.name());
cachedAccountKeys = response.keys();
return cachedAccountKeys;
return response.keys();
}

@Override
public List<StorageAccountKey> regenerateKey(String keyName) {
StorageAccountListKeysResultInner response =
this.client.regenerateKey(this.resourceGroupName(), this.name(), keyName);
cachedAccountKeys = response.keys();
return cachedAccountKeys;
return response.keys();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void canCRUDStorageAccount() throws Exception {
Assert.assertNotNull(storageAccount);

// Get Keys
List<StorageAccountKey> keys = storageAccount.keys();
List<StorageAccountKey> keys = storageAccount.getKeys();
Assert.assertTrue(keys.size() > 0);

// Regen key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void main(String[] args) {

System.out.println("Getting storage account access keys");

List<StorageAccountKey> storageAccountKeys = storageAccount.keys();
List<StorageAccountKey> storageAccountKeys = storageAccount.getKeys();

Utils.print(storageAccountKeys);

Expand Down

0 comments on commit 42395de

Please sign in to comment.