diff --git a/sdk/resourcemanager/azure-resourcemanager-storage/CHANGELOG.md b/sdk/resourcemanager/azure-resourcemanager-storage/CHANGELOG.md index de358256274a6..153ab3c856f56 100644 --- a/sdk/resourcemanager/azure-resourcemanager-storage/CHANGELOG.md +++ b/sdk/resourcemanager/azure-resourcemanager-storage/CHANGELOG.md @@ -4,11 +4,7 @@ ### Features Added -### Breaking Changes - -### Bugs Fixed - -### Other Changes +- Supported `allowCrossTenantReplication` and `defaultToOAuthAuthentication` for `StorageAccount` in create and update. ## 2.32.0 (2023-10-27) diff --git a/sdk/resourcemanager/azure-resourcemanager-storage/assets.json b/sdk/resourcemanager/azure-resourcemanager-storage/assets.json index 6b344bf5461b7..c143ad7776f7b 100644 --- a/sdk/resourcemanager/azure-resourcemanager-storage/assets.json +++ b/sdk/resourcemanager/azure-resourcemanager-storage/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/resourcemanager/azure-resourcemanager-storage", - "Tag": "java/resourcemanager/azure-resourcemanager-storage_d0dd902bd0" + "Tag": "java/resourcemanager/azure-resourcemanager-storage_5816c875b5" } diff --git a/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/implementation/StorageAccountImpl.java b/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/implementation/StorageAccountImpl.java index 02d4b8d5cfd04..de56b4a1bf2f9 100644 --- a/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/implementation/StorageAccountImpl.java +++ b/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/implementation/StorageAccountImpl.java @@ -240,6 +240,19 @@ public boolean isSharedKeyAccessAllowed() { return this.innerModel().allowSharedKeyAccess(); } + @Override + public boolean isAllowCrossTenantReplication() { + if (this.innerModel().allowCrossTenantReplication() == null) { + return true; + } + return this.innerModel().allowCrossTenantReplication(); + } + + @Override + public boolean isDefaultToOAuthAuthentication() { + return ResourceManagerUtils.toPrimitiveBoolean(this.innerModel().defaultToOAuthAuthentication()); + } + @Override public List getKeys() { return this.getKeysAsync().block(); @@ -565,6 +578,46 @@ public StorageAccountImpl disableSharedKeyAccess() { return this; } + @Override + public StorageAccountImpl allowCrossTenantReplication() { + if (isInCreateMode()) { + createParameters.withAllowCrossTenantReplication(true); + } else { + updateParameters.withAllowCrossTenantReplication(true); + } + return this; + } + + @Override + public StorageAccountImpl disallowCrossTenantReplication() { + if (isInCreateMode()) { + createParameters.withAllowCrossTenantReplication(false); + } else { + updateParameters.withAllowCrossTenantReplication(false); + } + return this; + } + + @Override + public StorageAccountImpl enableDefaultToOAuthAuthentication() { + if (isInCreateMode()) { + createParameters.withDefaultToOAuthAuthentication(true); + } else { + updateParameters.withDefaultToOAuthAuthentication(true); + } + return this; + } + + @Override + public StorageAccountImpl disableDefaultToOAuthAuthentication() { + if (isInCreateMode()) { + createParameters.withDefaultToOAuthAuthentication(false); + } else { + updateParameters.withDefaultToOAuthAuthentication(false); + } + return this; + } + @Override public StorageAccountImpl withAccessFromAllNetworks() { this.networkRulesHelper.withAccessFromAllNetworks(); diff --git a/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/models/StorageAccount.java b/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/models/StorageAccount.java index ce4f0179921bb..329c9f7e8e52b 100644 --- a/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/models/StorageAccount.java +++ b/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/models/StorageAccount.java @@ -206,6 +206,20 @@ public interface StorageAccount */ Mono> regenerateKeyAsync(String keyName); + /** + * Checks whether cross tenant replication is allowed. + * + * @return true if cross tenant replication is enabled, false otherwise + */ + boolean isAllowCrossTenantReplication(); + + /** + * Checks whether default to oauth authentication is allowed. + * + * @return true if default to oauth authentication is enabled, false otherwise + */ + boolean isDefaultToOAuthAuthentication(); + /** Container interface for all the definitions that need to be implemented. */ interface Definition extends DefinitionStages.Blank, @@ -547,6 +561,29 @@ interface WithHns { WithCreate withHnsEnabled(boolean enabled); } + /** The stage of storage account definition allowing to configure allow cross tenant replication. */ + interface WithAllowCrossTenantReplication { + /** + * Disables allow cross tenant replication. + * + * Disabling in storage account overrides the allow cross tenant replication settings for individual containers. + * + * @return the next stage of storage account definition + */ + WithCreate disallowCrossTenantReplication(); + + } + + /** The stage of storage account definition allowing to configure default to oauth authentication. */ + interface WithDefaultToOAuthAuthentication { + /** + * Allows default to oauth authentication, configured by individual containers. + * + * @return the next stage of storage account definition + */ + WithCreate enableDefaultToOAuthAuthentication(); + } + /** * A storage account definition with sufficient inputs to create a new storage account in the cloud, but * exposing additional optional inputs to specify. @@ -567,6 +604,8 @@ interface WithCreate DefinitionStages.WithLargeFileShares, DefinitionStages.WithHns, DefinitionStages.WithBlobAccess, + DefinitionStages.WithAllowCrossTenantReplication, + DefinitionStages.WithDefaultToOAuthAuthentication, Resource.DefinitionWithTags { } @@ -892,6 +931,45 @@ interface WithUpgrade { */ Update upgradeToGeneralPurposeAccountKindV2(); } + + /** The stage of storage account update allowing to allow cross tenant replication. */ + interface WithAllowCrossTenantReplication { + /** + * Allows to allow cross tenant replication, configured by individual containers. + * + * @return the next stage of storage account update + */ + Update allowCrossTenantReplication(); + + /** + * Disables cross tenant replication. + * + * Disabling in storage account overrides the cross tenant replication settings for individual containers. + * + * @return the next stage of storage account update + */ + Update disallowCrossTenantReplication(); + } + + /** The stage of storage account update allowing to configure default to oauth authentication. */ + interface WithDefaultToOAuthAuthentication { + /** + * Allows default to oauth authentication, configured by individual containers. + * + * @return the next stage of storage account update + */ + Update enableDefaultToOAuthAuthentication(); + + /** + * Disables default to oauth authentication. + * + * Disabling in storage account overrides the default to oauth authentication settings for individual containers. + * + * @return the next stage of storage account update + */ + Update disableDefaultToOAuthAuthentication(); + } + } /** The template for a storage account update operation, containing all the settings that can be modified. */ @@ -906,6 +984,8 @@ interface Update UpdateStages.WithNetworkAccess, UpdateStages.WithUpgrade, UpdateStages.WithBlobAccess, + UpdateStages.WithAllowCrossTenantReplication, + UpdateStages.WithDefaultToOAuthAuthentication, Resource.UpdateWithTags { } } diff --git a/sdk/resourcemanager/azure-resourcemanager-storage/src/test/java/com/azure/resourcemanager/storage/StorageAccountOperationsTests.java b/sdk/resourcemanager/azure-resourcemanager-storage/src/test/java/com/azure/resourcemanager/storage/StorageAccountOperationsTests.java index 0b3cb4d4e61c6..325de66a02cc4 100644 --- a/sdk/resourcemanager/azure-resourcemanager-storage/src/test/java/com/azure/resourcemanager/storage/StorageAccountOperationsTests.java +++ b/sdk/resourcemanager/azure-resourcemanager-storage/src/test/java/com/azure/resourcemanager/storage/StorageAccountOperationsTests.java @@ -185,4 +185,85 @@ public void storageAccountDefault() { Assertions.assertFalse(storageAccount.isBlobPublicAccessAllowed()); Assertions.assertFalse(storageAccount.isSharedKeyAccessAllowed()); } + + @Test + public void canAllowCrossTenantReplicationOnStorageAccount() { + StorageAccount storageAccount = + storageManager + .storageAccounts() + .define(saName) + .withRegion(Region.US_EAST2) + .withNewResourceGroup(rgName) + .withSku(StorageAccountSkuType.STANDARD_LRS) + .disallowCrossTenantReplication() + .create(); + + Assertions.assertFalse(storageAccount.isAllowCrossTenantReplication()); + + storageAccount.update() + .allowCrossTenantReplication() + .apply(); + + Assertions.assertTrue(storageAccount.isAllowCrossTenantReplication()); + } + + @Test + public void canDisallowCrossTenantReplicationOnStorageAccount() { + StorageAccount storageAccount = + storageManager + .storageAccounts() + .define(saName) + .withRegion(Region.US_EAST2) + .withNewResourceGroup(rgName) + .withSku(StorageAccountSkuType.STANDARD_LRS) + .create(); + + Assertions.assertTrue(storageAccount.isAllowCrossTenantReplication()); + + storageAccount.update() + .disallowCrossTenantReplication() + .apply(); + + Assertions.assertFalse(storageAccount.isAllowCrossTenantReplication()); + } + + @Test + public void canEnableDefaultToOAuthAuthenticationOnStorageAccount() { + StorageAccount storageAccount = + storageManager + .storageAccounts() + .define(saName) + .withRegion(Region.US_EAST2) + .withNewResourceGroup(rgName) + .withSku(StorageAccountSkuType.STANDARD_LRS) + .create(); + + Assertions.assertFalse(storageAccount.isDefaultToOAuthAuthentication()); + + storageAccount.update() + .enableDefaultToOAuthAuthentication() + .apply(); + + Assertions.assertTrue(storageAccount.isDefaultToOAuthAuthentication()); + } + @Test + public void canDisableDefaultToOAuthAuthenticationOnStorageAccount() { + StorageAccount storageAccount = + storageManager + .storageAccounts() + .define(saName) + .withRegion(Region.US_EAST2) + .withNewResourceGroup(rgName) + .withSku(StorageAccountSkuType.STANDARD_LRS) + .enableDefaultToOAuthAuthentication() + .create(); + + Assertions.assertTrue(storageAccount.isDefaultToOAuthAuthentication()); + + storageAccount.update() + .disableDefaultToOAuthAuthentication() + .apply(); + + Assertions.assertFalse(storageAccount.isDefaultToOAuthAuthentication()); + } }