diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainRegistrationProviderListOperationsSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainRegistrationProviderListOperationsSamples.java new file mode 100644 index 000000000000..3256d675b825 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainRegistrationProviderListOperationsSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for DomainRegistrationProvider ListOperations. + */ +public final class DomainRegistrationProviderListOperationsSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/ListOperations.json + */ + /** + * Sample code: List operations. + * + * @param manager Entry point to AppServiceManager. + */ + public static void listOperations(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomainRegistrationProviders() + .listOperations(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCheckAvailabilitySamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCheckAvailabilitySamples.java new file mode 100644 index 000000000000..2ffe2e6e3752 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCheckAvailabilitySamples.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +import com.azure.resourcemanager.appservice.fluent.models.NameIdentifierInner; + +/** + * Samples for Domains CheckAvailability. + */ +public final class DomainsCheckAvailabilitySamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/CheckDomainAvailability.json + */ + /** + * Sample code: Check domain availability. + * + * @param manager Entry point to AppServiceManager. + */ + public static void checkDomainAvailability(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .checkAvailabilityWithResponse(new NameIdentifierInner().withName("abcd.com"), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCreateOrUpdateOwnershipIdentifierSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCreateOrUpdateOwnershipIdentifierSamples.java new file mode 100644 index 000000000000..9d7189674d64 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCreateOrUpdateOwnershipIdentifierSamples.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +import com.azure.resourcemanager.appservice.fluent.models.DomainOwnershipIdentifierInner; + +/** + * Samples for Domains CreateOrUpdateOwnershipIdentifier. + */ +public final class DomainsCreateOrUpdateOwnershipIdentifierSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/CreateAppServiceDomainOwnershipIdentifier.json + */ + /** + * Sample code: Create App Service Domain OwnershipIdentifier. + * + * @param manager Entry point to AppServiceManager. + */ + public static void + createAppServiceDomainOwnershipIdentifier(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .createOrUpdateOwnershipIdentifierWithResponse("testrg123", "example.com", "SampleOwnershipId", + new DomainOwnershipIdentifierInner().withOwnershipId("SampleOwnershipId"), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCreateOrUpdateSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..1cfa8207dc37 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsCreateOrUpdateSamples.java @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +import com.azure.resourcemanager.appservice.fluent.models.DomainInner; +import com.azure.resourcemanager.appservice.models.Address; +import com.azure.resourcemanager.appservice.models.Contact; +import com.azure.resourcemanager.appservice.models.DnsType; +import com.azure.resourcemanager.appservice.models.DomainPurchaseConsent; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Domains CreateOrUpdate. + */ +public final class DomainsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/CreateAppServiceDomain.json + */ + /** + * Sample code: Create App Service Domain. + * + * @param manager Entry point to AppServiceManager. + */ + public static void createAppServiceDomain(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .createOrUpdate("testrg123", "example.com", + new DomainInner().withLocation("global") + .withTags(mapOf()) + .withContactAdmin(new Contact() + .withAddressMailing(new Address().withAddress1("3400 State St") + .withCity("Chicago") + .withCountry("United States") + .withPostalCode("fakeTokenPlaceholder") + .withState("IL")) + .withEmail("admin@email.com") + .withFax("1-245-534-2242") + .withJobTitle("Admin") + .withNameFirst("John") + .withNameLast("Doe") + .withNameMiddle("") + .withOrganization("Microsoft Inc.") + .withPhone("1-245-534-2242")) + .withContactBilling(new Contact() + .withAddressMailing(new Address().withAddress1("3400 State St") + .withCity("Chicago") + .withCountry("United States") + .withPostalCode("fakeTokenPlaceholder") + .withState("IL")) + .withEmail("billing@email.com") + .withFax("1-245-534-2242") + .withJobTitle("Billing") + .withNameFirst("John") + .withNameLast("Doe") + .withNameMiddle("") + .withOrganization("Microsoft Inc.") + .withPhone("1-245-534-2242")) + .withContactRegistrant(new Contact() + .withAddressMailing(new Address().withAddress1("3400 State St") + .withCity("Chicago") + .withCountry("United States") + .withPostalCode("fakeTokenPlaceholder") + .withState("IL")) + .withEmail("registrant@email.com") + .withFax("1-245-534-2242") + .withJobTitle("Registrant") + .withNameFirst("John") + .withNameLast("Doe") + .withNameMiddle("") + .withOrganization("Microsoft Inc.") + .withPhone("1-245-534-2242")) + .withContactTech(new Contact() + .withAddressMailing(new Address().withAddress1("3400 State St") + .withCity("Chicago") + .withCountry("United States") + .withPostalCode("fakeTokenPlaceholder") + .withState("IL")) + .withEmail("tech@email.com") + .withFax("1-245-534-2242") + .withJobTitle("Tech") + .withNameFirst("John") + .withNameLast("Doe") + .withNameMiddle("") + .withOrganization("Microsoft Inc.") + .withPhone("1-245-534-2242")) + .withPrivacy(false) + .withAutoRenew(true) + .withConsent(new DomainPurchaseConsent().withAgreementKeys(Arrays.asList("agreementKey1")) + .withAgreedBy("192.0.2.1") + .withAgreedAt(OffsetDateTime.parse("2021-09-10T19:30:53Z"))) + .withDnsType(DnsType.DEFAULT_DOMAIN_REGISTRAR_DNS) + .withAuthCode("fakeTokenPlaceholder"), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsDeleteOwnershipIdentifierSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsDeleteOwnershipIdentifierSamples.java new file mode 100644 index 000000000000..4390dc1c01eb --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsDeleteOwnershipIdentifierSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains DeleteOwnershipIdentifier. + */ +public final class DomainsDeleteOwnershipIdentifierSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/DeleteAppServiceDomainOwnershipIdentifier.json + */ + /** + * Sample code: Delete App Service Domain Ownership Identifier. + * + * @param manager Entry point to AppServiceManager. + */ + public static void + deleteAppServiceDomainOwnershipIdentifier(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .deleteOwnershipIdentifierWithResponse("testrg123", "example.com", "ownershipIdentifier", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsDeleteSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsDeleteSamples.java new file mode 100644 index 000000000000..c92650936c7c --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsDeleteSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains Delete. + */ +public final class DomainsDeleteSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/DeleteAppServiceDomain.json + */ + /** + * Sample code: Delete App Service Domain. + * + * @param manager Entry point to AppServiceManager. + */ + public static void deleteAppServiceDomain(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .deleteWithResponse("testrg123", "example.com", true, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetByResourceGroupSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetByResourceGroupSamples.java new file mode 100644 index 000000000000..a0ff4f509a0d --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetByResourceGroupSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains GetByResourceGroup. + */ +public final class DomainsGetByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/GetDomain.json + */ + /** + * Sample code: Get Domain. + * + * @param manager Entry point to AppServiceManager. + */ + public static void getDomain(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .getByResourceGroupWithResponse("testrg123", "example.com", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetControlCenterSsoRequestSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetControlCenterSsoRequestSamples.java new file mode 100644 index 000000000000..4b48b610fbd3 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetControlCenterSsoRequestSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains GetControlCenterSsoRequest. + */ +public final class DomainsGetControlCenterSsoRequestSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/GetDomainControlCenterSsoRequest.json + */ + /** + * Sample code: Get Domain Control Center Sso Request. + * + * @param manager Entry point to AppServiceManager. + */ + public static void + getDomainControlCenterSsoRequest(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .getControlCenterSsoRequestWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetOwnershipIdentifierSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetOwnershipIdentifierSamples.java new file mode 100644 index 000000000000..56a45e3e18e1 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsGetOwnershipIdentifierSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains GetOwnershipIdentifier. + */ +public final class DomainsGetOwnershipIdentifierSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/GetDomainOwnershipIdentifier.json + */ + /** + * Sample code: Get Domain Ownership Identifier. + * + * @param manager Entry point to AppServiceManager. + */ + public static void getDomainOwnershipIdentifier(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .getOwnershipIdentifierWithResponse("testrg123", "example.com", "SampleOwnershipId", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListByResourceGroupSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListByResourceGroupSamples.java new file mode 100644 index 000000000000..b71fb3933288 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListByResourceGroupSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains ListByResourceGroup. + */ +public final class DomainsListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/ListDomainsByResourceGroup.json + */ + /** + * Sample code: List domains by resource group. + * + * @param manager Entry point to AppServiceManager. + */ + public static void listDomainsByResourceGroup(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .listByResourceGroup("testrg123", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListOwnershipIdentifiersSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListOwnershipIdentifiersSamples.java new file mode 100644 index 000000000000..789592522225 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListOwnershipIdentifiersSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains ListOwnershipIdentifiers. + */ +public final class DomainsListOwnershipIdentifiersSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/ListDomainOwnershipIdentifiers.json + */ + /** + * Sample code: List Domain Ownership Identifiers. + * + * @param manager Entry point to AppServiceManager. + */ + public static void listDomainOwnershipIdentifiers(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .listOwnershipIdentifiers("testrg123", "example.com", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListRecommendationsSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListRecommendationsSamples.java new file mode 100644 index 000000000000..2c3ebc9ec6b6 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListRecommendationsSamples.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +import com.azure.resourcemanager.appservice.models.DomainRecommendationSearchParameters; + +/** + * Samples for Domains ListRecommendations. + */ +public final class DomainsListRecommendationsSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/ListDomainRecommendations.json + */ + /** + * Sample code: List domain recommendations. + * + * @param manager Entry point to AppServiceManager. + */ + public static void listDomainRecommendations(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .listRecommendations(new DomainRecommendationSearchParameters().withKeywords("fakeTokenPlaceholder") + .withMaxDomainRecommendations(10), com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListSamples.java new file mode 100644 index 000000000000..28b062ac6c06 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsListSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains List. + */ +public final class DomainsListSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/ListDomainsBySubscription.json + */ + /** + * Sample code: List domains by subscription. + * + * @param manager Entry point to AppServiceManager. + */ + public static void listDomainsBySubscription(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient().getDomains().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsRenewSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsRenewSamples.java new file mode 100644 index 000000000000..33c71f33a495 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsRenewSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains Renew. + */ +public final class DomainsRenewSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/RenewDomain.json + */ + /** + * Sample code: Renew an existing domain. + * + * @param manager Entry point to AppServiceManager. + */ + public static void renewAnExistingDomain(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .renewWithResponse("RG", "example.com", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsTransferOutSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsTransferOutSamples.java new file mode 100644 index 000000000000..f2692297a8d6 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsTransferOutSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for Domains TransferOut. + */ +public final class DomainsTransferOutSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/TransferOutDomain.json + */ + /** + * Sample code: Transfer out domain. + * + * @param manager Entry point to AppServiceManager. + */ + public static void transferOutDomain(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .transferOutWithResponse("testrg123", "example.com", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsUpdateOwnershipIdentifierSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsUpdateOwnershipIdentifierSamples.java new file mode 100644 index 000000000000..ccc4c3c02297 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsUpdateOwnershipIdentifierSamples.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +import com.azure.resourcemanager.appservice.fluent.models.DomainOwnershipIdentifierInner; + +/** + * Samples for Domains UpdateOwnershipIdentifier. + */ +public final class DomainsUpdateOwnershipIdentifierSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/UpdateAppServiceDomainOwnershipIdentifier.json + */ + /** + * Sample code: Update App Service Domain OwnershipIdentifier. + * + * @param manager Entry point to AppServiceManager. + */ + public static void + updateAppServiceDomainOwnershipIdentifier(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .updateOwnershipIdentifierWithResponse("testrg123", "example.com", "SampleOwnershipId", + new DomainOwnershipIdentifierInner().withOwnershipId("SampleOwnershipId"), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsUpdateSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsUpdateSamples.java new file mode 100644 index 000000000000..80c50039a921 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/DomainsUpdateSamples.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +import com.azure.resourcemanager.appservice.models.Address; +import com.azure.resourcemanager.appservice.models.Contact; +import com.azure.resourcemanager.appservice.models.DnsType; +import com.azure.resourcemanager.appservice.models.DomainPatchResource; +import com.azure.resourcemanager.appservice.models.DomainPurchaseConsent; +import java.time.OffsetDateTime; +import java.util.Arrays; + +/** + * Samples for Domains Update. + */ +public final class DomainsUpdateSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/UpdateAppServiceDomain.json + */ + /** + * Sample code: Update App Service Domain. + * + * @param manager Entry point to AppServiceManager. + */ + public static void updateAppServiceDomain(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getDomains() + .updateWithResponse("testrg123", "example.com", + new DomainPatchResource() + .withContactAdmin(new Contact() + .withAddressMailing(new Address().withAddress1("3400 State St") + .withCity("Chicago") + .withCountry("United States") + .withPostalCode("fakeTokenPlaceholder") + .withState("IL")) + .withEmail("admin@email.com") + .withFax("1-245-534-2242") + .withJobTitle("Admin") + .withNameFirst("John") + .withNameLast("Doe") + .withNameMiddle("") + .withOrganization("Microsoft Inc.") + .withPhone("1-245-534-2242")) + .withContactBilling(new Contact() + .withAddressMailing(new Address().withAddress1("3400 State St") + .withCity("Chicago") + .withCountry("United States") + .withPostalCode("fakeTokenPlaceholder") + .withState("IL")) + .withEmail("billing@email.com") + .withFax("1-245-534-2242") + .withJobTitle("Billing") + .withNameFirst("John") + .withNameLast("Doe") + .withNameMiddle("") + .withOrganization("Microsoft Inc.") + .withPhone("1-245-534-2242")) + .withContactRegistrant(new Contact() + .withAddressMailing(new Address().withAddress1("3400 State St") + .withCity("Chicago") + .withCountry("United States") + .withPostalCode("fakeTokenPlaceholder") + .withState("IL")) + .withEmail("registrant@email.com") + .withFax("1-245-534-2242") + .withJobTitle("Registrant") + .withNameFirst("John") + .withNameLast("Doe") + .withNameMiddle("") + .withOrganization("Microsoft Inc.") + .withPhone("1-245-534-2242")) + .withContactTech(new Contact() + .withAddressMailing(new Address().withAddress1("3400 State St") + .withCity("Chicago") + .withCountry("United States") + .withPostalCode("fakeTokenPlaceholder") + .withState("IL")) + .withEmail("tech@email.com") + .withFax("1-245-534-2242") + .withJobTitle("Tech") + .withNameFirst("John") + .withNameLast("Doe") + .withNameMiddle("") + .withOrganization("Microsoft Inc.") + .withPhone("1-245-534-2242")) + .withPrivacy(false) + .withAutoRenew(true) + .withConsent(new DomainPurchaseConsent().withAgreementKeys(Arrays.asList("agreementKey1")) + .withAgreedBy("192.0.2.1") + .withAgreedAt(OffsetDateTime.parse("2021-09-10T19:30:53Z"))) + .withDnsType(DnsType.DEFAULT_DOMAIN_REGISTRAR_DNS) + .withAuthCode("fakeTokenPlaceholder"), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsGetSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsGetSamples.java new file mode 100644 index 000000000000..207f24c54677 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsGetSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for TopLevelDomains Get. + */ +public final class TopLevelDomainsGetSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/GetTopLevelDomain.json + */ + /** + * Sample code: Get Top Level Domain. + * + * @param manager Entry point to AppServiceManager. + */ + public static void getTopLevelDomain(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getTopLevelDomains() + .getWithResponse("com", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsListAgreementsSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsListAgreementsSamples.java new file mode 100644 index 000000000000..906aa3d5f0f5 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsListAgreementsSamples.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +import com.azure.resourcemanager.appservice.models.TopLevelDomainAgreementOption; + +/** + * Samples for TopLevelDomains ListAgreements. + */ +public final class TopLevelDomainsListAgreementsSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/ListTopLevelDomainAgreements.json + */ + /** + * Sample code: List Top Level Domain Agreements. + * + * @param manager Entry point to AppServiceManager. + */ + public static void listTopLevelDomainAgreements(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient() + .getTopLevelDomains() + .listAgreements("in", new TopLevelDomainAgreementOption().withIncludePrivacy(true).withForTransfer(false), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsListSamples.java b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsListSamples.java new file mode 100644 index 000000000000..1cb89a4cf284 --- /dev/null +++ b/sdk/appservice/azure-resourcemanager-appservice/src/samples/java/com/azure/resourcemanager/appservice/generated/TopLevelDomainsListSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.appservice.generated; + +/** + * Samples for TopLevelDomains List. + */ +public final class TopLevelDomainsListSamples { + /* + * x-ms-original-file: + * specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/stable/2024-11- + * 01/examples/ListTopLevelDomains.json + */ + /** + * Sample code: List Top Level Domains. + * + * @param manager Entry point to AppServiceManager. + */ + public static void listTopLevelDomains(com.azure.resourcemanager.appservice.AppServiceManager manager) { + manager.domainRegistrationClient().getTopLevelDomains().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resourcemanager/api-specs.json b/sdk/resourcemanager/api-specs.json index bd98b3ca5934..3ed95ffb2157 100644 --- a/sdk/resourcemanager/api-specs.json +++ b/sdk/resourcemanager/api-specs.json @@ -15,13 +15,13 @@ "dir": "../appservice/azure-resourcemanager-appservice", "source": "specification/certificateregistration/resource-manager/Microsoft.CertificateRegistration/CertificateRegistration/readme.md", "package": "com.azure.resourcemanager.appservice", - "args": "--tag=package-2024-11 --title=CertificateRegistrationManagementClient --metadata-suffix=certificateregistration --add-inner=AppServiceCertificate,NameIdentifier --enable-sync-stack=false" + "args": "--tag=package-2024-11 --service-name=AppService --title=CertificateRegistrationManagementClient --metadata-suffix=certificateregistration --add-inner=AppServiceCertificate,NameIdentifier --enable-sync-stack=false" }, "domainregistration": { "dir": "../appservice/azure-resourcemanager-appservice", "source": "specification/domainregistration/resource-manager/Microsoft.DomainRegistration/DomainRegistration/readme.md", "package": "com.azure.resourcemanager.appservice", - "args": "--tag=package-2024-11 --title=DomainRegistrationManagementClient --metadata-suffix=domainregistration --enable-sync-stack=false" + "args": "--tag=package-2024-11 --service-name=AppService --title=DomainRegistrationManagementClient --metadata-suffix=domainregistration --enable-sync-stack=false" }, "authorization": { "dir": "../authorization/azure-resourcemanager-authorization", @@ -57,7 +57,7 @@ "dir": "../containerregistry/azure-resourcemanager-containerregistry", "source": "specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/RegistryTasks/readme.md", "package": "com.azure.resourcemanager.containerregistry", - "args": "--tag=package-2019-06-preview --generate-samples=false --title=ContainerRegistryTasksManagementClient --rename-operation-group:Registries:RegistryTasks --rename-model=DockerBuildStep:DockerTaskStep --modelerfour.lenient-model-deduplication --metadata-suffix=registrytasks --enable-sync-stack=false", + "args": "--tag=package-2019-06-preview --service-name=ContainerRegistry --generate-samples=false --title=ContainerRegistryTasksManagementClient --rename-operation-group:Registries:RegistryTasks --rename-model=DockerBuildStep:DockerTaskStep --modelerfour.lenient-model-deduplication --metadata-suffix=registrytasks --enable-sync-stack=false", "note": "Use commit 09695f5a97dfcf201766ea2f2e7e3b53aec49144 for Swagger before TypeSpec migration" }, "containerservice": { @@ -88,14 +88,14 @@ "dir": "../resources/azure-resourcemanager-resources", "source": "specification/resources/resource-manager/Microsoft.Features/features/readme.md", "package": "com.azure.resourcemanager.resources", - "args": "--tag=package-features-2021-07 --metadata-suffix=feature --enable-sync-stack=false" + "args": "--tag=package-features-2021-07 --service-name=Resource --metadata-suffix=feature --enable-sync-stack=false" }, "msgraph": { "spec": ".", "dir": "azure-resourcemanager-authorization", "source": "azure-resourcemanager-authorization/swagger/swagger.md", "package": "com.azure.resourcemanager.authorization", - "args": "--tag=v1.0 --metadata-suffix=msgraph --title=MicrosoftGraphClient --models-subpackage=fluent.models --enable-sync-stack=false" + "args": "--tag=v1.0 --service-name=Authorization --metadata-suffix=msgraph --title=MicrosoftGraphClient --models-subpackage=fluent.models --enable-sync-stack=false" }, "keyvault": { "dir": "../keyvault/azure-resourcemanager-keyvault", @@ -108,7 +108,7 @@ "dir": "../resources/azure-resourcemanager-resources", "source": "specification/resources/resource-manager/Microsoft.Authorization/locks/readme.md", "package": "com.azure.resourcemanager.resources", - "args": "--tag=package-locks-2017-04 --metadata-suffix=lock --enable-sync-stack=false" + "args": "--tag=package-locks-2017-04 --service-name=Resource --metadata-suffix=lock --enable-sync-stack=false" }, "monitor": { "dir": "../monitor/azure-resourcemanager-monitor", @@ -127,7 +127,7 @@ "dir": "../resources/azure-resourcemanager-resources", "source": "specification/resources/resource-manager/Microsoft.Authorization/policy/readme.md", "package": "com.azure.resourcemanager.resources", - "args": "--tag=package-policy-2025-03-java --metadata-suffix=policy --modelerfour.lenient-model-deduplication --rename-model=UserAssignedIdentitiesValue:IdentityUserAssignedIdentitiesValue --enable-sync-stack=false", + "args": "--tag=package-policy-2025-03-java --service-name=Resource --metadata-suffix=policy --modelerfour.lenient-model-deduplication --rename-model=UserAssignedIdentitiesValue:IdentityUserAssignedIdentitiesValue --enable-sync-stack=false", "note": "Remove policyVariables.json and policyVariableValues.json from tag, as they are still in preview." }, "privatedns": { @@ -160,13 +160,13 @@ "dir": "../resources/azure-resourcemanager-resources", "source": "specification/resources/resource-manager/Microsoft.Resources/deployments/readme.md", "package": "com.azure.resourcemanager.resources", - "args": "--tag=package-2025-04 --title=DeploymentsManagementClient --uuid-as-string=false --client-flattened-annotation-target=none --add-inner=Deployment,Provider --metadata-suffix=deployments --enable-sync-stack=false" + "args": "--tag=package-2025-04 --service-name=Resource --title=DeploymentsManagementClient --uuid-as-string=false --client-flattened-annotation-target=none --add-inner=Deployment,Provider --metadata-suffix=deployments --enable-sync-stack=false" }, "deploymentstacks": { "dir": "../resources/azure-resourcemanager-resources", "source": "specification/resources/resource-manager/Microsoft.Resources/deploymentStacks/readme.md", "package": "com.azure.resourcemanager.resources", - "args": "--tag=package-2024-03-java --metadata-suffix=deploymentstacks --generate-samples=false --enable-sync-stack=false" + "args": "--tag=package-2024-03-java --service-name=Resource --metadata-suffix=deploymentstacks --generate-samples=false --enable-sync-stack=false" }, "search": { "dir": "../search/azure-resourcemanager-search", @@ -198,7 +198,7 @@ "dir": "../resources/azure-resourcemanager-resources", "source": "specification/resources/resource-manager/Microsoft.Resources/subscriptions/readme.md", "package": "com.azure.resourcemanager.resources", - "args": "--tag=package-subscriptions-2022-12 --metadata-suffix=subscription --modelerfour.lenient-model-deduplication --name-for-ungrouped-operations=ResourceName --remove-operation-group=Operations --enable-sync-stack=false" + "args": "--tag=package-subscriptions-2022-12 --service-name=Resource --metadata-suffix=subscription --modelerfour.lenient-model-deduplication --name-for-ungrouped-operations=ResourceName --remove-operation-group=Operations --enable-sync-stack=false" }, "trafficmanager": { "dir": "../trafficmanager/azure-resourcemanager-trafficmanager", @@ -216,12 +216,12 @@ "dir": "../resources/azure-resourcemanager-resources", "source": "specification/resources/resource-manager/Microsoft.Resources/changes/readme.md", "package": "com.azure.resourcemanager.resources", - "args": "--tag=package-changes-2022-05 --metadata-suffix=change --rename-model=ChangeType:ResourceChangeType,PropertyChangeType:ResourcePropertyChangeType --enable-sync-stack=false" + "args": "--tag=package-changes-2022-05 --service-name=Resource --metadata-suffix=change --rename-model=ChangeType:ResourceChangeType,PropertyChangeType:ResourcePropertyChangeType --enable-sync-stack=false" }, "databoundaries": { "dir": "../resources/azure-resourcemanager-resources", "source": "specification/resources/resource-manager/Microsoft.Resources/databoundaries/readme.md", "package": "com.azure.resourcemanager.resources", - "args": "--tag=package-databoundaries-2024-08 --title=DataBoundariesManagementClient --metadata-suffix=databoundary --remove-operation-group=Operations --enable-sync-stack=false" + "args": "--tag=package-databoundaries-2024-08 --service-name=Resource --title=DataBoundariesManagementClient --metadata-suffix=databoundary --remove-operation-group=Operations --enable-sync-stack=false" } } diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/DataPolicyManifestsGetByPolicyModeSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/DataPolicyManifestsGetByPolicyModeSamples.java new file mode 100644 index 000000000000..5cd975bf3c85 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/DataPolicyManifestsGetByPolicyModeSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for DataPolicyManifests GetByPolicyMode. + */ +public final class DataPolicyManifestsGetByPolicyModeSamples { + /* + * x-ms-original-file: + * specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2020-09-01/examples/ + * getDataPolicyManifest.json + */ + /** + * Sample code: Retrieve a data policy manifest by policy mode. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveADataPolicyManifestByPolicyMode(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getDataPolicyManifests() + .getByPolicyModeWithResponse("Microsoft.KeyVault.Data", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/DataPolicyManifestsListSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/DataPolicyManifestsListSamples.java new file mode 100644 index 000000000000..fe1a5b770ccb --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/DataPolicyManifestsListSamples.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for DataPolicyManifests List. + */ +public final class DataPolicyManifestsListSamples { + /* + * x-ms-original-file: + * specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2020-09-01/examples/ + * listDataPolicyManifests.json + */ + /** + * Sample code: List data policy manifests. + * + * @param manager Entry point to ResourceManager. + */ + public static void listDataPolicyManifests(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient().getDataPolicyManifests().list(null, com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * specification/resources/resource-manager/Microsoft.Authorization/policy/stable/2020-09-01/examples/ + * listDataPolicyManifestsNamespaceFilter.json + */ + /** + * Sample code: List data policy manifests with namespace filter. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listDataPolicyManifestsWithNamespaceFilter(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getDataPolicyManifests() + .list("namespace eq 'Microsoft.KeyVault'", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsCreateByIdSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsCreateByIdSamples.java new file mode 100644 index 000000000000..aa8a81ea8a3e --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsCreateByIdSamples.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicyAssignmentInner; +import com.azure.resourcemanager.resources.models.EnforcementMode; +import com.azure.resourcemanager.resources.models.Identity; +import com.azure.resourcemanager.resources.models.ParameterValuesValue; +import com.azure.resourcemanager.resources.models.ResourceIdentityType; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicyAssignments CreateById. + */ +public final class PolicyAssignmentsCreateByIdSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentById.json + */ + /** + * Sample code: Create or update policy assignment by ID. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdatePolicyAssignmentByID(com.azure.resourcemanager.resources.ResourceManager manager) + throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createByIdWithResponse( + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", + new PolicyAssignmentInner().withDisplayName("Enforce storage account SKU") + .withPolicyDefinitionId( + "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + .withDefinitionVersion("1.*.*") + .withParameters(mapOf("listOfAllowedSKUs", new ParameterValuesValue().withValue(SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize("[\"Standard_GRS\",\"Standard_LRS\"]", Object.class, SerializerEncoding.JSON)))) + .withDescription("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Cheapskate Boss\"}", Object.class, SerializerEncoding.JSON)) + .withEnforcementMode(EnforcementMode.DEFAULT), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentWithIdentityById.json + */ + /** + * Sample code: Create or update policy assignment with a managed identity by ID. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdatePolicyAssignmentWithAManagedIdentityByID( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createByIdWithResponse( + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", + new PolicyAssignmentInner().withLocation("eastus") + .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED)) + .withDisplayName("Enforce storage account SKU") + .withPolicyDefinitionId( + "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + .withDefinitionVersion("1.*.*") + .withParameters(mapOf("listOfAllowedSKUs", new ParameterValuesValue().withValue(SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize("[\"Standard_GRS\",\"Standard_LRS\"]", Object.class, SerializerEncoding.JSON)))) + .withDescription("Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Cheapskate Boss\"}", Object.class, SerializerEncoding.JSON)) + .withEnforcementMode(EnforcementMode.DEFAULT), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsCreateSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsCreateSamples.java new file mode 100644 index 000000000000..6ed94bbb6fbe --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsCreateSamples.java @@ -0,0 +1,279 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicyAssignmentInner; +import com.azure.resourcemanager.resources.models.EnforcementMode; +import com.azure.resourcemanager.resources.models.Identity; +import com.azure.resourcemanager.resources.models.IdentityUserAssignedIdentitiesValue; +import com.azure.resourcemanager.resources.models.NonComplianceMessage; +import com.azure.resourcemanager.resources.models.OverrideKind; +import com.azure.resourcemanager.resources.models.OverrideModel; +import com.azure.resourcemanager.resources.models.ParameterValuesValue; +import com.azure.resourcemanager.resources.models.ResourceIdentityType; +import com.azure.resourcemanager.resources.models.ResourceSelector; +import com.azure.resourcemanager.resources.models.Selector; +import com.azure.resourcemanager.resources.models.SelectorKind; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicyAssignments Create. + */ +public final class PolicyAssignmentsCreateSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentWithResourceSelectors.json + */ + /** + * Sample code: Create or update a policy assignment with resource selectors. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyAssignmentWithResourceSelectors( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", + new PolicyAssignmentInner().withDisplayName("Limit the resource location and resource SKU") + .withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement") + .withDescription("Limit the resource location and resource SKU") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Special Someone\"}", Object.class, SerializerEncoding.JSON)) + .withResourceSelectors(Arrays.asList(new ResourceSelector().withName("SDPRegions") + .withSelectors(Arrays.asList(new Selector().withKind(SelectorKind.RESOURCE_LOCATION) + .withIn(Arrays.asList("eastus2euap", "centraluseuap")))))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentWithEnrollEnforcement.json + */ + /** + * Sample code: Create or update a policy assignment to enforce policy effect only on enrolled resources during + * resource creation or update. + * + * @param manager Entry point to ResourceManager. + */ + public static void + createOrUpdateAPolicyAssignmentToEnforcePolicyEffectOnlyOnEnrolledResourcesDuringResourceCreationOrUpdate( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNamingEnroll", + new PolicyAssignmentInner().withDisplayName("Enforce resource naming rules") + .withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withDescription("Force resource names to begin with given DeptA and end with -LC") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Special Someone\"}", Object.class, SerializerEncoding.JSON)) + .withEnforcementMode(EnforcementMode.ENROLL), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignment.json + */ + /** + * Sample code: Create or update a policy assignment. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyAssignment(com.azure.resourcemanager.resources.ResourceManager manager) + throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", + new PolicyAssignmentInner().withDisplayName("Enforce resource naming rules") + .withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withDescription("Force resource names to begin with given DeptA and end with -LC") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Special Someone\"}", Object.class, SerializerEncoding.JSON)) + .withNonComplianceMessages(Arrays.asList(new NonComplianceMessage() + .withMessage("Resource names must start with 'DeptA' and end with '-LC'."))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentWithIdentity.json + */ + /** + * Sample code: Create or update a policy assignment with a system assigned identity. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", + new PolicyAssignmentInner().withLocation("eastus") + .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED)) + .withDisplayName("Enforce resource naming rules") + .withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withDescription("Force resource names to begin with given DeptA and end with -LC") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Foo Bar\"}", Object.class, SerializerEncoding.JSON)) + .withEnforcementMode(EnforcementMode.DEFAULT), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentNonComplianceMessages.json + */ + /** + * Sample code: Create or update a policy assignment with multiple non-compliance messages. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .createWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "securityInitAssignment", + new PolicyAssignmentInner().withDisplayName("Enforce security policies") + .withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative") + .withNonComplianceMessages(Arrays.asList(new NonComplianceMessage().withMessage( + "Resources must comply with all internal security policies. See for more info."), + new NonComplianceMessage() + .withMessage("Resource names must start with 'DeptA' and end with '-LC'.") + .withPolicyDefinitionReferenceId("10420126870854049575"), + new NonComplianceMessage().withMessage("Storage accounts must have firewall rules configured.") + .withPolicyDefinitionReferenceId("8572513655450389710"))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json + */ + /** + * Sample code: Create or update a policy assignment with a user assigned identity. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", + new PolicyAssignmentInner().withLocation("eastus") + .withIdentity(new Identity().withType(ResourceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity", + new IdentityUserAssignedIdentitiesValue()))) + .withDisplayName("Enforce resource naming rules") + .withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withDescription("Force resource names to begin with given DeptA and end with -LC") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Foo Bar\"}", Object.class, SerializerEncoding.JSON)) + .withEnforcementMode(EnforcementMode.DEFAULT), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentWithOverrides.json + */ + /** + * Sample code: Create or update a policy assignment with overrides. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyAssignmentWithOverrides( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", + new PolicyAssignmentInner().withDisplayName("Limit the resource location and resource SKU") + .withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement") + .withDefinitionVersion("1.*.*") + .withDescription("Limit the resource location and resource SKU") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Special Someone\"}", Object.class, SerializerEncoding.JSON)) + .withOverrides( + Arrays + .asList( + new OverrideModel().withKind(OverrideKind.POLICY_EFFECT) + .withValue("Audit") + .withSelectors(Arrays + .asList(new Selector().withKind(SelectorKind.POLICY_DEFINITION_REFERENCE_ID) + .withIn(Arrays.asList("Limit_Skus", "Limit_Locations")))), + new OverrideModel().withKind(OverrideKind.DEFINITION_VERSION) + .withValue("2.*.*") + .withSelectors(Arrays.asList(new Selector().withKind(SelectorKind.RESOURCE_LOCATION) + .withIn(Arrays.asList("eastUSEuap", "centralUSEuap")))))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createPolicyAssignmentWithoutEnforcement.json + */ + /** + * Sample code: Create or update a policy assignment without enforcing policy effect during resource creation or + * update. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyAssignments() + .createWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", + new PolicyAssignmentInner().withDisplayName("Enforce resource naming rules") + .withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withDescription("Force resource names to begin with given DeptA and end with -LC") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"assignedBy\":\"Special Someone\"}", Object.class, SerializerEncoding.JSON)) + .withEnforcementMode(EnforcementMode.DO_NOT_ENFORCE), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsDeleteByIdSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsDeleteByIdSamples.java new file mode 100644 index 000000000000..3548fb07abf0 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsDeleteByIdSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyAssignments DeleteById. + */ +public final class PolicyAssignmentsDeleteByIdSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicyAssignmentById.json + */ + /** + * Sample code: Delete a policy assignment by ID. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicyAssignmentByID(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .deleteByIdWithResponse( + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsDeleteSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsDeleteSamples.java new file mode 100644 index 000000000000..5e5a5d3e9121 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsDeleteSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyAssignments Delete. + */ +public final class PolicyAssignmentsDeleteSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicyAssignment.json + */ + /** + * Sample code: Delete a policy assignment. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicyAssignment(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .deleteWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsGetByIdSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsGetByIdSamples.java new file mode 100644 index 000000000000..6358ea1d7686 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsGetByIdSamples.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyAssignments GetById. + */ +public final class PolicyAssignmentsGetByIdSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyAssignmentById.json + */ + /** + * Sample code: Retrieve a policy assignment by ID. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicyAssignmentByID(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .getByIdWithResponse( + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyAssignmentWithIdentityById.json + */ + /** + * Sample code: Retrieve a policy assignment with a managed identity by ID. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveAPolicyAssignmentWithAManagedIdentityByID(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .getByIdWithResponse( + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsGetSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsGetSamples.java new file mode 100644 index 000000000000..74ccb1bf58eb --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsGetSamples.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyAssignments Get. + */ +public final class PolicyAssignmentsGetSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyAssignmentWithOverrides.json + */ + /** + * Sample code: Retrieve a policy assignment with overrides. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveAPolicyAssignmentWithOverrides(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .getWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", null, + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json + */ + /** + * Sample code: Retrieve a policy assignment with a user assigned identity. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicyAssignmentWithAUserAssignedIdentity( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .getWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", null, + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyAssignmentWithResourceSelectors.json + */ + /** + * Sample code: Retrieve a policy assignment with resource selectors. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveAPolicyAssignmentWithResourceSelectors(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .getWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", null, + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyAssignment.json + */ + /** + * Sample code: Retrieve a policy assignment. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicyAssignment(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .getWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", null, + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyAssignmentWithIdentity.json + */ + /** + * Sample code: Retrieve a policy assignment with a system assigned identity. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicyAssignmentWithASystemAssignedIdentity( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .getWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", null, + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListByResourceGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListByResourceGroupSamples.java new file mode 100644 index 000000000000..6e937406e16e --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListByResourceGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyAssignments ListByResourceGroup. + */ +public final class PolicyAssignmentsListByResourceGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicyAssignmentsForResourceGroup.json + */ + /** + * Sample code: List policy assignments that apply to a resource group. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyAssignmentsThatApplyToAResourceGroup(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .listByResourceGroup("TestResourceGroup", "atScope()", + "LatestDefinitionVersion, EffectiveDefinitionVersion", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListForManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListForManagementGroupSamples.java new file mode 100644 index 000000000000..6d74a99e46a3 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListForManagementGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyAssignments ListForManagementGroup. + */ +public final class PolicyAssignmentsListForManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicyAssignmentsForManagementGroup.json + */ + /** + * Sample code: List policy assignments that apply to a management group. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyAssignmentsThatApplyToAManagementGroup(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .listForManagementGroup("TestManagementGroup", "atScope()", + "LatestDefinitionVersion, EffectiveDefinitionVersion", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListForResourceSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListForResourceSamples.java new file mode 100644 index 000000000000..88672eff24d1 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListForResourceSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyAssignments ListForResource. + */ +public final class PolicyAssignmentsListForResourceSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicyAssignmentsForResource.json + */ + /** + * Sample code: List all policy assignments that apply to a resource. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listAllPolicyAssignmentsThatApplyToAResource(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .listForResource("TestResourceGroup", "Microsoft.Compute", "virtualMachines/MyTestVm", "domainNames", + "MyTestComputer.cloudapp.net", null, null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListSamples.java new file mode 100644 index 000000000000..bc6d64c670cf --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsListSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyAssignments List. + */ +public final class PolicyAssignmentsListSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicyAssignments.json + */ + /** + * Sample code: List policy assignments that apply to a subscription. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyAssignmentsThatApplyToASubscription(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .list("atScope()", "LatestDefinitionVersion, EffectiveDefinitionVersion", null, + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsUpdateByIdSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsUpdateByIdSamples.java new file mode 100644 index 000000000000..56230026912b --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsUpdateByIdSamples.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.resourcemanager.resources.models.Identity; +import com.azure.resourcemanager.resources.models.PolicyAssignmentUpdate; +import com.azure.resourcemanager.resources.models.ResourceIdentityType; + +/** + * Samples for PolicyAssignments UpdateById. + */ +public final class PolicyAssignmentsUpdateByIdSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/updatePolicyAssignmentWithIdentityById.json + */ + /** + * Sample code: Update policy assignment with a managed identity by ID. + * + * @param manager Entry point to ResourceManager. + */ + public static void + updatePolicyAssignmentWithAManagedIdentityByID(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .updateByIdWithResponse( + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage", + new PolicyAssignmentUpdate().withLocation("eastus") + .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED)), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsUpdateSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsUpdateSamples.java new file mode 100644 index 000000000000..72b2f4bb957e --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyAssignmentsUpdateSamples.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.resourcemanager.resources.models.Identity; +import com.azure.resourcemanager.resources.models.IdentityUserAssignedIdentitiesValue; +import com.azure.resourcemanager.resources.models.OverrideKind; +import com.azure.resourcemanager.resources.models.OverrideModel; +import com.azure.resourcemanager.resources.models.PolicyAssignmentUpdate; +import com.azure.resourcemanager.resources.models.ResourceIdentityType; +import com.azure.resourcemanager.resources.models.ResourceSelector; +import com.azure.resourcemanager.resources.models.Selector; +import com.azure.resourcemanager.resources.models.SelectorKind; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicyAssignments Update. + */ +public final class PolicyAssignmentsUpdateSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/updatePolicyAssignmentWithResourceSelectors.json + */ + /** + * Sample code: Update a policy assignment with resource selectors. + * + * @param manager Entry point to ResourceManager. + */ + public static void + updateAPolicyAssignmentWithResourceSelectors(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .updateWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", + new PolicyAssignmentUpdate() + .withResourceSelectors(Arrays.asList(new ResourceSelector().withName("SDPRegions") + .withSelectors(Arrays.asList(new Selector().withKind(SelectorKind.RESOURCE_LOCATION) + .withIn(Arrays.asList("eastus2euap", "centraluseuap")))))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json + */ + /** + * Sample code: Update a policy assignment with a user assigned identity. + * + * @param manager Entry point to ResourceManager. + */ + public static void + updateAPolicyAssignmentWithAUserAssignedIdentity(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .updateWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", + new PolicyAssignmentUpdate().withLocation("eastus") + .withIdentity(new Identity().withType(ResourceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity", + new IdentityUserAssignedIdentitiesValue()))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/updatePolicyAssignmentWithOverrides.json + */ + /** + * Sample code: Update a policy assignment with overrides. + * + * @param manager Entry point to ResourceManager. + */ + public static void + updateAPolicyAssignmentWithOverrides(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .updateWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "CostManagement", + new PolicyAssignmentUpdate().withOverrides(Arrays.asList(new OverrideModel() + .withKind(OverrideKind.POLICY_EFFECT) + .withValue("Audit") + .withSelectors(Arrays.asList(new Selector().withKind(SelectorKind.POLICY_DEFINITION_REFERENCE_ID) + .withIn(Arrays.asList("Limit_Skus", "Limit_Locations")))))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/updatePolicyAssignmentWithIdentity.json + */ + /** + * Sample code: Update a policy assignment with a system assigned identity. + * + * @param manager Entry point to ResourceManager. + */ + public static void updateAPolicyAssignmentWithASystemAssignedIdentity( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyAssignments() + .updateWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2", "EnforceNaming", + new PolicyAssignmentUpdate().withLocation("eastus") + .withIdentity(new Identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED)), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupSamples.java new file mode 100644 index 000000000000..c5868519a8d7 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupSamples.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicyDefinitionVersionInner; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValue; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValueMetadata; +import com.azure.resourcemanager.resources.models.ParameterType; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicyDefinitionVersions CreateOrUpdateAtManagementGroup. + */ +public final class PolicyDefinitionVersionsCreateOrUpdateAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicyDefinitionVersionAtManagementGroup.json + */ + /** + * Sample code: Create or update a policy definition version at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyDefinitionVersionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyDefinitionVersions() + .createOrUpdateAtManagementGroupWithResponse("MyManagementGroup", "ResourceNaming", "1.2.1", + new PolicyDefinitionVersionInner().withMode("All") + .withDisplayName("Enforce resource naming convention") + .withDescription("Force resource names to begin with given 'prefix' and/or end with given 'suffix'") + .withPolicyRule(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize( + "{\"if\":{\"not\":{\"field\":\"name\",\"like\":\"[concat(parameters('prefix'), '*', parameters('suffix'))]\"}},\"then\":{\"effect\":\"deny\"}}", + Object.class, SerializerEncoding.JSON)) + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Naming\"}", Object.class, SerializerEncoding.JSON)) + .withParameters(mapOf("prefix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Prefix") + .withDescription("Resource name prefix") + .withAdditionalProperties(mapOf())), + "suffix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Suffix") + .withDescription("Resource name suffix") + .withAdditionalProperties(mapOf())))) + .withVersion("1.2.1"), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsCreateOrUpdateSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..7769eca26993 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsCreateOrUpdateSamples.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicyDefinitionVersionInner; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValue; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValueMetadata; +import com.azure.resourcemanager.resources.models.ParameterType; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicyDefinitionVersions CreateOrUpdate. + */ +public final class PolicyDefinitionVersionsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicyDefinitionVersion.json + */ + /** + * Sample code: Create or update a policy definition version. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyDefinitionVersion( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyDefinitionVersions() + .createOrUpdateWithResponse("ResourceNaming", "1.2.1", new PolicyDefinitionVersionInner().withMode("All") + .withDisplayName("Enforce resource naming convention") + .withDescription("Force resource names to begin with given 'prefix' and/or end with given 'suffix'") + .withPolicyRule(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize( + "{\"if\":{\"not\":{\"field\":\"name\",\"like\":\"[concat(parameters('prefix'), '*', parameters('suffix'))]\"}},\"then\":{\"effect\":\"deny\"}}", + Object.class, SerializerEncoding.JSON)) + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Naming\"}", Object.class, SerializerEncoding.JSON)) + .withParameters(mapOf("prefix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Prefix") + .withDescription("Resource name prefix") + .withAdditionalProperties(mapOf())), + "suffix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Suffix") + .withDescription("Resource name suffix") + .withAdditionalProperties(mapOf())))) + .withVersion("1.2.1"), com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsDeleteAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsDeleteAtManagementGroupSamples.java new file mode 100644 index 000000000000..bf4afd7573ca --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsDeleteAtManagementGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions DeleteAtManagementGroup. + */ +public final class PolicyDefinitionVersionsDeleteAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicyDefinitionVersionAtManagementGroup.json + */ + /** + * Sample code: Delete a policy definition version at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicyDefinitionVersionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .deleteAtManagementGroupWithResponse("MyManagementGroup", "ResourceNaming", "1.2.1", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsDeleteSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsDeleteSamples.java new file mode 100644 index 000000000000..008f79610c7c --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsDeleteSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions Delete. + */ +public final class PolicyDefinitionVersionsDeleteSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicyDefinitionVersion.json + */ + /** + * Sample code: Delete a policy definition version. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicyDefinitionVersion(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .deleteWithResponse("ResourceNaming", "1.2.1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetAtManagementGroupSamples.java new file mode 100644 index 000000000000..af936448c34b --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetAtManagementGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions GetAtManagementGroup. + */ +public final class PolicyDefinitionVersionsGetAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyDefinitionVersionAtManagementGroup.json + */ + /** + * Sample code: Retrieve a policy definition version at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicyDefinitionVersionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .getAtManagementGroupWithResponse("MyManagementGroup", "ResourceNaming", "1.2.1", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetBuiltInSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetBuiltInSamples.java new file mode 100644 index 000000000000..8734f35f76ea --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetBuiltInSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions GetBuiltIn. + */ +public final class PolicyDefinitionVersionsGetBuiltInSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getBuiltinPolicyDefinitionVersion.json + */ + /** + * Sample code: Retrieve a built-in policy definition version. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveABuiltInPolicyDefinitionVersion(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .getBuiltInWithResponse("7433c107-6db4-4ad1-b57a-a76dce0154a1", "1.2.1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetSamples.java new file mode 100644 index 000000000000..1dfd59e1d043 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsGetSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions Get. + */ +public final class PolicyDefinitionVersionsGetSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyDefinitionVersion.json + */ + /** + * Sample code: Retrieve a policy definition version. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicyDefinitionVersion(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .getWithResponse("ResourceNaming", "1.2.1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllAtManagementGroupSamples.java new file mode 100644 index 000000000000..f66f99b75f7e --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllAtManagementGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions ListAllAtManagementGroup. + */ +public final class PolicyDefinitionVersionsListAllAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listAllPolicyDefinitionVersionsByManagementGroup.json + */ + /** + * Sample code: List all policy definition versions at management group. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listAllPolicyDefinitionVersionsAtManagementGroup(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .listAllAtManagementGroupWithResponse("MyManagementGroup", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllBuiltinsSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllBuiltinsSamples.java new file mode 100644 index 000000000000..754d931f40de --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllBuiltinsSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions ListAllBuiltins. + */ +public final class PolicyDefinitionVersionsListAllBuiltinsSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listAllBuiltInPolicyDefinitionVersions.json + */ + /** + * Sample code: List all built-in policy definition versions. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listAllBuiltInPolicyDefinitionVersions(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .listAllBuiltinsWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllSamples.java new file mode 100644 index 000000000000..99071691d277 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListAllSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions ListAll. + */ +public final class PolicyDefinitionVersionsListAllSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listAllPolicyDefinitionVersions.json + */ + /** + * Sample code: List all policy definition versions at subscription. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listAllPolicyDefinitionVersionsAtSubscription(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient().getPolicyDefinitionVersions().listAllWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListBuiltInSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListBuiltInSamples.java new file mode 100644 index 000000000000..cdcd155dd953 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListBuiltInSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions ListBuiltIn. + */ +public final class PolicyDefinitionVersionsListBuiltInSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listBuiltInPolicyDefinitionVersions.json + */ + /** + * Sample code: List built-in policy definition versions. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listBuiltInPolicyDefinitionVersions(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .listBuiltIn("06a78e20-9358-41c9-923c-fb736d382a12", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListByManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListByManagementGroupSamples.java new file mode 100644 index 000000000000..58c12209c1b0 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListByManagementGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions ListByManagementGroup. + */ +public final class PolicyDefinitionVersionsListByManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicyDefinitionVersionsByManagementGroup.json + */ + /** + * Sample code: List policy definition versions by management group. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyDefinitionVersionsByManagementGroup(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .listByManagementGroup("MyManagementGroup", "ResourceNaming", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListSamples.java new file mode 100644 index 000000000000..ebc8c0c8ca56 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionVersionsListSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitionVersions List. + */ +public final class PolicyDefinitionVersionsListSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicyDefinitionVersions.json + */ + /** + * Sample code: List policy definition versions by subscription. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyDefinitionVersionsBySubscription(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitionVersions() + .list("ResourceNaming", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsCreateOrUpdateAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsCreateOrUpdateAtManagementGroupSamples.java new file mode 100644 index 000000000000..cdfee3427382 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsCreateOrUpdateAtManagementGroupSamples.java @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicyDefinitionInner; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValue; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValueMetadata; +import com.azure.resourcemanager.resources.models.ParameterType; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicyDefinitions CreateOrUpdateAtManagementGroup. + */ +public final class PolicyDefinitionsCreateOrUpdateAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json + */ + /** + * Sample code: Create or update a policy definition at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyDefinitionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyDefinitions() + .createOrUpdateAtManagementGroupWithResponse("MyManagementGroup", "ResourceNaming", + new PolicyDefinitionInner().withMode("All") + .withDisplayName("Enforce resource naming convention") + .withDescription("Force resource names to begin with given 'prefix' and/or end with given 'suffix'") + .withPolicyRule(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize( + "{\"if\":{\"not\":{\"field\":\"name\",\"like\":\"[concat(parameters('prefix'), '*', parameters('suffix'))]\"}},\"then\":{\"effect\":\"deny\"}}", + Object.class, SerializerEncoding.JSON)) + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Naming\"}", Object.class, SerializerEncoding.JSON)) + .withParameters(mapOf("prefix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Prefix") + .withDescription("Resource name prefix") + .withAdditionalProperties(mapOf())), + "suffix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Suffix") + .withDescription("Resource name suffix") + .withAdditionalProperties(mapOf())))), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsCreateOrUpdateSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..3a6dbf3ff4f7 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsCreateOrUpdateSamples.java @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicyDefinitionInner; +import com.azure.resourcemanager.resources.models.ExternalEvaluationEndpointSettings; +import com.azure.resourcemanager.resources.models.ExternalEvaluationEnforcementSettings; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValue; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValueMetadata; +import com.azure.resourcemanager.resources.models.ParameterType; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicyDefinitions CreateOrUpdate. + */ +public final class PolicyDefinitionsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json + */ + /** + * Sample code: Create or update a policy definition with advanced parameters. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyDefinitionWithAdvancedParameters( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyDefinitions() + .createOrUpdateWithResponse("EventHubDiagnosticLogs", new PolicyDefinitionInner().withMode("Indexed") + .withDisplayName("Event Hubs should have diagnostic logging enabled") + .withDescription( + "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised") + .withPolicyRule(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize( + "{\"if\":{\"equals\":\"Microsoft.EventHub/namespaces\",\"field\":\"type\"},\"then\":{\"effect\":\"AuditIfNotExists\",\"details\":{\"type\":\"Microsoft.Insights/diagnosticSettings\",\"existenceCondition\":{\"allOf\":[{\"equals\":\"true\",\"field\":\"Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled\"},{\"equals\":\"[parameters('requiredRetentionDays')]\",\"field\":\"Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days\"}]}}}}", + Object.class, SerializerEncoding.JSON)) + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Event Hub\"}", Object.class, SerializerEncoding.JSON)) + .withParameters(mapOf("requiredRetentionDays", new ParameterDefinitionsValue() + .withType(ParameterType.INTEGER) + .withAllowedValues(Arrays.asList(0, 30, 90, 180, 365)) + .withDefaultValue(365) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Required retention (days)") + .withDescription("The required diagnostic logs retention in days") + .withAdditionalProperties(mapOf())))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicyDefinitionExternalEvaluationEnforcementSettings.json + */ + /** + * Sample code: Create or update a policy definition with external evaluation enforcement settings. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyDefinitionWithExternalEvaluationEnforcementSettings( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyDefinitions() + .createOrUpdateWithResponse("RandomizeVMAllocation", new PolicyDefinitionInner().withMode("Indexed") + .withDisplayName("Randomize VM Allocation") + .withDescription( + "Randomly disable VM allocation in eastus by having policy rule reference the outcome of invoking an external endpoint using the CoinFlip endpoint that returns random values.") + .withPolicyRule(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize( + "{\"if\":{\"allOf\":[{\"equals\":\"Microsoft.Compute/virtualMachines\",\"field\":\"type\"},{\"equals\":\"eastus\",\"field\":\"location\"},{\"equals\":\"false\",\"value\":\"[claims().isValid]\"}]},\"then\":{\"effect\":\"deny\"}}", + Object.class, SerializerEncoding.JSON)) + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"VM\"}", Object.class, SerializerEncoding.JSON)) + .withExternalEvaluationEnforcementSettings(new ExternalEvaluationEnforcementSettings() + .withMissingTokenAction("fakeTokenPlaceholder") + .withEndpointSettings(new ExternalEvaluationEndpointSettings().withKind("CoinFlip") + .withDetails(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"successProbability\":0.5}", Object.class, SerializerEncoding.JSON))) + .withRoleDefinitionIds(Arrays.asList( + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/roleDefinitions/f0cc2aea-b517-48f6-8f9e-0c01c687907b"))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicyDefinition.json + */ + /** + * Sample code: Create or update a policy definition. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyDefinition(com.azure.resourcemanager.resources.ResourceManager manager) + throws IOException { + manager.policyClient() + .getPolicyDefinitions() + .createOrUpdateWithResponse("ResourceNaming", new PolicyDefinitionInner().withMode("All") + .withDisplayName("Enforce resource naming convention") + .withDescription("Force resource names to begin with given 'prefix' and/or end with given 'suffix'") + .withPolicyRule(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize( + "{\"if\":{\"not\":{\"field\":\"name\",\"like\":\"[concat(parameters('prefix'), '*', parameters('suffix'))]\"}},\"then\":{\"effect\":\"deny\"}}", + Object.class, SerializerEncoding.JSON)) + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Naming\"}", Object.class, SerializerEncoding.JSON)) + .withParameters(mapOf("prefix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Prefix") + .withDescription("Resource name prefix") + .withAdditionalProperties(mapOf())), + "suffix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withMetadata(new ParameterDefinitionsValueMetadata().withDisplayName("Suffix") + .withDescription("Resource name suffix") + .withAdditionalProperties(mapOf())))), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsDeleteAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsDeleteAtManagementGroupSamples.java new file mode 100644 index 000000000000..c924e45bdc02 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsDeleteAtManagementGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitions DeleteAtManagementGroup. + */ +public final class PolicyDefinitionsDeleteAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicyDefinitionAtManagementGroup.json + */ + /** + * Sample code: Delete a policy definition at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void + deleteAPolicyDefinitionAtManagementGroupLevel(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitions() + .deleteAtManagementGroupWithResponse("MyManagementGroup", "ResourceNaming", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsDeleteSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsDeleteSamples.java new file mode 100644 index 000000000000..9881eb0799c7 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsDeleteSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitions Delete. + */ +public final class PolicyDefinitionsDeleteSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicyDefinition.json + */ + /** + * Sample code: Delete a policy definition. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicyDefinition(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitions() + .deleteWithResponse("ResourceNaming", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetAtManagementGroupSamples.java new file mode 100644 index 000000000000..282095dc4ffa --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetAtManagementGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitions GetAtManagementGroup. + */ +public final class PolicyDefinitionsGetAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyDefinitionAtManagementGroup.json + */ + /** + * Sample code: Retrieve a policy definition at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveAPolicyDefinitionAtManagementGroupLevel(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitions() + .getAtManagementGroupWithResponse("MyManagementGroup", "ResourceNaming", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetBuiltInSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetBuiltInSamples.java new file mode 100644 index 000000000000..a95a8e47dc59 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetBuiltInSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitions GetBuiltIn. + */ +public final class PolicyDefinitionsGetBuiltInSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getBuiltinPolicyDefinition.json + */ + /** + * Sample code: Retrieve a built-in policy definition. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveABuiltInPolicyDefinition(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitions() + .getBuiltInWithResponse("7433c107-6db4-4ad1-b57a-a76dce0154a1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetSamples.java new file mode 100644 index 000000000000..0680f9d9473a --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsGetSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitions Get. + */ +public final class PolicyDefinitionsGetSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicyDefinition.json + */ + /** + * Sample code: Retrieve a policy definition. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicyDefinition(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitions() + .getWithResponse("ResourceNaming", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListBuiltInSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListBuiltInSamples.java new file mode 100644 index 000000000000..99c260237142 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListBuiltInSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitions ListBuiltIn. + */ +public final class PolicyDefinitionsListBuiltInSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listBuiltInPolicyDefinitions.json + */ + /** + * Sample code: List built-in policy definitions. + * + * @param manager Entry point to ResourceManager. + */ + public static void listBuiltInPolicyDefinitions(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient().getPolicyDefinitions().listBuiltIn(null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListByManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListByManagementGroupSamples.java new file mode 100644 index 000000000000..89642e30a634 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListByManagementGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitions ListByManagementGroup. + */ +public final class PolicyDefinitionsListByManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicyDefinitionsByManagementGroup.json + */ + /** + * Sample code: List policy definitions by management group. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyDefinitionsByManagementGroup(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyDefinitions() + .listByManagementGroup("MyManagementGroup", null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListSamples.java new file mode 100644 index 000000000000..45b9fbe0223c --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyDefinitionsListSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyDefinitions List. + */ +public final class PolicyDefinitionsListSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicyDefinitions.json + */ + /** + * Sample code: List policy definitions by subscription. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyDefinitionsBySubscription(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient().getPolicyDefinitions().list(null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsCreateOrUpdateSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..a95063e490da --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsCreateOrUpdateSamples.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicyExemptionInner; +import com.azure.resourcemanager.resources.models.AssignmentScopeValidation; +import com.azure.resourcemanager.resources.models.ExemptionCategory; +import com.azure.resourcemanager.resources.models.ResourceSelector; +import com.azure.resourcemanager.resources.models.Selector; +import com.azure.resourcemanager.resources.models.SelectorKind; +import java.io.IOException; +import java.util.Arrays; + +/** + * Samples for PolicyExemptions CreateOrUpdate. + */ +public final class PolicyExemptionsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/createOrUpdatePolicyExemption.json + */ + /** + * Sample code: Create or update a policy exemption. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyExemption(com.azure.resourcemanager.resources.ResourceManager manager) + throws IOException { + manager.policyClient() + .getPolicyExemptions() + .createOrUpdateWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", + "DemoExpensiveVM", + new PolicyExemptionInner().withPolicyAssignmentId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement") + .withPolicyDefinitionReferenceIds(Arrays.asList("Limit_Skus")) + .withExemptionCategory(ExemptionCategory.WAIVER) + .withDisplayName("Exempt demo cluster") + .withDescription("Exempt demo cluster from limit sku") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"reason\":\"Temporary exemption for a expensive VM demo\"}", Object.class, + SerializerEncoding.JSON)), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/createOrUpdatePolicyExemptionWithResourceSelectors.json + */ + /** + * Sample code: Create or update a policy exemption with resource selectors. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicyExemptionWithResourceSelectors( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicyExemptions() + .createOrUpdateWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", + "DemoExpensiveVM", + new PolicyExemptionInner().withPolicyAssignmentId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement") + .withPolicyDefinitionReferenceIds(Arrays.asList("Limit_Skus")) + .withExemptionCategory(ExemptionCategory.WAIVER) + .withDisplayName("Exempt demo cluster") + .withDescription("Exempt demo cluster from limit sku") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"reason\":\"Temporary exemption for a expensive VM demo\"}", Object.class, + SerializerEncoding.JSON)) + .withResourceSelectors(Arrays.asList(new ResourceSelector().withName("SDPRegions") + .withSelectors(Arrays.asList(new Selector().withKind(SelectorKind.RESOURCE_LOCATION) + .withIn(Arrays.asList("eastus2euap", "centraluseuap")))))) + .withAssignmentScopeValidation(AssignmentScopeValidation.DEFAULT), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsDeleteSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsDeleteSamples.java new file mode 100644 index 000000000000..5952073b2ae9 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsDeleteSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyExemptions Delete. + */ +public final class PolicyExemptionsDeleteSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/deletePolicyExemption.json + */ + /** + * Sample code: Delete a policy exemption. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicyExemption(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyExemptions() + .deleteWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", + "DemoExpensiveVM", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsGetSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsGetSamples.java new file mode 100644 index 000000000000..532b83b188de --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsGetSamples.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyExemptions Get. + */ +public final class PolicyExemptionsGetSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/getPolicyExemptionWithResourceSelectors.json + */ + /** + * Sample code: Retrieve a policy exemption with resource selectors. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveAPolicyExemptionWithResourceSelectors(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyExemptions() + .getWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", + "DemoExpensiveVM", com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/getPolicyExemption.json + */ + /** + * Sample code: Retrieve a policy exemption. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicyExemption(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyExemptions() + .getWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", + "DemoExpensiveVM", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListByResourceGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListByResourceGroupSamples.java new file mode 100644 index 000000000000..93c9b91c7c7e --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListByResourceGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyExemptions ListByResourceGroup. + */ +public final class PolicyExemptionsListByResourceGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json + */ + /** + * Sample code: List policy exemptions that apply to a resource group. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyExemptionsThatApplyToAResourceGroup(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyExemptions() + .listByResourceGroup("TestResourceGroup", "atScope()", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListForManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListForManagementGroupSamples.java new file mode 100644 index 000000000000..541d9d5be3e2 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListForManagementGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyExemptions ListForManagementGroup. + */ +public final class PolicyExemptionsListForManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json + */ + /** + * Sample code: List policy exemptions that apply to a management group. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyExemptionsThatApplyToAManagementGroup(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyExemptions() + .listForManagementGroup("DevOrg", "atScope()", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListForResourceSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListForResourceSamples.java new file mode 100644 index 000000000000..336fa31b283e --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListForResourceSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyExemptions ListForResource. + */ +public final class PolicyExemptionsListForResourceSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/listPolicyExemptionsForResource.json + */ + /** + * Sample code: List all policy exemptions that apply to a resource. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listAllPolicyExemptionsThatApplyToAResource(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyExemptions() + .listForResource("TestResourceGroup", "Microsoft.Compute", "virtualMachines/MyTestVm", "domainNames", + "MyTestComputer.cloudapp.net", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListSamples.java new file mode 100644 index 000000000000..89237cb7452f --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsListSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicyExemptions List. + */ +public final class PolicyExemptionsListSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/listPolicyExemptionsForSubscription.json + */ + /** + * Sample code: List policy exemptions that apply to a subscription. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicyExemptionsThatApplyToASubscription(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient().getPolicyExemptions().list("atScope()", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsUpdateSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsUpdateSamples.java new file mode 100644 index 000000000000..79a63f745673 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyExemptionsUpdateSamples.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.resourcemanager.resources.models.AssignmentScopeValidation; +import com.azure.resourcemanager.resources.models.PolicyExemptionUpdate; +import com.azure.resourcemanager.resources.models.ResourceSelector; +import com.azure.resourcemanager.resources.models.Selector; +import com.azure.resourcemanager.resources.models.SelectorKind; +import java.util.Arrays; + +/** + * Samples for PolicyExemptions Update. + */ +public final class PolicyExemptionsUpdateSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * preview/2022-07-01-preview/examples/updatePolicyExemptionWithResourceSelectors.json + */ + /** + * Sample code: Update a policy exemption with resource selectors. + * + * @param manager Entry point to ResourceManager. + */ + public static void + updateAPolicyExemptionWithResourceSelectors(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyExemptions() + .updateWithResponse("subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster", + "DemoExpensiveVM", + new PolicyExemptionUpdate() + .withResourceSelectors(Arrays.asList(new ResourceSelector().withName("SDPRegions") + .withSelectors(Arrays.asList(new Selector().withKind(SelectorKind.RESOURCE_LOCATION) + .withIn(Arrays.asList("eastus2euap", "centraluseuap")))))) + .withAssignmentScopeValidation(AssignmentScopeValidation.DEFAULT), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupSamples.java new file mode 100644 index 000000000000..20d4d09ebd90 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupSamples.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicySetDefinitionVersionInner; +import com.azure.resourcemanager.resources.models.ParameterValuesValue; +import com.azure.resourcemanager.resources.models.PolicyDefinitionReference; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicySetDefinitionVersions CreateOrUpdateAtManagementGroup. + */ +public final class PolicySetDefinitionVersionsCreateOrUpdateAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicySetDefinitionVersionAtManagementGroup.json + */ + /** + * Sample code: Create or update a policy set definition version at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicySetDefinitionVersionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicySetDefinitionVersions() + .createOrUpdateAtManagementGroupWithResponse("MyManagementGroup", "CostManagement", "1.2.1", + new PolicySetDefinitionVersionInner().withDisplayName("Cost Management") + .withDescription("Policies to enforce low cost storage SKUs") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Cost Management\"}", Object.class, SerializerEncoding.JSON)) + .withPolicyDefinitions(Arrays.asList(new PolicyDefinitionReference().withPolicyDefinitionId( + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + .withParameters(mapOf("listOfAllowedSKUs", + new ParameterValuesValue() + .withValue(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("[\"Standard_GRS\",\"Standard_LRS\"]", Object.class, + SerializerEncoding.JSON)))) + .withPolicyDefinitionReferenceId("Limit_Skus"), + new PolicyDefinitionReference().withPolicyDefinitionId( + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withPolicyDefinitionReferenceId("Resource_Naming"))) + .withVersion("1.2.1"), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsCreateOrUpdateSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..f5329c71b91a --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsCreateOrUpdateSamples.java @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicySetDefinitionVersionInner; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValue; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValueMetadata; +import com.azure.resourcemanager.resources.models.ParameterType; +import com.azure.resourcemanager.resources.models.ParameterValuesValue; +import com.azure.resourcemanager.resources.models.PolicyDefinitionReference; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicySetDefinitionVersions CreateOrUpdate. + */ +public final class PolicySetDefinitionVersionsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicySetDefinitionVersion.json + */ + /** + * Sample code: Create or update a policy set definition version. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicySetDefinitionVersion( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicySetDefinitionVersions() + .createOrUpdateWithResponse("CostManagement", "1.2.1", + new PolicySetDefinitionVersionInner().withDisplayName("Cost Management") + .withDescription("Policies to enforce low cost storage SKUs") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Cost Management\"}", Object.class, SerializerEncoding.JSON)) + .withParameters(mapOf("namePrefix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withDefaultValue("myPrefix") + .withMetadata(new ParameterDefinitionsValueMetadata() + .withDisplayName("Prefix to enforce on resource names") + .withAdditionalProperties(mapOf())))) + .withPolicyDefinitions(Arrays.asList(new PolicyDefinitionReference().withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + .withParameters(mapOf("listOfAllowedSKUs", + new ParameterValuesValue() + .withValue(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("[\"Standard_GRS\",\"Standard_LRS\"]", Object.class, + SerializerEncoding.JSON)))) + .withPolicyDefinitionReferenceId("Limit_Skus"), + new PolicyDefinitionReference().withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters( + mapOf("prefix", new ParameterValuesValue().withValue("[parameters('namePrefix')]"), + "suffix", new ParameterValuesValue().withValue("-LC"))) + .withPolicyDefinitionReferenceId("Resource_Naming"))) + .withVersion("1.2.1"), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsDeleteAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsDeleteAtManagementGroupSamples.java new file mode 100644 index 000000000000..978882363958 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsDeleteAtManagementGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions DeleteAtManagementGroup. + */ +public final class PolicySetDefinitionVersionsDeleteAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicySetDefinitionVersionAtManagementGroup.json + */ + /** + * Sample code: Delete a policy set definition version at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicySetDefinitionVersionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .deleteAtManagementGroupWithResponse("MyManagementGroup", "CostManagement", "1.2.1", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsDeleteSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsDeleteSamples.java new file mode 100644 index 000000000000..99b084405371 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsDeleteSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions Delete. + */ +public final class PolicySetDefinitionVersionsDeleteSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicySetDefinitionVersion.json + */ + /** + * Sample code: Delete a policy set definition version. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicySetDefinitionVersion(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .deleteWithResponse("CostManagement", "1.2.1", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetAtManagementGroupSamples.java new file mode 100644 index 000000000000..a24624564335 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetAtManagementGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions GetAtManagementGroup. + */ +public final class PolicySetDefinitionVersionsGetAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicySetDefinitionVersionAtManagementGroup.json + */ + /** + * Sample code: Retrieve a policy set definition version at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicySetDefinitionVersionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .getAtManagementGroupWithResponse("MyManagementGroup", "CostManagement", "1.2.1", null, + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetBuiltInSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetBuiltInSamples.java new file mode 100644 index 000000000000..4e6d35c983fc --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetBuiltInSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions GetBuiltIn. + */ +public final class PolicySetDefinitionVersionsGetBuiltInSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getBuiltInPolicySetDefinitionVersion.json + */ + /** + * Sample code: Retrieve a built-in policy set definition version. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveABuiltInPolicySetDefinitionVersion(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .getBuiltInWithResponse("1f3afdf9-d0c9-4c3d-847f-89da613e70a8", "1.2.1", null, + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetSamples.java new file mode 100644 index 000000000000..d602cde35b7a --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsGetSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions Get. + */ +public final class PolicySetDefinitionVersionsGetSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicySetDefinitionVersion.json + */ + /** + * Sample code: Retrieve a policy set definition version. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveAPolicySetDefinitionVersion(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .getWithResponse("CostManagement", "1.2.1", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllAtManagementGroupSamples.java new file mode 100644 index 000000000000..c7ad2c245634 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllAtManagementGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions ListAllAtManagementGroup. + */ +public final class PolicySetDefinitionVersionsListAllAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listAllPolicySetDefinitionVersionsByManagementGroup.json + */ + /** + * Sample code: List all policy definition versions at management group. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listAllPolicyDefinitionVersionsAtManagementGroup(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .listAllAtManagementGroupWithResponse("MyManagementGroup", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllBuiltinsSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllBuiltinsSamples.java new file mode 100644 index 000000000000..306937c8ae54 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllBuiltinsSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions ListAllBuiltins. + */ +public final class PolicySetDefinitionVersionsListAllBuiltinsSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listAllBuiltInPolicySetDefinitionVersions.json + */ + /** + * Sample code: List all built-in policy definition versions. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listAllBuiltInPolicyDefinitionVersions(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .listAllBuiltinsWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllSamples.java new file mode 100644 index 000000000000..732812e15bcf --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListAllSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions ListAll. + */ +public final class PolicySetDefinitionVersionsListAllSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listAllPolicySetDefinitionVersions.json + */ + /** + * Sample code: List all policy definition versions at subscription. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listAllPolicyDefinitionVersionsAtSubscription(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient().getPolicySetDefinitionVersions().listAllWithResponse(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListBuiltInSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListBuiltInSamples.java new file mode 100644 index 000000000000..2fb83acf9b06 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListBuiltInSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions ListBuiltIn. + */ +public final class PolicySetDefinitionVersionsListBuiltInSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listBuiltInPolicySetDefinitionVersions.json + */ + /** + * Sample code: List built-in policy set definitions. + * + * @param manager Entry point to ResourceManager. + */ + public static void listBuiltInPolicySetDefinitions(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .listBuiltIn("1f3afdf9-d0c9-4c3d-847f-89da613e70a8", null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListByManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListByManagementGroupSamples.java new file mode 100644 index 000000000000..955e09904038 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListByManagementGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions ListByManagementGroup. + */ +public final class PolicySetDefinitionVersionsListByManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicySetDefinitionVersionsByManagementGroup.json + */ + /** + * Sample code: List policy set definitions at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicySetDefinitionsAtManagementGroupLevel(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .listByManagementGroup("MyManagementGroup", "CostManagement", null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListSamples.java new file mode 100644 index 000000000000..cf683430749d --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionVersionsListSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitionVersions List. + */ +public final class PolicySetDefinitionVersionsListSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicySetDefinitionVersions.json + */ + /** + * Sample code: List policy set definitions. + * + * @param manager Entry point to ResourceManager. + */ + public static void listPolicySetDefinitions(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitionVersions() + .list("CostManagement", null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsCreateOrUpdateAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsCreateOrUpdateAtManagementGroupSamples.java new file mode 100644 index 000000000000..a074f3b91d6e --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsCreateOrUpdateAtManagementGroupSamples.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicySetDefinitionInner; +import com.azure.resourcemanager.resources.models.ParameterValuesValue; +import com.azure.resourcemanager.resources.models.PolicyDefinitionGroup; +import com.azure.resourcemanager.resources.models.PolicyDefinitionReference; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicySetDefinitions CreateOrUpdateAtManagementGroup. + */ +public final class PolicySetDefinitionsCreateOrUpdateAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json + */ + /** + * Sample code: Create or update a policy set definition with groups at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicySetDefinitions() + .createOrUpdateAtManagementGroupWithResponse("MyManagementGroup", "CostManagement", + new PolicySetDefinitionInner().withDisplayName("Cost Management") + .withDescription("Policies to enforce low cost storage SKUs") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Cost Management\"}", Object.class, SerializerEncoding.JSON)) + .withPolicyDefinitions(Arrays.asList(new PolicyDefinitionReference().withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + .withParameters(mapOf("listOfAllowedSKUs", + new ParameterValuesValue() + .withValue(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("[\"Standard_GRS\",\"Standard_LRS\"]", Object.class, + SerializerEncoding.JSON)))) + .withPolicyDefinitionReferenceId("Limit_Skus") + .withGroupNames(Arrays.asList("CostSaving")), + new PolicyDefinitionReference().withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withPolicyDefinitionReferenceId("Resource_Naming") + .withGroupNames(Arrays.asList("Organizational")))) + .withPolicyDefinitionGroups(Arrays.asList( + new PolicyDefinitionGroup().withName("CostSaving") + .withDisplayName("Cost Management Policies") + .withDescription("Policies designed to control spend within a subscription."), + new PolicyDefinitionGroup().withName("Organizational") + .withDisplayName("Organizational Policies") + .withDescription( + "Policies that help enforce resource organization standards within a subscription."))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json + */ + /** + * Sample code: Create or update a policy set definition at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicySetDefinitionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicySetDefinitions() + .createOrUpdateAtManagementGroupWithResponse("MyManagementGroup", "CostManagement", + new PolicySetDefinitionInner().withDisplayName("Cost Management") + .withDescription("Policies to enforce low cost storage SKUs") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Cost Management\"}", Object.class, SerializerEncoding.JSON)) + .withPolicyDefinitions(Arrays.asList(new PolicyDefinitionReference().withPolicyDefinitionId( + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + .withParameters(mapOf("listOfAllowedSKUs", + new ParameterValuesValue() + .withValue(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("[\"Standard_GRS\",\"Standard_LRS\"]", Object.class, + SerializerEncoding.JSON)))) + .withPolicyDefinitionReferenceId("Limit_Skus"), + new PolicyDefinitionReference().withPolicyDefinitionId( + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withPolicyDefinitionReferenceId("Resource_Naming"))), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsCreateOrUpdateSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsCreateOrUpdateSamples.java new file mode 100644 index 000000000000..12e10587c4e1 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsCreateOrUpdateSamples.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.resources.fluent.models.PolicySetDefinitionInner; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValue; +import com.azure.resourcemanager.resources.models.ParameterDefinitionsValueMetadata; +import com.azure.resourcemanager.resources.models.ParameterType; +import com.azure.resourcemanager.resources.models.ParameterValuesValue; +import com.azure.resourcemanager.resources.models.PolicyDefinitionGroup; +import com.azure.resourcemanager.resources.models.PolicyDefinitionReference; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for PolicySetDefinitions CreateOrUpdate. + */ +public final class PolicySetDefinitionsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json + */ + /** + * Sample code: Create or update a policy set definition with groups. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicySetDefinitionWithGroups( + com.azure.resourcemanager.resources.ResourceManager manager) throws IOException { + manager.policyClient() + .getPolicySetDefinitions() + .createOrUpdateWithResponse("CostManagement", new PolicySetDefinitionInner() + .withDisplayName("Cost Management") + .withDescription("Policies to enforce low cost storage SKUs") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Cost Management\"}", Object.class, SerializerEncoding.JSON)) + .withPolicyDefinitions(Arrays.asList(new PolicyDefinitionReference().withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + .withDefinitionVersion("1.*.*") + .withParameters(mapOf("listOfAllowedSKUs", new ParameterValuesValue().withValue(SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize("[\"Standard_GRS\",\"Standard_LRS\"]", Object.class, SerializerEncoding.JSON)))) + .withPolicyDefinitionReferenceId("Limit_Skus") + .withGroupNames(Arrays.asList("CostSaving")), + new PolicyDefinitionReference().withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withDefinitionVersion("1.*.*") + .withParameters(mapOf("prefix", new ParameterValuesValue().withValue("DeptA"), "suffix", + new ParameterValuesValue().withValue("-LC"))) + .withPolicyDefinitionReferenceId("Resource_Naming") + .withGroupNames(Arrays.asList("Organizational")))) + .withPolicyDefinitionGroups(Arrays.asList( + new PolicyDefinitionGroup().withName("CostSaving") + .withDisplayName("Cost Management Policies") + .withDescription("Policies designed to control spend within a subscription."), + new PolicyDefinitionGroup().withName("Organizational") + .withDisplayName("Organizational Policies") + .withDescription( + "Policies that help enforce resource organization standards within a subscription."))), + com.azure.core.util.Context.NONE); + } + + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/createOrUpdatePolicySetDefinition.json + */ + /** + * Sample code: Create or update a policy set definition. + * + * @param manager Entry point to ResourceManager. + */ + public static void createOrUpdateAPolicySetDefinition(com.azure.resourcemanager.resources.ResourceManager manager) + throws IOException { + manager.policyClient() + .getPolicySetDefinitions() + .createOrUpdateWithResponse("CostManagement", + new PolicySetDefinitionInner().withDisplayName("Cost Management") + .withDescription("Policies to enforce low cost storage SKUs") + .withMetadata(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("{\"category\":\"Cost Management\"}", Object.class, SerializerEncoding.JSON)) + .withParameters(mapOf("namePrefix", + new ParameterDefinitionsValue().withType(ParameterType.STRING) + .withDefaultValue("myPrefix") + .withMetadata(new ParameterDefinitionsValueMetadata() + .withDisplayName("Prefix to enforce on resource names") + .withAdditionalProperties(mapOf())))) + .withPolicyDefinitions(Arrays.asList(new PolicyDefinitionReference().withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + .withParameters(mapOf("listOfAllowedSKUs", + new ParameterValuesValue() + .withValue(SerializerFactory.createDefaultManagementSerializerAdapter() + .deserialize("[\"Standard_GRS\",\"Standard_LRS\"]", Object.class, + SerializerEncoding.JSON)))) + .withPolicyDefinitionReferenceId("Limit_Skus"), + new PolicyDefinitionReference().withPolicyDefinitionId( + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") + .withParameters( + mapOf("prefix", new ParameterValuesValue().withValue("[parameters('namePrefix')]"), + "suffix", new ParameterValuesValue().withValue("-LC"))) + .withPolicyDefinitionReferenceId("Resource_Naming"))), + com.azure.core.util.Context.NONE); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsDeleteAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsDeleteAtManagementGroupSamples.java new file mode 100644 index 000000000000..b4d47a7ba3a4 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsDeleteAtManagementGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitions DeleteAtManagementGroup. + */ +public final class PolicySetDefinitionsDeleteAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicySetDefinitionAtManagementGroup.json + */ + /** + * Sample code: Delete a policy set definition at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void + deleteAPolicySetDefinitionAtManagementGroupLevel(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitions() + .deleteAtManagementGroupWithResponse("MyManagementGroup", "CostManagement", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsDeleteSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsDeleteSamples.java new file mode 100644 index 000000000000..3772d12c57d0 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsDeleteSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitions Delete. + */ +public final class PolicySetDefinitionsDeleteSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/deletePolicySetDefinition.json + */ + /** + * Sample code: Delete a policy set definition. + * + * @param manager Entry point to ResourceManager. + */ + public static void deleteAPolicySetDefinition(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitions() + .deleteWithResponse("CostManagement", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetAtManagementGroupSamples.java new file mode 100644 index 000000000000..09f06a433e64 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetAtManagementGroupSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitions GetAtManagementGroup. + */ +public final class PolicySetDefinitionsGetAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicySetDefinitionAtManagementGroup.json + */ + /** + * Sample code: Retrieve a policy set definition at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicySetDefinitionAtManagementGroupLevel( + com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitions() + .getAtManagementGroupWithResponse("MyManagementGroup", "CostManagement", null, + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetBuiltInSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetBuiltInSamples.java new file mode 100644 index 000000000000..f863ba673010 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetBuiltInSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitions GetBuiltIn. + */ +public final class PolicySetDefinitionsGetBuiltInSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getBuiltInPolicySetDefinition.json + */ + /** + * Sample code: Retrieve a built-in policy set definition. + * + * @param manager Entry point to ResourceManager. + */ + public static void + retrieveABuiltInPolicySetDefinition(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitions() + .getBuiltInWithResponse("1f3afdf9-d0c9-4c3d-847f-89da613e70a8", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetSamples.java new file mode 100644 index 000000000000..ef6e62c105e0 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsGetSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitions Get. + */ +public final class PolicySetDefinitionsGetSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/getPolicySetDefinition.json + */ + /** + * Sample code: Retrieve a policy set definition. + * + * @param manager Entry point to ResourceManager. + */ + public static void retrieveAPolicySetDefinition(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitions() + .getWithResponse("CostManagement", null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListBuiltInSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListBuiltInSamples.java new file mode 100644 index 000000000000..0debd71c273e --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListBuiltInSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitions ListBuiltIn. + */ +public final class PolicySetDefinitionsListBuiltInSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listBuiltInPolicySetDefinitions.json + */ + /** + * Sample code: List built-in policy set definitions. + * + * @param manager Entry point to ResourceManager. + */ + public static void listBuiltInPolicySetDefinitions(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitions() + .listBuiltIn(null, null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListByManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListByManagementGroupSamples.java new file mode 100644 index 000000000000..b4d648a432db --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListByManagementGroupSamples.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitions ListByManagementGroup. + */ +public final class PolicySetDefinitionsListByManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicySetDefinitionsByManagementGroup.json + */ + /** + * Sample code: List policy set definitions at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void + listPolicySetDefinitionsAtManagementGroupLevel(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicySetDefinitions() + .listByManagementGroup("MyManagementGroup", null, null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListSamples.java new file mode 100644 index 000000000000..c3d6d7477a18 --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicySetDefinitionsListSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +/** + * Samples for PolicySetDefinitions List. + */ +public final class PolicySetDefinitionsListSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/listPolicySetDefinitions.json + */ + /** + * Sample code: List policy set definitions. + * + * @param manager Entry point to ResourceManager. + */ + public static void listPolicySetDefinitions(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient().getPolicySetDefinitions().list(null, null, null, com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyTokensAcquireAtManagementGroupSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyTokensAcquireAtManagementGroupSamples.java new file mode 100644 index 000000000000..603d49812f5d --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyTokensAcquireAtManagementGroupSamples.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.resourcemanager.resources.models.PolicyTokenOperation; +import com.azure.resourcemanager.resources.models.PolicyTokenRequest; + +/** + * Samples for PolicyTokens AcquireAtManagementGroup. + */ +public final class PolicyTokensAcquireAtManagementGroupSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/acquirePolicyTokenAtManagementGroup.json + */ + /** + * Sample code: Acquire a policy token at management group level. + * + * @param manager Entry point to ResourceManager. + */ + public static void + acquireAPolicyTokenAtManagementGroupLevel(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyTokens() + .acquireAtManagementGroupWithResponse("MyManagementGroup", + new PolicyTokenRequest().withOperation(new PolicyTokenOperation().withUri( + "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000?api-version=2022-04-01") + .withHttpMethod("delete")), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyTokensAcquireSamples.java b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyTokensAcquireSamples.java new file mode 100644 index 000000000000..697cbd3d004b --- /dev/null +++ b/sdk/resources/azure-resourcemanager-resources/src/samples/java/com/azure/resourcemanager/resources/generated/PolicyTokensAcquireSamples.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resources.generated; + +import com.azure.resourcemanager.resources.models.PolicyTokenOperation; +import com.azure.resourcemanager.resources.models.PolicyTokenRequest; + +/** + * Samples for PolicyTokens Acquire. + */ +public final class PolicyTokensAcquireSamples { + /* + * x-ms-original-file: + * 2b3c430bff9474d80080498090d71caf3fafcb75/specification/resources/resource-manager/Microsoft.Authorization/policy/ + * stable/2025-03-01/examples/acquirePolicyToken.json + */ + /** + * Sample code: Acquire a policy token. + * + * @param manager Entry point to ResourceManager. + */ + public static void acquireAPolicyToken(com.azure.resourcemanager.resources.ResourceManager manager) { + manager.policyClient() + .getPolicyTokens() + .acquireWithResponse(new PolicyTokenRequest().withOperation(new PolicyTokenOperation().withUri( + "https://management.azure.com/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM?api-version=2024-01-01") + .withHttpMethod("delete")), com.azure.core.util.Context.NONE); + } +}