diff --git a/src/main/java/gyro/azure/storage/StorageAccountResource.java b/src/main/java/gyro/azure/storage/StorageAccountResource.java index 6eebb73b..4fbe61af 100644 --- a/src/main/java/gyro/azure/storage/StorageAccountResource.java +++ b/src/main/java/gyro/azure/storage/StorageAccountResource.java @@ -101,6 +101,7 @@ public class StorageAccountResource extends AzureResource implements Copyable tags; private StorageLifeCycle lifecycle; private Boolean upgradeAccountV2; + private Boolean blobPublicAccess; /** * The cors rules associated with the Storage Account. @@ -203,6 +204,18 @@ public void setUpgradeAccountV2(Boolean upgradeAccountV2) { this.upgradeAccountV2 = upgradeAccountV2; } + /** + * When set to ``true``, allows blob public access, configured by individual containers. + */ + @Updatable + public Boolean getBlobPublicAccess() { + return blobPublicAccess; + } + + public void setBlobPublicAccess(Boolean blobPublicAccess) { + this.blobPublicAccess = blobPublicAccess; + } + @Override public void copyFrom(StorageAccount storageAccount) { setId(storageAccount.id()); @@ -211,6 +224,7 @@ public void copyFrom(StorageAccount storageAccount) { setResourceGroup(findById(ResourceGroupResource.class, storageAccount.resourceGroupName())); setId(storageAccount.id()); setUpgradeAccountV2(storageAccount.kind().equals(Kind.STORAGE_V2)); + setBlobPublicAccess(storageAccount.isBlobPublicAccessAllowed()); getTags().clear(); storageAccount.tags().forEach((key, value) -> getTags().put(key, value)); @@ -250,6 +264,16 @@ public void create(GyroUI ui, State state) throws URISyntaxException, InvalidKey setId(storageAccount.id()); + StorageAccount.Update update = storageAccount.update(); + + if (Boolean.TRUE.equals(getBlobPublicAccess())) { + update = update.enableBlobPublicAccess(); + } else if (Boolean.FALSE.equals(getBlobPublicAccess())) { + update = update.disableBlobPublicAccess(); + } + + update.apply(); + // TODO lifecycle and cors } @@ -271,6 +295,14 @@ public void update(GyroUI ui, State state, Resource current, Set changed } } + if (changedFieldNames.contains("blob-public-access")) { + if (Boolean.TRUE.equals(getBlobPublicAccess())) { + update = update.enableBlobPublicAccess(); + } else { + update = update.disableBlobPublicAccess(); + } + } + update.apply(); }