diff --git a/sdk/resourcemanager/azure-resourcemanager-containerregistry/assets.json b/sdk/resourcemanager/azure-resourcemanager-containerregistry/assets.json index 9f5cf02e29233..0f84110468dff 100644 --- a/sdk/resourcemanager/azure-resourcemanager-containerregistry/assets.json +++ b/sdk/resourcemanager/azure-resourcemanager-containerregistry/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/resourcemanager/azure-resourcemanager-containerregistry", - "Tag": "java/resourcemanager/azure-resourcemanager-containerregistry_1a4bd3c103" + "Tag": "java/resourcemanager/azure-resourcemanager-containerregistry_c7a0288b18" } diff --git a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/implementation/RegistryImpl.java b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/implementation/RegistryImpl.java index 55ffbd5da87e4..fdc832dc0b63b 100644 --- a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/implementation/RegistryImpl.java +++ b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/implementation/RegistryImpl.java @@ -29,6 +29,7 @@ import com.azure.resourcemanager.containerregistry.models.SkuName; import com.azure.resourcemanager.containerregistry.models.SourceUploadDefinition; import com.azure.resourcemanager.containerregistry.models.WebhookOperations; +import com.azure.resourcemanager.containerregistry.models.ZoneRedundancy; import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpoint; import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpointConnection; import com.azure.resourcemanager.resources.fluentcore.arm.models.PrivateEndpointConnectionProvisioningState; @@ -224,6 +225,11 @@ public boolean isDedicatedDataEndpointsEnabled() { return ResourceManagerUtils.toPrimitiveBoolean(this.innerModel().dataEndpointEnabled()); } + @Override + public boolean isZoneRedundancyEnabled() { + return !Objects.isNull(this.innerModel().zoneRedundancy()) && ZoneRedundancy.ENABLED.equals(this.innerModel().zoneRedundancy()); + } + @Override public List dedicatedDataEndpointsHostNames() { return this.innerModel().dataEndpointHostNames() == null @@ -453,6 +459,14 @@ public PagedFlux listPrivateLinkResourcesAsync() { .mapPage(PrivateLinkResourceImpl::new); } + @Override + public RegistryImpl withZoneRedundancy() { + if (isInCreateMode()) { + this.innerModel().withZoneRedundancy(ZoneRedundancy.ENABLED); + } + return this; + } + private static final class PrivateLinkResourceImpl implements PrivateLinkResource { private final PrivateLinkResourceInner innerModel; diff --git a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/models/Registry.java b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/models/Registry.java index c60a962bb3355..48ff1e10cbd13 100644 --- a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/models/Registry.java +++ b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/models/Registry.java @@ -106,6 +106,9 @@ public interface Registry /** @return whether the container registries dedicated data endpoints can be accessed from public network */ boolean isDedicatedDataEndpointsEnabled(); + /** @return Whether or not zone redundancy is enabled for this container registry */ + boolean isZoneRedundancyEnabled(); + /** @return list of host names that will serve data when isDedicatedDataEndpointsEnabled is true */ List dedicatedDataEndpointsHostNames(); @@ -239,6 +242,21 @@ interface WithDedicatedDataEndpoints { WithCreate enableDedicatedDataEndpoints(); } + /** + * The stage of the container registry definition allowing to configure Zone Redundancy. + */ + interface WithZoneRedundancy { + /** + * Enables zone redundancy for the container registry. + * + * @return the next stage of the definition + * @see + * Enable zone redundancy + * + */ + WithCreate withZoneRedundancy(); + } + /** * The stage of the definition which contains all the minimum required inputs for the resource to be created, * but also allows for any other optional settings to be specified. @@ -249,6 +267,7 @@ interface WithCreate WithWebhook, WithPublicNetworkAccess, WithDedicatedDataEndpoints, + WithZoneRedundancy, Resource.DefinitionWithTags { } } diff --git a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/test/java/com/azure/resourcemanager/containerregistry/RegistryOperationsTests.java b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/test/java/com/azure/resourcemanager/containerregistry/RegistryOperationsTests.java new file mode 100644 index 0000000000000..b2a4332176610 --- /dev/null +++ b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/test/java/com/azure/resourcemanager/containerregistry/RegistryOperationsTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.resourcemanager.containerregistry; + +import com.azure.core.management.Region; +import com.azure.resourcemanager.containerregistry.models.Registry; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class RegistryOperationsTests extends RegistryTest { + + @Override + protected void cleanUpResources() { + resourceManager.resourceGroups().beginDeleteByName(rgName); + } + + @Test + public void canCreateContainerRegisterWithZoneRedundancy() { + final String acrName = generateRandomResourceName("acr", 10); + Registry registry = + registryManager + .containerRegistries() + .define(acrName) + .withRegion(Region.US_EAST) + .withNewResourceGroup(rgName) + .withPremiumSku() + .withRegistryNameAsAdminUser() + .withZoneRedundancy() + .create(); + Assertions.assertTrue(registry.isZoneRedundancyEnabled()); + } +}